Compare commits

...

2 Commits

1 changed files with 65 additions and 0 deletions

View File

@ -1649,6 +1649,7 @@ completion function [[info:elisp#Minibuffer Completion][completing-read]]. List
| consult-mark | goto-map | {{{kbd(M-g m)}}} |
| consult-mode-command | global-map | {{{kbd(C-c m)}}} |
| consult-multi-occur | search-map | {{{kbd(M-s m)}}} |
| consult-org-heading | org-mode-map | {{{kbd(C-c C-h)}}} |
| consult-outline | goto-map | {{{kbd(M-g o)}}} |
| consult-register | ctl-x-r-keymap | {{{kbd(C-x r x)}}} |
| consult-yank-pop | global-map | {{{kbd(M-y)}}} |
@ -1663,6 +1664,7 @@ completion function [[info:elisp#Minibuffer Completion][completing-read]]. List
| org-agenda | global-map | {{{kbd(C-c a)}}} |
| org-capture | global-map | {{{kbd(C-c c)}}} |
| org-cite | org-mode-map | {{{kbd(C-c b)}}} |
| org-goto | org-goto | {{{kbd(C-c C-j)}}} |
| org-insert-link-global | global-map | {{{kbd(C-c C-l)}}} |
| org-narrow-to-table | ctl-x-keymap | {{{kbd(C-x n t)}}} |
| org-store-link | global-map | {{{kbd(C-c l)}}} |
@ -1692,6 +1694,8 @@ completion function [[info:elisp#Minibuffer Completion][completing-read]]. List
(keymap-set goto-map "k" #'consult-global-mark)
(keymap-set goto-map "i" #'consult-imenu)
(keymap-set goto-map "e" #'consult-compile-error)
(with-eval-after-load 'org
(keymap-set org-mode-map "C-c C-h" #'consult-org-heading))
;; M-s bindings (search-map)
(keymap-set search-map "g" #'consult-git-grep)
(keymap-set search-map "f" #'consult-find)
@ -4712,6 +4716,67 @@ it for this buffer is by typing {{{kbd(C-c C-e t U)}}} to export the it to a
(global-set-key (kbd "C-c g") #'writegood-mode))
#+end_src
** [[info:emacs#Which Function][Which-function-mode (info)]]
:PROPERTIES:
:CUSTOM_ID: sec:which-function-mode
:END:
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]].
#+caption[Setup ~which-function-mode~]:
#+caption: Setup ~which-function-mode~.
#+name: lst:setup-which-function-mode
#+begin_src emacs-lisp -n :results silent
;; https://emacs.stackexchange.com/questions/30894/
;; https://list.orgmode.org/20240205.141235.268481480563517065.teika@gmx.com/
(defvar which-func-functions nil)
(defun which--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.
(when (eq major-mode 'org-mode)
(let (text)
(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)))))))
(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)
(defun which--pdf-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.
(when (eq major-mode 'pdf-view-mode)
(let* ((current-page (pdf-view-current-page))
(outline (pdf-info-outline (current-buffer)))
(hl-count (length outline))
(hl-index 0)
(hl-page 0)
(old-title "Front Matter")
(new-title old-title))
(while (and (< hl-index hl-count) (< hl-page current-page))
(setq old-title new-title)
(setq hl-page (alist-get 'page (nth hl-index outline)))
(setq new-title (alist-get 'title (nth hl-index outline)))
(cl-incf hl-index))
(if (< current-page hl-page) old-title new-title))))
(add-to-list 'which-func-functions 'which--pdf-function)
#+end_src
* [[info:emacs#Saving Emacs Sessions][Saving Emacs sessions (info)]]
:PROPERTIES:
:CUSTOM_ID: sec:desktop