Reorganize the advice toggle functions
This commit is contained in:
parent
87ac53dcb3
commit
b57898eb40
144
README.org
144
README.org
@ -600,15 +600,15 @@ and [[lst:3rd-window-management]] implement a selection of his recommendations.
|
||||
(side . left)
|
||||
(window-width . 70))))
|
||||
#+end_src
|
||||
president
|
||||
* [[info:elisp#Advising Functions][Advising Functions (info)]]
|
||||
|
||||
* [[info:elisp#Advising Functions][Advising functions (info)]]
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: sec:advising-function
|
||||
:END:
|
||||
|
||||
#+caption[Tools for advising functions]:
|
||||
#+caption: Tools for advising functions.
|
||||
#+name: lst:advising-tools
|
||||
#+caption[Toggle any advice]:
|
||||
#+caption: Toggle any advice.
|
||||
#+name: lst:toggle-any-advice
|
||||
#+begin_src emacs-lisp
|
||||
(with-eval-after-load 'emacs
|
||||
(defun advice-toggle (symbol where function &optional props)
|
||||
@ -622,6 +622,52 @@ president
|
||||
(advice-add symbol where function props)))))
|
||||
#+end_src
|
||||
|
||||
#+caption[Toggle specific advice]:
|
||||
#+caption: Toggle specific advice.
|
||||
#+name: lst:toggle-specific-advice
|
||||
#+begin_src emacs-lisp
|
||||
(with-eval-after-load 'emacs
|
||||
(defun toggle-TeX-brace-count-line-override ()
|
||||
"Toggle `TeX-brace-count-line-override' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'TeX-brace-count-line
|
||||
:override #'TeX-brace-count-line-override))
|
||||
|
||||
(defun toggle-engrave-faces-latex-face-apply-override ()
|
||||
"Toggle `engrave-faces-latex-face-apply' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'engrave-faces-latex-face-apply
|
||||
:override #'engrave-faces-latex-face-apply-override))
|
||||
|
||||
(defun toggle-engrave-faces-latex-face-mapper-override ()
|
||||
"Toggle `engrave-faces-latex-face-mapper' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'engrave-faces-latex-face-mapper
|
||||
:override #'engrave-faces-latex-face-mapper-override))
|
||||
|
||||
(defun toggle-eww-display-pdf-around ()
|
||||
"Toggle `eww-display-advice' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'eww-display-pdf :around #'eww-display-pdf-as-binary))
|
||||
|
||||
(defun toggle-ilog-timer-function-after ()
|
||||
"Toggle `ilog-timer-function' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'ilog-timer-function :after #'ilog-ensure-ilog-buffer-window))
|
||||
|
||||
(defun toggle-keycast-log-update-buffer-override ()
|
||||
"Toggle `keycast-log-update-buffer' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'keycast-log-update-buffer
|
||||
:override #'keycast-log-update-buffer-plain))
|
||||
|
||||
(defun toggle-org-babel-python-format-session-value-override ()
|
||||
"Toggle `org-babel-python-format-session-value' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'org-babel-python-format-session-value
|
||||
:override #'org-babel-python-format-session-value-override)))
|
||||
#+end_src
|
||||
|
||||
* [[info:emacs#Dired][Dired: directory editor as file manager (info)]]
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: sec:file-manager
|
||||
@ -807,6 +853,8 @@ defined in this Org file.
|
||||
(toggle-engrave-faces-latex-face-apply-override :no-manual t)
|
||||
(toggle-engrave-faces-latex-face-mapper-override :no-manual t)
|
||||
(toggle-eww-display-pdf-around :no-manual t)
|
||||
(toggle-ilog-timer-function-after :no-manual t)
|
||||
(toggle-keycast-log-update-buffer-override :no-manual t)
|
||||
(toggle-org-babel-python-format-session-value-override :no-manual t)
|
||||
"Face"
|
||||
(invert-default-face :no-manual t)
|
||||
@ -815,9 +863,7 @@ defined in this Org file.
|
||||
(enable-this-command :no-manual t)
|
||||
(narrow-or-widen-dwim :no-manual t)
|
||||
(org-narrow-to-table :no-manual t)
|
||||
(toggle-ilog-timer-function-after :no-manual)
|
||||
"LaTeX"
|
||||
(TeX-brace-count-line-override :no-manual t)
|
||||
(biber-delete-cache :no-manual t)
|
||||
(update-lualatex-opentype-font-name-database :no-manual t)
|
||||
"Org"
|
||||
@ -931,15 +977,8 @@ users from shooting themselves in the feet. Listing
|
||||
(not (get-buffer-window ilog-buffer-name)))
|
||||
(display-buffer (get-buffer ilog-buffer-name))))
|
||||
|
||||
(define-key help-map (kbd "C-l") #'interaction-log-mode))
|
||||
|
||||
(with-eval-after-load 'emacs
|
||||
(defun toggle-ilog-timer-function-after ()
|
||||
"Toggle `ilog-timer-function' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'ilog-timer-function :after #'ilog-ensure-ilog-buffer-window))
|
||||
|
||||
(toggle-ilog-timer-function-after))
|
||||
(define-key help-map (kbd "C-l") #'interaction-log-mode)
|
||||
(advice-add 'ilog-timer-function :after #'ilog-ensure-ilog-buffer-window))
|
||||
#+end_src
|
||||
|
||||
|
||||
@ -986,13 +1025,8 @@ Listing [[lst:configure-keycast]] configures =keycast=.
|
||||
(insert output))
|
||||
(goto-char (if keycast-log-newest-first (point-min) (point-max)))))))
|
||||
|
||||
(defun toggle-keycast-log-update-buffer-override ()
|
||||
"Toggle `keycast-log-update-buffer' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'keycast-log-update-buffer
|
||||
:override #'keycast-log-update-buffer-plain))
|
||||
|
||||
(toggle-keycast-log-update-buffer-override))
|
||||
(advice-add 'keycast-log-update-buffer
|
||||
:override #'keycast-log-update-buffer-plain))
|
||||
#+end_src
|
||||
|
||||
* [[info:emacs#Emacs Server][Using Emacs as a server (info)]]
|
||||
@ -1800,12 +1834,7 @@ in listing [[lst:configure-auctex]] corrects this by advising to override
|
||||
(forward-char) t))))))
|
||||
count)))
|
||||
|
||||
(defun toggle-TeX-brace-count-line-override ()
|
||||
"Toggle `TeX-brace-count-line-override' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'TeX-brace-count-line :override #'TeX-brace-count-line-override))
|
||||
|
||||
(toggle-TeX-brace-count-line-override))
|
||||
(advice-add 'TeX-brace-count-line :override #'TeX-brace-count-line-override))
|
||||
#+end_src
|
||||
|
||||
Listing [[lst:configure-bibtex]] configures the Emacs =bibtex= library to use the
|
||||
@ -2041,16 +2070,10 @@ backward compatibility. See table [[tab:org-latex-class-tag-placeholder]] and ty
|
||||
__org_babel_python_final = None"
|
||||
(org-babel-process-file-name src-file 'noquote)
|
||||
(org-babel-process-file-name result-file 'noquote)
|
||||
(if (member "pp" result-params) "True" "False"))))
|
||||
(if (member "pp" result-params) "True" "False")))
|
||||
|
||||
(with-eval-after-load 'emacs
|
||||
(defun toggle-org-babel-python-format-session-value-override ()
|
||||
"Toggle `org-babel-python-format-session-value' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'org-babel-python-format-session-value
|
||||
:override #'org-babel-python-format-session-value-override))
|
||||
|
||||
(toggle-org-babel-python-format-session-value-override))
|
||||
(advice-add 'org-babel-python-format-session-value
|
||||
:override #'org-babel-python-format-session-value-override))
|
||||
#+end_src
|
||||
|
||||
#+caption[Customize =Org=]:
|
||||
@ -2543,26 +2566,10 @@ listings below make* [[https://github.com/tecosaur/engrave-faces#readme][Engrave
|
||||
(engrave-faces-latex--color fg) "}{"))
|
||||
(when st "\\sout{") (when bl "\\textbf{") (when it "\\textit{")
|
||||
content
|
||||
(when bg "}") (when fg "}") (when st "}") (when bl "}") (when it "}"))))))
|
||||
(when bg "}") (when fg "}") (when st "}") (when bl "}") (when it "}")))))
|
||||
|
||||
(with-eval-after-load 'emacs
|
||||
(defun advice-toggle (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-engrave-faces-latex-face-apply-override ()
|
||||
"Toggle `engrave-faces-latex-face-apply' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'engrave-faces-latex-face-apply
|
||||
:override #'engrave-faces-latex-face-apply-override))
|
||||
|
||||
(toggle-engrave-faces-latex-face-apply-override))
|
||||
(advice-add 'engrave-faces-latex-face-apply
|
||||
:override #'engrave-faces-latex-face-apply-override))
|
||||
#+end_src
|
||||
|
||||
#+caption[Fix engraving of horizontal/vertical spacing in multiline docstrings]:
|
||||
@ -2597,16 +2604,10 @@ listings below make* [[https://github.com/tecosaur/engrave-faces#readme][Engrave
|
||||
(push (engrave-faces-latex-face-apply faces pc) stack)))
|
||||
(when-let ((pc (match-string 2 protected-content)))
|
||||
(push pc stack)))
|
||||
(apply #'concat (nreverse stack))))))
|
||||
(apply #'concat (nreverse stack)))))
|
||||
|
||||
(with-eval-after-load 'emacs
|
||||
(defun toggle-engrave-faces-latex-face-mapper-override ()
|
||||
"Toggle `engrave-faces-latex-face-mapper' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'engrave-faces-latex-face-mapper
|
||||
:override #'engrave-faces-latex-face-mapper-override))
|
||||
|
||||
(toggle-engrave-faces-latex-face-mapper-override))
|
||||
(advice-add 'engrave-faces-latex-face-mapper
|
||||
:override #'engrave-faces-latex-face-mapper-override))
|
||||
#+end_src
|
||||
|
||||
#+caption[Emacs setup to use =engrave-faces-latex= in =org-mode= smartly]:
|
||||
@ -4995,15 +4996,8 @@ Listing [[lst:configure-browse-url]] configures =browse-url=.
|
||||
(name (or (and (eq "" title) (plist-get eww-data :url)) title)))
|
||||
(rename-buffer (format "*%s # eww*" name) t)))
|
||||
|
||||
(add-hook 'eww-after-render-hook #'eww-rename-buffer))
|
||||
|
||||
(with-eval-after-load 'emacs
|
||||
(defun toggle-eww-display-pdf-around ()
|
||||
"Toggle `eww-display-advice' advice."
|
||||
(interactive)
|
||||
(advice-toggle 'eww-display-pdf :around #'eww-display-pdf-as-binary))
|
||||
|
||||
(toggle-eww-display-pdf-around))
|
||||
(add-hook 'eww-after-render-hook #'eww-rename-buffer)
|
||||
(advice-add 'eww-display-pdf :around #'eww-display-pdf-as-binary))
|
||||
#+end_src
|
||||
|
||||
*** [[https://en.wikipedia.org/wiki/Media_type#Mailcap][Mailcap]]
|
||||
|
Loading…
Reference in New Issue
Block a user