Delay hooking to ensure hooking

This commit is contained in:
Gerard Vermeulen 2024-01-26 19:22:09 +01:00
parent 78b99060c4
commit f1e8335a21

View File

@ -4669,9 +4669,9 @@ the [[https://github.com/gromnitsky/wordnut#readme][wordnut]] prerequisites.
[[https://github.com/bnbeckwith/writegood-mode#readme][Writegood mode]] is a minor mode to aid in finding common writing problems. The
post [[http://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/][Matt Might's "My Ph.D. advisor rewrote himself in bash" scripts]] inspired
this mode. Listing [[lst:configure-writegood-mode]] configures [[https://github.com/bnbeckwith/writegood-mode#readme][writegood mode]] and
enables =writegood-mode= for =text-mode= buffers. The best way to apply it to
this buffer is by typing {{{kbd(C-c C-e t U)}}} to export the it to a
=text-mode= buffer.
enables =writegood-mode= for =text-mode= buffers. Therefore, the best way use
it for this buffer is by typing {{{kbd(C-c C-e t U)}}} to export the it to a
=text-mode= buffer where the =writegood-mode= faces are more visible.
#+caption[Configure =writegood-mode=]:
#+caption: Configure =writegood-mode=.
@ -4679,8 +4679,21 @@ this buffer is by typing {{{kbd(C-c C-e t U)}}} to export the it to a
#+begin_src emacs-lisp -n :results silent
(when (and (ensure-package-installation 'writegood-mode)
(fboundp 'writegood-mode))
(global-set-key (kbd "C-c g") #'writegood-mode)
(add-hook 'after-change-major-mode-hook #'writegood-mode))
(defcustom writegood-mode-for '(org-mode text-mode)
"List of modes for which to enable `writegood-mode'."
:group 'writegood
:type '(repeat symbol))
(add-hook 'after-init-hook
(defun on-after-change-mode-hook-enable-writegood-mode ()
(add-hook 'after-change-major-mode-hook
(defun enable-writegood-mode ()
(when (derived-mode-p writegood-mode-for)
(writegood-mode +1)))))
'depth)
(global-set-key (kbd "C-c g") #'writegood-mode))
#+end_src
* Programming Tools