Fix #4271: prevent file-templates in org-capture
This commit is contained in:
parent
3265c25821
commit
da54fa98ce
1 changed files with 10 additions and 1 deletions
|
@ -8,6 +8,9 @@
|
||||||
"The default yasnippet trigger key (a string) for file template rules that
|
"The default yasnippet trigger key (a string) for file template rules that
|
||||||
don't have a :trigger property in `+file-templates-alist'.")
|
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
|
(defvar +file-templates-alist
|
||||||
'(;; General
|
'(;; General
|
||||||
(gitignore-mode)
|
(gitignore-mode)
|
||||||
|
@ -133,7 +136,8 @@ information.")
|
||||||
"Check if the current buffer is a candidate for file template expansion. It
|
"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
|
must be non-read-only, empty, and there must be a rule in
|
||||||
`+file-templates-alist' that applies to it."
|
`+file-templates-alist' that applies to it."
|
||||||
(and buffer-file-name
|
(and (not +file-templates-inhibit)
|
||||||
|
buffer-file-name
|
||||||
(not buffer-read-only)
|
(not buffer-read-only)
|
||||||
(bobp) (eobp)
|
(bobp) (eobp)
|
||||||
(not (member (substring (buffer-name) 0 1) '("*" " ")))
|
(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))
|
(when-let (rule (cl-find-if #'+file-template-p +file-templates-alist))
|
||||||
(apply #'+file-templates--expand rule))))
|
(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
|
;;; Bootstrap
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue