Get rid of unexported Tempo section
This commit is contained in:
parent
3b31228747
commit
94f013df98
145
README.org
145
README.org
@ -6659,151 +6659,6 @@ formatter for Python]].
|
|||||||
(add-hook symbol #'yas-minor-mode)))
|
(add-hook symbol #'yas-minor-mode)))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** [[info:autotype#Tempo][Tempo (info)]] :noexport:
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: sec:tempo
|
|
||||||
:header-args:emacs-lisp: :tangle no :eval never-export
|
|
||||||
:END:
|
|
||||||
|
|
||||||
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]].
|
|
||||||
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.
|
|
||||||
#+name: lst:configure-tempo-ui
|
|
||||||
#+begin_src emacs-lisp -n :results silent
|
|
||||||
(when (require 'tempo nil 'noerror)
|
|
||||||
(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."
|
|
||||||
(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'."
|
|
||||||
(tempo-expand-if-complete))
|
|
||||||
|
|
||||||
(put 'abbrev-tempo-expand-if-complete 'no-self-insert t)
|
|
||||||
|
|
||||||
(defun add-tempo-tags-to-abbrev-table (tempo-tags abbrev-table)
|
|
||||||
"Add the tags in TEMPO-TAGS to ABBREV-TABLE.
|
|
||||||
Allows `tempo' expansion by typing <SPC> after a complete `tempo' tag."
|
|
||||||
(dolist (tag tempo-tags)
|
|
||||||
(unless (abbrev-symbol (car tag) abbrev-table)
|
|
||||||
(define-abbrev abbrev-table
|
|
||||||
(car tag) 1 'abbrev-tempo-expand-if-complete)))))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Tempo for =LaTeX-mode= of =AUCTeX=
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: sec:tempo-latex
|
|
||||||
:END:
|
|
||||||
|
|
||||||
#+caption[Configure =tempo= for =latex= with =completing-read=]:
|
|
||||||
#+caption: Configure =tempo= for =latex= with =completing-read=.
|
|
||||||
#+name: lst:configure-tempo-latex-completing-read
|
|
||||||
#+begin_src emacs-lisp -n :results silent
|
|
||||||
(with-eval-after-load 'latex
|
|
||||||
(require 'tempo nil 'noerror)
|
|
||||||
|
|
||||||
(defun tempo-latex-environment-handler (element)
|
|
||||||
(when (eq element 'latex-environment)
|
|
||||||
(let ((environment (completing-read "LaTeX environment: "
|
|
||||||
(LaTeX-environment-list)
|
|
||||||
#'always 'require-match)))
|
|
||||||
`(l "\\begin{" ,environment "}" > n > r n "\\end{" ,environment "}" >))))
|
|
||||||
|
|
||||||
(cl-pushnew 'tempo-latex-environment-handler tempo-user-elements)
|
|
||||||
|
|
||||||
(defun setup-tempo-latex ()
|
|
||||||
(defvar latex-tempo-tags nil)
|
|
||||||
|
|
||||||
(tempo-define-template
|
|
||||||
"LaTeX-environment"
|
|
||||||
'('latex-environment)
|
|
||||||
"env"
|
|
||||||
"Insert a LaTeX environment"
|
|
||||||
'latex-tempo-tags)
|
|
||||||
|
|
||||||
(tempo-use-tag-list 'latex-tempo-tags)
|
|
||||||
(add-tempo-tags-to-abbrev-table latex-tempo-tags latex-mode-abbrev-table)
|
|
||||||
(setup-local-tempo-key-bindings))
|
|
||||||
|
|
||||||
(add-hook 'LaTeX-mode-hook 'setup-tempo-latex))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Tempo for =python-mode=
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: sec:tempo-python
|
|
||||||
:END:
|
|
||||||
|
|
||||||
#+caption[Configure =tempo= for =python-mode=]:
|
|
||||||
#+caption: Configure =tempo= for =python-mode=.
|
|
||||||
#+name: lst:setup-python-tempo
|
|
||||||
#+begin_src emacs-lisp -n :results silent
|
|
||||||
(with-eval-after-load 'python
|
|
||||||
(require 'tempo nil 'noerror)
|
|
||||||
|
|
||||||
(defun setup-tempo-python ()
|
|
||||||
(defvar python-tempo-tags nil)
|
|
||||||
(tempo-define-template
|
|
||||||
"python-base-class"
|
|
||||||
'("class " p ":" n >)
|
|
||||||
"clsb" "Define a base class" 'python-tempo-tags)
|
|
||||||
(tempo-define-template
|
|
||||||
"python-derived-class"
|
|
||||||
'("class " p "(" p "):" n >)
|
|
||||||
"clsd" "Define a derived class" 'python-tempo-tags)
|
|
||||||
(tempo-define-template
|
|
||||||
"python-class-method"
|
|
||||||
'("@classmethod" > n > "def " p "(cls, " p "):" n >)
|
|
||||||
"defc" "Define a class method" 'python-tempo-tags)
|
|
||||||
(tempo-define-template
|
|
||||||
"python-function"
|
|
||||||
'("def " p "(" p "):" n >)
|
|
||||||
"deff" "Define a function" 'python-tempo-tags)
|
|
||||||
(tempo-define-template
|
|
||||||
"python-normal-method"
|
|
||||||
'("def " p "(self, " p "):" n >)
|
|
||||||
"defm" "Define a normal method" 'python-tempo-tags)
|
|
||||||
(tempo-define-template
|
|
||||||
"python-static-method"
|
|
||||||
'("@staticmethod" > n > "def " p "(" p "):" n >)
|
|
||||||
"defs" "Define a static method" 'python-tempo-tags)
|
|
||||||
|
|
||||||
(tempo-use-tag-list 'python-tempo-tags)
|
|
||||||
(add-tempo-tags-to-abbrev-table python-tempo-tags python-mode-abbrev-table)
|
|
||||||
(setup-local-tempo-key-bindings))
|
|
||||||
|
|
||||||
(add-hook 'python-mode-hook 'setup-tempo-python))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* [[info:emacs#Display][Display (info)]]
|
* [[info:emacs#Display][Display (info)]]
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: sec:display
|
:CUSTOM_ID: sec:display
|
||||||
|
Loading…
Reference in New Issue
Block a user