Compare commits

...

2 Commits

Author SHA1 Message Date
8666b82b75 Implement `insert-tempo-template' and improve text 2023-02-15 06:45:37 +01:00
2914212cc4 Reformat table 2023-02-15 06:44:36 +01:00

View File

@ -1414,47 +1414,47 @@ completion function [[info:elisp#Minibuffer Completion][completing-read]]. List
#+caption[Configuration specific key bindings]: #+caption[Configuration specific key bindings]:
#+caption: Configuration specific key-bindings. #+caption: Configuration specific key-bindings.
#+name: tab:configuration-specific-key-bindings #+name: tab:configuration-specific-key-bindings
|-----------------------------+----------------------+---------------------| |-----------------------------+----------------------+--------------------|
| command | key map | keys | | command | key map | keys |
|-----------------------------+----------------------+---------------------| |-----------------------------+----------------------+--------------------|
| consult-bookmark | ctl-x-r-keymap | {{{kbd(C-x r b)}}} | | consult-bookmark | ctl-x-r-keymap | {{{kbd(C-x r b)}}} |
| consult-buffer-other-frame | ctl-x-5-keymap | {{{kbd(C-x 5 b)}}} | | consult-buffer-other-frame | ctl-x-5-keymap | {{{kbd(C-x 5 b)}}} |
| consult-buffer-other-window | ctl-x-4-keymap | {{{kbd(C-x 4 b)}}} | | consult-buffer-other-window | ctl-x-4-keymap | {{{kbd(C-x 4 b)}}} |
| consult-buffer | ctl-x-keymap | {{{kbd(C-x b)}}} | | consult-buffer | ctl-x-keymap | {{{kbd(C-x b)}}} |
| consult-compile-error | goto-map | {{{kbd(M-g e)}}} | | consult-compile-error | goto-map | {{{kbd(M-g e)}}} |
| consult-complex-command | ctl-x-keymap | {{{kbd(C-x M-:)}}} | | consult-complex-command | ctl-x-keymap | {{{kbd(C-x M-:)}}} |
| consult-find | search-map | {{{kbd(M-s f)}}} | | consult-find | search-map | {{{kbd(M-s f)}}} |
| consult-focus-lines | search-map | {{{kbd(M-s u)}}} | | consult-focus-lines | search-map | {{{kbd(M-s u)}}} |
| consult-git-grep | search-map | {{{kbd(M-s g)}}} | | consult-git-grep | search-map | {{{kbd(M-s g)}}} |
| consult-global-mark | goto-map | {{{kbd(M-g k)}}} | | consult-global-mark | goto-map | {{{kbd(M-g k)}}} |
| consult-goto-line | goto-map | {{{kbd(M-g M-g)}}} | | consult-goto-line | goto-map | {{{kbd(M-g M-g)}}} |
| consult-goto-line | goto-map | {{{kbd(M-g g)}}} | | consult-goto-line | goto-map | {{{kbd(M-g g)}}} |
| consult-history | global-map | {{{kbd(C-c h)}}} | | consult-history | global-map | {{{kbd(C-c h)}}} |
| consult-imenu | goto-map | {{{kbd(M-g i)}}} | | consult-imenu | goto-map | {{{kbd(M-g i)}}} |
| consult-keep-lines | search-map | {{{kbd(M-s k)}}} | | consult-keep-lines | search-map | {{{kbd(M-s k)}}} |
| consult-line | search-map | {{{kbd(M-s l)}}} | | consult-line | search-map | {{{kbd(M-s l)}}} |
| consult-mark | goto-map | {{{kbd(M-g m)}}} | | consult-mark | goto-map | {{{kbd(M-g m)}}} |
| consult-mode-command | global-map | {{{kbd(C-c m)}}} | | consult-mode-command | global-map | {{{kbd(C-c m)}}} |
| consult-multi-occur | search-map | {{{kbd(M-s m)}}} | | consult-multi-occur | search-map | {{{kbd(M-s m)}}} |
| consult-outline | goto-map | {{{kbd(M-g o)}}} | | consult-outline | goto-map | {{{kbd(M-g o)}}} |
| consult-register | ctl-x-r-keymap | {{{kbd(C-x r x)}}} | | consult-register | ctl-x-r-keymap | {{{kbd(C-x r x)}}} |
| consult-yank-pop | global-map | {{{kbd(M-y)}}} | | consult-yank-pop | global-map | {{{kbd(M-y)}}} |
|-----------------------------+----------------------+---------------------| |-----------------------------+----------------------+--------------------|
| deadgrep | search-map | {{{kbd(M-s d)}}} | | deadgrep | search-map | {{{kbd(M-s d)}}} |
| elfeed | global-map | {{{kbd(C-x w)}}} | | elfeed | global-map | {{{kbd(C-x w)}}} |
| embark-act | global-map | {{{kbd(C-\,)}}} | | embark-act | global-map | {{{kbd(C-\,)}}} |
| embark-bindings | global-map | {{{kbd(C-h B)}}} | | embark-bindings | global-map | {{{kbd(C-h B)}}} |
| embark-dwim | global-map | {{{kbd(C-:)}}} | | embark-dwim | global-map | {{{kbd(C-:)}}} |
| iedit-mode | global-map | {{{kbd(C-;)}}} | | iedit-mode | global-map | {{{kbd(C-;)}}} |
| minibuffer-complete-history | minibuffer-local-map | {{{kbd(C-<tab>)}}} | | minibuffer-complete-history | minibuffer-local-map | {{{kbd(C-<tab>)}}} |
| narrow-or-widen-dwim | ctl-x-keymap | {{{kbd(C-x C-n)}}} | | narrow-or-widen-dwim | ctl-x-keymap | {{{kbd(C-x C-n)}}} |
| org-agenda | global-map | {{{kbd(C-c a)}}} | | org-agenda | global-map | {{{kbd(C-c a)}}} |
| org-capture | global-map | {{{kbd(C-c c)}}} | | org-capture | global-map | {{{kbd(C-c c)}}} |
| org-cite | org-mode-map | {{{kbd(C-c b)}}} | | org-cite | org-mode-map | {{{kbd(C-c b)}}} |
| org-insert-link-global | global-map | {{{kbd(C-c C-l)}}} | | org-insert-link-global | global-map | {{{kbd(C-c C-l)}}} |
| org-narrow-to-table | ctl-x-keymap | {{{kbd(C-x n t)}}} | | org-narrow-to-table | ctl-x-keymap | {{{kbd(C-x n t)}}} |
| org-store-link | global-map | {{{kbd(C-c l)}}} | | org-store-link | global-map | {{{kbd(C-c l)}}} |
|-----------------------------+----------------------+---------------------| |-----------------------------+----------------------+--------------------|
#+caption[Bind =consult= commands]: #+caption[Bind =consult= commands]:
@ -4969,14 +4969,17 @@ code formatter for Python]].
The official [[info:autotype#Tempo][tempo (info)]] documentation is very short and the following links The official [[info:autotype#Tempo][tempo (info)]] documentation is very short and the following links
are obsolete or do not reveal the full power of [[info:autotype#Tempo][tempo (info)]] after its are obsolete or do not reveal the full power of [[info:autotype#Tempo][tempo (info)]] after its
adaptation to =lexical-binding=: adaptation to =lexical-binding=:
1. [[https://www.emacswiki.org/emacs/TempoMode][Tempo (Emacs Wiki)]] 1. [[https://www.emacswiki.org/emacs/TempoMode][Tempo (Emacs Wiki)]].
2. [[https://www.lysator.liu.se/~davidk/elisp/][David Kågedals elisp]] 2. [[https://www.lysator.liu.se/~davidk/elisp/][David Kågedals elisp]].
3. [[https://github.com/yilkalargaw/emacs-native-snippets][Emacs's Native Snippets]], [[https://www.reddit.com/r/emacs/comments/wdbk34/emacss_native_templating_and_snippet_fuctionality/][Emacs's native templating and snippet functionality]] 3. [[https://github.com/yilkalargaw/emacs-native-snippets][Emacs's Native Snippets]], [[https://www.reddit.com/r/emacs/comments/wdbk34/emacss_native_templating_and_snippet_fuctionality/][Emacs's native templating and snippet functionality]].
Listing [[lst:configure-tempo-ui]] provide a function to define local keybindings 4. [[https://www.n16f.net/blog/templating-in-emacs-with-tempo/][Templating in Emacs with Tempo]].
and the tools to add =tempo-tags= to abbreviation tables. Listing Listing [[lst:configure-tempo-ui]] defines a function that inserts major modes
[[lst:configure-tempo-latex-completing-read]] shows how to combine =tempo=, =latex= specific tempo templates by means of [[https://github.com/minad/marginalia][marginalia]], a function to define local
and =completing-read= for the builtin =tempo= package that is part of Emacs-28.1 keybindings and the tools to add =tempo-tags= to abbreviation tables.
and later. Listing [[lst:setup-python-tempo]] configures =tempo= for =python-mode=.
Listing [[lst:configure-tempo-latex-completing-read]] shows how to combine =tempo=,
=latex= and =completing-read= for the builtin =tempo= package. Listing
[[lst:setup-python-tempo]] configures =tempo= for =python-mode=.
#+caption[Configure =tempo= user interface]: #+caption[Configure =tempo= user interface]:
#+caption: Configure =tempo= user-interface. #+caption: Configure =tempo= user-interface.
@ -4985,10 +4988,23 @@ and later. Listing [[lst:setup-python-tempo]] configures =tempo= for =python-mo
(with-eval-after-load 'tempo (with-eval-after-load 'tempo
(setopt tempo-interactive t) (setopt tempo-interactive t)
(with-eval-after-load 'marginalia
(add-to-list 'marginalia-prompt-categories
'("\\<tempo template\\>" . command)))
;; https://www.n16f.net/blog/templating-in-emacs-with-tempo/
(defun insert-tempo-template ()
"Insert a major mode specific tempo template."
(interactive)
(let* ((choices (mapcar #'cdr (tempo-build-collection)))
(function-name (completing-read "Tempo template: " choices)))
(funcall (intern function-name))))
(defun setup-local-tempo-key-bindings () (defun setup-local-tempo-key-bindings ()
"Initialize local `tempo' key bindings." "Initialize local `tempo' key bindings."
(local-set-key (kbd "M-n") #'tempo-forward-mark) (keymap-local-set "M-n" #'tempo-forward-mark)
(local-set-key (kbd "M-p") #'tempo-backward-mark)) (keymap-local-set "M-p" #'tempo-backward-mark)
(keymap-local-set "M-+" #'insert-tempo-template))
(defun abbrev-tempo-expand-if-complete () (defun abbrev-tempo-expand-if-complete ()
"Hook function for `define-abbrev' with `no-self-insert' property `t'." "Hook function for `define-abbrev' with `no-self-insert' property `t'."
@ -5003,6 +5019,9 @@ Allows `tempo' expansion by typing <SPC> after a complete `tempo' tag."
(unless (abbrev-symbol (car tag) abbrev-table) (unless (abbrev-symbol (car tag) abbrev-table)
(define-abbrev abbrev-table (define-abbrev abbrev-table
(car tag) 1 'abbrev-tempo-expand-if-complete))))) (car tag) 1 'abbrev-tempo-expand-if-complete)))))
(with-eval-after-load 'org
(add-hook 'org-mode-hook 'setup-local-tempo-key-bindings))
#+end_src #+end_src
#+caption[Configure =tempo= for =latex= with =completing-read=]: #+caption[Configure =tempo= for =latex= with =completing-read=]: