Move toggle-advice to its own section

This commit is contained in:
Gerard Vermeulen 2022-05-01 17:35:18 +02:00
parent fa47364def
commit d5f3b42584
1 changed files with 18 additions and 10 deletions

View File

@ -353,6 +353,24 @@ However, in order to improve visibility, it relies on:
"My face to show a here-document."))
#+end_src
** [[info:elisp#Advising Functions][Advising Functions (info)]]
#+caption[Tools for advising functions]:
#+caption: Tools for advising functions.
#+name: lst:advising-tools
#+begin_src emacs-lisp
(with-eval-after-load 'emacs
(defun toggle-advice (symbol where function &optional props)
"Toggle between states after `advice-remove' and `advice-add'."
(let ((how "%s `%s' advice `%s' %s `%s'"))
(if (advice-member-p function symbol)
(progn
(message how "Removal of" where function "from" symbol)
(advice-remove symbol function))
(message how "Addition of" where function "to" symbol)
(advice-add symbol where function props)))))
#+end_src
** [[info:emacs#Dired][Dired: directory editor as file manager (info)]]
:PROPERTIES:
:CUSTOM_ID: sec:file-manager
@ -1336,16 +1354,6 @@ corrects this by advising to override ~TeX-brace-count-line~ with
(forward-char) t))))))
count)))
(defun toggle-advice (symbol where function &optional props)
"Toggle between states after `advice-remove' and `advice-add'."
(let ((how "%s `%s' advice `%s' %s `%s'"))
(if (advice-member-p function symbol)
(progn
(message how "Removal of" where function "from" symbol)
(advice-remove symbol function))
(message how "Addition of" where function "to" symbol)
(advice-add symbol where function props))))
(defun toggle-TeX-brace-count-line-override ()
"Toggle `TeX-brace-count-line-override' advice."
(interactive)