💥 Refactor add-hook! macro & change arg order
This update may potentially break your usage of add-hook! if you pass the :local or :append properties to it. This is how they used to work: (add-hook! :append 'some-mode-hook #'do-something) Thsoe properties must now follow the hooks, e.g. (add-hook! 'some-mode-hook :append #'do-something) Other changes: - Various add-hook calls have been renamed to add-hook! because I incorrectly assumed `defun` always returned its definition's symbol, when in fact, its return value is "undefined" (so sayeth the documentation). This should fix #1597. - This update adds the ability to add multiple functions to hooks without a list: (add-hook! 'some-mode-hook #'do-something #'do-something-else) - The indentation logic has been changed so that consecutive function symbols at indented at the same level as the first argument, but forms are indent like a defun. (add-hook! 'some-mode-hook #'do-something #'do-something-else) (add-hook! 'some-mode-hook (message "Hello"))
This commit is contained in:
parent
c2ae6f30a5
commit
a3e262c7ac
42 changed files with 248 additions and 225 deletions
|
@ -97,7 +97,7 @@ playback.")
|
|||
:after #'circe--irc-conn-disconnected
|
||||
(run-hooks '+irc-disconnect-hook))
|
||||
|
||||
(add-hook 'lui-pre-output-hook
|
||||
(add-hook! 'lui-pre-output-hook
|
||||
(defun +irc-circe-truncate-nicks-h ()
|
||||
"Truncate long nicknames in chat output non-destructively."
|
||||
(when-let (beg (text-property-any (point-min) (point-max) 'lui-format-argument 'nick))
|
||||
|
@ -109,7 +109,7 @@ playback.")
|
|||
(compose-region (+ beg +irc-left-padding -1) end
|
||||
+irc-truncate-nick-char))))))
|
||||
|
||||
(add-hook 'doom-real-buffer-functions
|
||||
(add-hook! 'doom-real-buffer-functions
|
||||
(defun +circe-buffer-p (buf)
|
||||
"Return non-nil if BUF is a `circe-mode' buffer."
|
||||
(with-current-buffer buf
|
||||
|
@ -117,13 +117,13 @@ playback.")
|
|||
(eq (safe-persp-name (get-current-persp))
|
||||
+irc--workspace-name)))))
|
||||
|
||||
(add-hook 'circe-message-option-functions
|
||||
(add-hook! 'circe-message-option-functions
|
||||
(defun +irc-circe-message-option-bot-h (nick &rest ignored)
|
||||
"Fontify known bots and mark them to not be tracked."
|
||||
(when (member nick +irc-bot-list)
|
||||
'((text-properties . (face circe-fool-face lui-do-not-track t))))))
|
||||
|
||||
(add-hook 'circe-mode-hook
|
||||
(add-hook! 'circe-mode-hook
|
||||
(defun +irc-add-circe-buffer-to-persp-h ()
|
||||
(let ((persp (get-current-persp))
|
||||
(buf (current-buffer)))
|
||||
|
@ -202,7 +202,8 @@ after prompt marker."
|
|||
(goto-char (point-max))))
|
||||
|
||||
(add-hook! 'lui-mode-hook
|
||||
(add-hook 'evil-insert-state-entry-hook #'+irc-evil-insert-h nil t))
|
||||
(add-hook 'evil-insert-state-entry-hook #'+irc-evil-insert-h
|
||||
nil 'local))
|
||||
|
||||
(mapc (lambda (cmd) (push cmd +irc-scroll-to-bottom-on-commands))
|
||||
'(evil-paste-after evil-paste-before evil-open-above evil-open-below)))
|
||||
|
|
|
@ -36,14 +36,14 @@ easier to scroll through.")
|
|||
(make-directory elfeed-db-directory t)
|
||||
|
||||
;; Ensure elfeed buffers are treated as real
|
||||
(add-hook 'doom-real-buffer-functions
|
||||
(add-hook! 'doom-real-buffer-functions
|
||||
(defun +rss-buffer-p (buf)
|
||||
(string-match-p "^\\*elfeed" (buffer-name buf))))
|
||||
|
||||
;; Enhance readability of a post
|
||||
(add-hook 'elfeed-show-mode-hook #'+rss-elfeed-wrap-h)
|
||||
(add-hook! 'elfeed-search-mode-hook
|
||||
(add-hook 'kill-buffer-hook #'+rss-cleanup-h nil t))
|
||||
(add-hook 'kill-buffer-hook #'+rss-cleanup-h nil 'local))
|
||||
|
||||
;; Large images are annoying to scroll through, because scrolling follows the
|
||||
;; cursor, so we force shr to insert images in slices.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue