summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+org.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/lisp/+org.el b/lisp/+org.el index 6075b60..89ed483 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -650,5 +650,39 @@ and POST-PROCESS are passed to `org-export-to-file'."
650 (set-category-table +org-category-table) 650 (set-category-table +org-category-table)
651 (setq-local word-wrap-by-category t)) 651 (setq-local word-wrap-by-category t))
652 652
653
654;;; Inhibit hooks on `org-agenda'
655;; It's really annoying when I call `org-agenda' and five hundred Ispell
656;; processes are created because I have `flyspell-mode' in the hook. This mode
657;; inhibits those hooks when entering the agenda, but runs them when opening the
658;; actual buffer.
659
660(defun +org-agenda-inhibit-hooks (fn &rest r)
661 "Advice to inhibit hooks when entering `org-agenda'."
662 (dlet ((org-mode-hook nil)) ; I'm not sure if `dlet' is strictly needed
663 (apply fn r)))
664
665(defvar-local +org-hook-has-run-p nil
666 "Whether `org-mode-hook' has run in the current buffer.")
667
668(defun +org-agenda-switch-run-hooks (&rest _)
669 "Advice to run `org-mode-hook' when entering org-mode.
670This should only fire when switching to a buffer from `org-agenda'."
671 (unless +org-hook-has-run-p
672 (run-hooks 'org-mode-hook)
673 (setq +org-hook-has-run-p t)))
674
675(define-minor-mode +org-agenda-inhibit-hooks-mode
676 "Inhibit `org-mode-hook' when opening `org-agenda'."
677 :lighter ""
678 :global t
679 (if +org-agenda-inhibit-hooks-mode
680 (progn ; Enable
681 (advice-add 'org-agenda :around #'+org-agenda-inhibit-hooks)
682 (advice-add 'org-agenda-switch-to :after #'+org-agenda-switch-run-hooks))
683 (progn ; Disable
684 (advice-remove 'org-agenda #'+org-agenda-inhibit-hooks)
685 (advice-remove 'org-agenda-switch-to #'+org-agenda-switch-run-hooks))))
686
653(provide '+org) 687(provide '+org)
654;;; +org.el ends here 688;;; +org.el ends here