Compare commits

...

2 Commits

1 changed files with 0 additions and 222 deletions

View File

@ -292,7 +292,6 @@ of [[info:emacs#Saving Customizations][saving customizations (info)]].
(f . "melpa-stable")
(forge . "melpa-stable")
(git-commit . "nongnu")
(hyperbole . "gnu-devel")
(keycast . "nongnu")
(magit . "nongnu")
(magit-section . "nongnu")
@ -6660,151 +6659,6 @@ formatter for Python]].
(add-hook symbol #'yas-minor-mode)))
#+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å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]].
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)]]
:PROPERTIES:
:CUSTOM_ID: sec:display
@ -6989,82 +6843,6 @@ Listing [[lst:configure-browse-url]] configures =browse-url=.
(advice-add 'eww-display-pdf :around #'eww-display-pdf-as-binary))
#+end_src
*** [[https://www.gnu.org/software/hyperbole/][GNU Hyperbole]] :noexport:
:PROPERTIES:
:CUSTOM_ID: sec:ensure-hyperbole-installation
:header-args:emacs-lisp: :tangle no :eval never-export
:END:
Listing [[lst:ensure-hyperbole-installation][ensure Hyperbole installation]] works around two [[https://www.gnu.org/software/hyperbole/][GNU Hyperbole]] quirks:
1. The [[https://elpa.gnu.org/elpa/hyperbole.html][GNU ELPA Hyperbole]] and [[https://elpa.gnu.org/devel/hyperbole.html][GNU ELPA Hyperbole developer]] packages ship their
own =hyperbole-autoloads= and =kotl-autoloads= files which are incompatible
with Emacs Lisp packages from "package archives". Consequently, Emacs can
neither autoload nor load the =hyperbole-autoloads= and =kotl-autoloads=
files. Therefore, the predicate loading the =kotl-autoloads= file in the
first =unless= form of listing [[lst:ensure-hyperbole-installation][ensure Hyperbole installation]] will fail and
the body of this form will overwrite the =hyperbole-autoloads= file to fix
=load-path= *and* load the =hyperbole-autoloads= and =kotl-autoloads= files.
A next time, Emacs will be able to autoload the new =hyperbole-autoloads=
file but not the =kotl-autoloads= file. However, Emacs will now be able to
load the =kotl-autoloads= file which the predicate in the first =unless= form
of listing [[lst:ensure-hyperbole-installation][ensure Hyperbole installation]] does.
2. [[https://www.gnu.org/software/hyperbole/][GNU Hyperbole]] and [[info:vertico#Top][Vertico (info)]] do not play well together, since the
=vertico-mode= preselection of the first candidate out of the full candidate
completion list interferes with =hyperbole-mode= expectations where it must
handle a full candidate list. Therefore, the function call
src_emacs-lisp[:results silent]{(either-hyperbole-or-vertico-mode)} handles
this conflict by toggling between =hyperbole-mode= and =vertico-mode=.
#+caption[Ensure Hyperbole installation]:
#+caption: Ensure Hyperbole installation and address two Hyperbole quirks.
#+name: lst:ensure-hyperbole-installation
#+begin_src emacs-lisp -n :results silent
(when (ensure-package-installation 'hyperbole)
(unless (load "kotl-autoloads.el" 'noerror nil nil 'must-suffix)
;; See `package-generate-autoloads' for `loaddefs-generate' usage.
(unless (bound-and-true-p package-archive-contents)
(package-read-all-archive-contents))
(let* ((pkg-desc (cadr (assq 'hyperbole package-archive-contents)))
(pkg-dir (expand-file-name
(package-desc-full-name pkg-desc) package-user-dir))
(hpbl-alf (expand-file-name "hyperbole-autoloads.el" pkg-dir))
(kotl-alf (expand-file-name
(file-name-concat "kotl" "kotl-autoloads.el") pkg-dir))
(extra-data
(concat
(prin1-to-string
'(add-to-list
'load-path
(or (and load-file-name (file-name-directory load-file-name))
(car load-path))))
"\n"
(prin1-to-string
'(add-to-list
'load-path
(expand-file-name
"kotl"
(or (and load-file-name (file-name-directory load-file-name))
(car load-path)))))))
(autoload-timestamps nil)
(version-control 'never))
(loaddefs-generate pkg-dir hpbl-alf nil extra-data nil 'generate-full)
(dolist (alf (list hpbl-alf kotl-alf))
(let ((buf (find-buffer-visiting hpbl-alf)))
(when buf (kill-buffer buf)))
(load alf nil nil nil 'must-suffix))))
(defun either-hyperbole-or-vertico-mode ()
"Toggle between either `hyperbole-mode' or `vertico-mode'."
(interactive)
(when (and (boundp hyperbole-mode) (boundp vertico-mode))
(if hyperbole-mode
(progn
(hyperbole-mode -1)
(vertico-mode +1))
(hyperbole-mode +1)
(vertico-mode -1)))))
#+end_src
*** [[https://en.wikipedia.org/wiki/Media_type#Mailcap][Mailcap]]
:PROPERTIES:
:CUSTOM_ID: sec:mailcap