Implement `insert-tempo-template' and improve text
This commit is contained in:
parent
2914212cc4
commit
8666b82b75
39
README.org
39
README.org
@ -4969,14 +4969,17 @@ code formatter for Python]].
|
||||
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
|
||||
adaptation to =lexical-binding=:
|
||||
1. [[https://www.emacswiki.org/emacs/TempoMode][Tempo (Emacs Wiki)]]
|
||||
2. [[https://www.lysator.liu.se/~davidk/elisp/][David Kågedal’s 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]]
|
||||
Listing [[lst:configure-tempo-ui]] provide a function to define local keybindings
|
||||
and the tools to add =tempo-tags= to abbreviation tables. Listing
|
||||
[[lst:configure-tempo-latex-completing-read]] shows how to combine =tempo=, =latex=
|
||||
and =completing-read= for the builtin =tempo= package that is part of Emacs-28.1
|
||||
and later. Listing [[lst:setup-python-tempo]] configures =tempo= for =python-mode=.
|
||||
1. [[https://www.emacswiki.org/emacs/TempoMode][Tempo (Emacs Wiki)]].
|
||||
2. [[https://www.lysator.liu.se/~davidk/elisp/][David Kågedal’s 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]].
|
||||
4. [[https://www.n16f.net/blog/templating-in-emacs-with-tempo/][Templating in Emacs with Tempo]].
|
||||
Listing [[lst:configure-tempo-ui]] defines a function that inserts major modes
|
||||
specific tempo templates by means of [[https://github.com/minad/marginalia][marginalia]], a function to define local
|
||||
keybindings and the tools to add =tempo-tags= to abbreviation tables.
|
||||
|
||||
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.
|
||||
@ -4985,10 +4988,23 @@ and later. Listing [[lst:setup-python-tempo]] configures =tempo= for =python-mo
|
||||
(with-eval-after-load 'tempo
|
||||
(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 ()
|
||||
"Initialize local `tempo' key bindings."
|
||||
(local-set-key (kbd "M-n") #'tempo-forward-mark)
|
||||
(local-set-key (kbd "M-p") #'tempo-backward-mark))
|
||||
(keymap-local-set "M-n" #'tempo-forward-mark)
|
||||
(keymap-local-set "M-p" #'tempo-backward-mark)
|
||||
(keymap-local-set "M-+" #'insert-tempo-template))
|
||||
|
||||
(defun abbrev-tempo-expand-if-complete ()
|
||||
"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)
|
||||
(define-abbrev abbrev-table
|
||||
(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
|
||||
|
||||
#+caption[Configure =tempo= for =latex= with =completing-read=]:
|
||||
|
Loading…
Reference in New Issue
Block a user