forked from mirrors/org-mode
Capture: Change order of escape processing
* lisp/org-capture.el (org-capture-fill-template): Do inserting file contents and expanding sexp escapes first, so that further escape processing can happen in the inserted text. This was a request by Sebastian Rose.
This commit is contained in:
parent
c3cfb22fcc
commit
aaea4a8dbf
|
@ -1109,19 +1109,6 @@ The template may still contain \"%?\" for cursor positioning."
|
|||
(goto-char (point-min))
|
||||
(org-capture-steal-local-variables buffer)
|
||||
(setq buffer-file-name nil)
|
||||
;; Simple %-escapes
|
||||
(while (re-search-forward "%\\([tTuUaiAcxkKI]\\)" nil t)
|
||||
(unless (org-capture-escaped-%)
|
||||
(when (and initial (equal (match-string 0) "%i"))
|
||||
(save-match-data
|
||||
(let* ((lead (buffer-substring
|
||||
(point-at-bol) (match-beginning 0))))
|
||||
(setq v-i (mapconcat 'identity
|
||||
(org-split-string initial "\n")
|
||||
(concat "\n" lead))))))
|
||||
(replace-match
|
||||
(or (eval (intern (concat "v-" (match-string 1)))) "")
|
||||
t t)))
|
||||
|
||||
;; %[] Insert contents of a file.
|
||||
(goto-char (point-min))
|
||||
|
@ -1150,6 +1137,20 @@ The template may still contain \"%?\" for cursor positioning."
|
|||
(delete-region template-start (point))
|
||||
(insert result)))))
|
||||
|
||||
;; Simple %-escapes
|
||||
(while (re-search-forward "%\\([tTuUaiAcxkKI]\\)" nil t)
|
||||
(unless (org-capture-escaped-%)
|
||||
(when (and initial (equal (match-string 0) "%i"))
|
||||
(save-match-data
|
||||
(let* ((lead (buffer-substring
|
||||
(point-at-bol) (match-beginning 0))))
|
||||
(setq v-i (mapconcat 'identity
|
||||
(org-split-string initial "\n")
|
||||
(concat "\n" lead))))))
|
||||
(replace-match
|
||||
(or (eval (intern (concat "v-" (match-string 1)))) "")
|
||||
t t)))
|
||||
|
||||
;; From the property list
|
||||
(when plist-p
|
||||
(goto-char (point-min))
|
||||
|
|
Loading…
Reference in New Issue