Tweak the `which-function-mode' section

This commit is contained in:
Gerard Vermeulen 2024-02-07 13:15:50 +01:00
parent 9a3bf288cc
commit 1098fab11b
1 changed files with 17 additions and 3 deletions

View File

@ -4745,10 +4745,11 @@ 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 post [[https://codelearn.me/2024/02/02/emacs-which-function-mode.html][Emacs: which-function-mode]] claims that ~which-function-mode~ works in
Listing [[lst:setup-which-function-mode]] sets ~which-function-mode~ options. 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:
[[lst:define-for-which-func-functions]] 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]].
@ -4756,8 +4757,21 @@ true in case document headlines contain links. The code in listing
#+caption: Setup ~which-function-mode~.
#+name: lst:setup-which-function-mode
#+begin_src emacs-lisp -n :results silent
;; https://emacs.stackexchange.com/questions/30894/
(setopt which-func-modes '(emacs-lisp-mode org-mode pdf-view-mode))
;; It looks like `python-mode' does nothing when they it is an element
;; of `which-func-modes'.
;; (setopt which-func-modes t)
;; (setopt which-func-display 'header) ;; AFAIU, fails on my system.
#+end_src
#+caption[Define functions for ~which-func-functions~]:
#+caption: Define functions for ~which-func-functions~.
#+name: lst:define-for-which-func-functions
#+begin_src emacs-lisp -n :results silent
;; https://emacs.stackexchange.com/questions/30894/
(defvar which-func-functions nil)
(defun which-func-org-function ()