summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-12-08 11:49:10 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-12-08 11:49:10 +0100
commite9108043e1f9801ef1ee4d86186352b4671ddffa (patch)
tree3167962277ff0b4223a2fcd30d963d1df4268445
parent4c23d83eed3a8e6e4754880c028b2c162b8fc0a7 (diff)
downloadorg-mode-e9108043e1f9801ef1ee4d86186352b4671ddffa.tar.gz
org-capture: Fix %i with prefix containing "\\"
* lisp/org-capture.el (org-capture-fill-template): Fix %i with prefix containing "\\". * testing/lisp/test-org-capture.el (test-org-capture/fill-template): Add test.
-rw-r--r--lisp/org-capture.el8
-rw-r--r--testing/lisp/test-org-capture.el7
2 files changed, 9 insertions, 6 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 2d72c39..0446594 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1670,11 +1670,9 @@ The template may still contain \"%?\" for cursor positioning."
;; Outside embedded Lisp, repeat leading
;; characters before initial place holder
;; every line.
- (let ((lead (buffer-substring-no-properties
- (line-beginning-position) (point))))
- (replace-regexp-in-string "\n\\(.\\)"
- (concat lead "\\1")
- v-i nil nil 1))))
+ (let ((lead (concat "\n"
+ (org-current-line-string t))))
+ (replace-regexp-in-string "\n" lead v-i nil t))))
(?a v-a)
(?A v-A)
(?c v-c)
diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el
index fd4f21a..978f843 100644
--- a/testing/lisp/test-org-capture.el
+++ b/testing/lisp/test-org-capture.el
@@ -74,11 +74,16 @@
(org-capture-fill-template
"%i" "%(concat \"no \" \"evaluation\")"))))
;; When %i contents span over multiple line, repeat initial leading
- ;; characters over each line.
+ ;; characters over each line. Also try possibly problematic
+ ;; prefixes such as "\\".
(should
(equal "> line 1\n> line 2\n"
(let ((org-store-link-plist nil))
(org-capture-fill-template "> %i" "line 1\nline 2"))))
+ (should
+ (equal "\\ line 1\n\\ line 2\n"
+ (let ((org-store-link-plist nil))
+ (org-capture-fill-template "\\ %i" "line 1\nline 2"))))
;; Test %-escaping with \ character.
(should
(equal "%i\n"