Replace save-after-refile advice with hook

A hook is better than an advice, which could break with an update.

Also, reformat org-mks advice.
This commit is contained in:
Henrik Lissner 2020-05-11 03:08:37 -04:00
parent 129eebcf2a
commit f9a677427e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -319,11 +319,17 @@ I like:
(after! org-capture (after! org-capture
(org-capture-put :kill-buffer t)) (org-capture-put :kill-buffer t))
;; Fix #462: when refiling from org-capture, Emacs prompts to kill the
;; underlying, modified buffer. This fixes that.
(add-hook 'org-after-refile-insert-hook #'save-buffer)
;; HACK Doom doesn't support `customize'. Best not to advertise it as an ;; HACK Doom doesn't support `customize'. Best not to advertise it as an
;; option in `org-capture's menu. ;; option in `org-capture's menu.
(defadvice! +org--remove-customize-option-a (orig-fn table title &optional prompt specials) (defadvice! +org--remove-customize-option-a (orig-fn table title &optional prompt specials)
:around #'org-mks :around #'org-mks
(funcall orig-fn table title prompt (remove '("C" "Customize org-capture-templates") specials))) (funcall orig-fn table title prompt
(remove '("C" "Customize org-capture-templates")
specials)))
(defadvice! +org--capture-expand-variable-file-a (file) (defadvice! +org--capture-expand-variable-file-a (file)
"If a variable is used for a file path in `org-capture-template', it is used "If a variable is used for a file path in `org-capture-template', it is used
@ -334,13 +340,6 @@ relative to `org-directory', unless it is an absolute path."
(expand-file-name (symbol-value file) org-directory) (expand-file-name (symbol-value file) org-directory)
file)) file))
(defadvice! +org--prevent-save-prompts-when-refiling-a (&rest _)
"Fix #462: when refiling from org-capture, Emacs prompts to kill the
underlying, modified buffer. This fixes that."
:after #'org-refile
(when (bound-and-true-p org-capture-is-refiling)
(org-save-all-org-buffers)))
(add-hook! 'org-capture-mode-hook (add-hook! 'org-capture-mode-hook
(defun +org-show-target-in-capture-header-h () (defun +org-show-target-in-capture-header-h ()
(setq header-line-format (setq header-line-format