From 4dde26f0863ca57fd3fdfb8dc57c631cb22e6cc1 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 27 Mar 2017 13:34:04 +0200 Subject: [PATCH] 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 --- lisp/org.el | 3 ++- testing/lisp/test-org.el | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index ce41e6147..dc3668218 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 b7b16b95f..3f4d5cf64 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]]" (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