Parcourir la source

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>
Nicolas Goaziou il y a 8 ans
Parent
commit
4dde26f086
2 fichiers modifiés avec 13 ajouts et 2 suppressions
  1. 2 1
      lisp/org.el
  2. 11 1
      testing/lisp/test-org.el

+ 2 - 1
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

+ 11 - 1
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