Compare commits

...

2 Commits

1 changed files with 23 additions and 9 deletions

View File

@ -2371,7 +2371,17 @@ list detailing and motivating each listing:
(defun org-ctags-disable ()
"Undo calling `org-ctags-enable'."
(setq org-ctags-enabled-p nil)
(setq org-open-link-functions nil)
;; Steal the options list from the `org-ctags-open-link-functions' code.
(setq org-open-link-functions
(seq-difference org-open-link-functions
'(org-ctags-append-topic
org-ctags-ask-append-topic
org-ctags-ask-rebuild-tags-file-then-find-tag
org-ctags-ask-visit-buffer-or-file
org-ctags-fail-silently
org-ctags-find-tag
org-ctags-rebuild-tags-file-then-find-tag
org-ctags-visit-buffer-or-file)))
(put 'org-mode 'find-tag-default-function nil))
(with-eval-after-load 'org-ctags
@ -4721,8 +4731,10 @@ it for this buffer is by typing {{{kbd(C-c C-e t U)}}} to export the it to a
:CUSTOM_ID: sec:which-function-mode
:END:
The code in listing [[lst:setup-which-function-mode]] has stolen ideas from the
following links:
The post [[https://codelearn.me/2024/02/02/emacs-which-function-mode.html][Emacs: which-function-mode]] claims that ~which-function-mode~ works in
~org-mode~. This is true in case all document headlines are simple, but is not
true in case document headlines contain links. The code in listing
[[lst:setup-which-function-mode]] has stolen ideas from the following links:
- [[https://list.orgmode.org/20240205.141235.268481480563517065.teika@gmx.com/][Show current org-mode headline in frame header]].
- [[https://emacs.stackexchange.com/questions/30894/][Show current org-mode headline in modeline]].
@ -4735,30 +4747,32 @@ following links:
(defvar which-func-functions nil)
(defun which--org-function ()
(defun which-func-org-function ()
"Return level and title of the current headline.
Return the document title when point is above the first headline."
(interactive) ;; Keep this function interactive for debugging.
(interactive) ;; Keep this function interactive for fixing.
(when (eq major-mode 'org-mode)
(let (text)
;; Handle point eventually above the first headline.
(unless (org-at-heading-p)
(save-excursion
(org-previous-visible-heading 1)
(let ((eap (org-element-at-point)))
(when (org-element-type-p eap 'keyword)
(setq text (format "0|%s" (org-element-property :value eap)))))))
;; Handle point anywhere else.
(unless text
(let* ((chain (org-get-outline-path t))
(count (length chain)))
(setq text (format "%s|%s" count (nth (1- count) chain)))))
text)))
(add-to-list 'which-func-functions 'which--org-function)
(add-to-list 'which-func-functions 'which-func-org-function)
(defun which--pdf-function ()
(defun which-func-pdf-view-function ()
"Return the title of the current headline.
Return \"Front Matter\" when point is above the first headline."
(interactive) ;; Keep this function interactive for debugging.
(interactive) ;; Keep this function interactive for fixing.
(when (eq major-mode 'pdf-view-mode)
(let* ((current-page (pdf-view-current-page))
(outline (pdf-info-outline (current-buffer)))
@ -4774,7 +4788,7 @@ Return \"Front Matter\" when point is above the first headline."
(cl-incf hl-index))
(if (< current-page hl-page) old-title new-title))))
(add-to-list 'which-func-functions 'which--pdf-function)
(add-to-list 'which-func-functions 'which-func-pdf-view-function)
#+end_src
* [[info:emacs#Saving Emacs Sessions][Saving Emacs sessions (info)]]