From da54fa98ce5d5c433d002804eaca1a8e44184773 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 14 Nov 2020 12:57:29 -0500 Subject: [PATCH] Fix #4271: prevent file-templates in org-capture --- modules/editor/file-templates/config.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/editor/file-templates/config.el b/modules/editor/file-templates/config.el index 80af00441..f9ac6886e 100644 --- a/modules/editor/file-templates/config.el +++ b/modules/editor/file-templates/config.el @@ -8,6 +8,9 @@ "The default yasnippet trigger key (a string) for file template rules that don't have a :trigger property in `+file-templates-alist'.") +(defvar +file-templates-inhibit nil + "If non-nil, inhibit file template expansion.") + (defvar +file-templates-alist '(;; General (gitignore-mode) @@ -133,7 +136,8 @@ information.") "Check if the current buffer is a candidate for file template expansion. It must be non-read-only, empty, and there must be a rule in `+file-templates-alist' that applies to it." - (and buffer-file-name + (and (not +file-templates-inhibit) + buffer-file-name (not buffer-read-only) (bobp) (eobp) (not (member (substring (buffer-name) 0 1) '("*" " "))) @@ -142,6 +146,11 @@ must be non-read-only, empty, and there must be a rule in (when-let (rule (cl-find-if #'+file-template-p +file-templates-alist)) (apply #'+file-templates--expand rule)))) +(defadvice! +file-templates-inhibit-in-org-capture-a (orig-fn &rest args) + :around #'org-capture + (let ((+file-templates-inhibit t)) + (apply orig-fn args))) + ;; ;;; Bootstrap