summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-03-27 13:34:04 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-03-27 13:34:04 +0200
commit4dde26f0863ca57fd3fdfb8dc57c631cb22e6cc1 (patch)
treee3a550e9ad4ab9830a47e81a0fad26c890ae62b5
parent18d9b2181bb95f84d3dbc2ad92ca67a4f3e15c66 (diff)
downloadorg-mode-4dde26f0863ca57fd3fdfb8dc57c631cb22e6cc1.tar.gz
Fix lsearch strings with newline characters
* lisp/org.el (org-link-search): Fix regexp. * testing/lisp/test-org.el (test-org/fuzzy-links): Add test. Reported-by: Matt Lundin <mdl@imapmail.org> <http://permalink.gmane.org/gmane.emacs.orgmode/112876>
-rw-r--r--lisp/org.el3
-rw-r--r--testing/lisp/test-org.el12
2 files changed, 13 insertions, 2 deletions
diff --git a/lisp/org.el b/lisp/org.el
index ce41e61..dc36682 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11172,7 +11172,8 @@ of matched result, which is either `dedicated' or `fuzzy'."
(normalized (replace-regexp-in-string "\n[ \t]*" " " s))
(starred (eq (string-to-char normalized) ?*))
(words (split-string (if starred (substring s 1) s)))
- (s-multi-re (mapconcat #'regexp-quote words "[ \t]+\\(?:\n[ \t]*\\)?"))
+ (s-multi-re
+ (mapconcat #'regexp-quote words "\\([ \t]*\n[ \t]*\\|[ \t]+\\)"))
(s-single-re (mapconcat #'regexp-quote words "[ \t]+"))
type)
(cond
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index b7b16b9..3f4d5cf 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -2217,7 +2217,17 @@ Foo Bar
(should
(org-test-with-temp-text "* [1]\n[[*%5B1%5D<point>]]"
(org-open-at-point)
- (bobp))))
+ (bobp)))
+ ;; Match search strings containing newline characters.
+ (should
+ (org-test-with-temp-text-in-file "Paragraph\n\nline1\nline2\n\n"
+ (let ((file (buffer-file-name)))
+ (goto-char (point-max))
+ (insert (format "[[file:%s::line1 line2]]" file))
+ (beginning-of-line)
+ (let ((org-link-search-must-match-exact-headline nil))
+ (org-open-at-point))
+ (looking-at-p "line1")))))
;;;; Link Escaping