From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: doc patch: move footnote in external links Date: Sat, 07 Feb 2015 12:23:55 +0100 Message-ID: References: <87egs4bwuu.fsf@nicolasgoaziou.fr> <87388jab2j.fsf@nicolasgoaziou.fr> <87y4q745w7.fsf@nicolasgoaziou.fr> <87vbl6x91a.fsf@nicolasgoaziou.fr> <87twzxdlkf.fsf@nicolasgoaziou.fr> <87lhl8e6db.fsf@nicolasgoaziou.fr> <87egqzehgl.fsf@nicolasgoaziou.fr> <87h9vrt8e9.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YK3Ua-0007sH-OQ for emacs-orgmode@gnu.org; Sat, 07 Feb 2015 06:24:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YK3UW-0002N7-ME for emacs-orgmode@gnu.org; Sat, 07 Feb 2015 06:24:04 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:20527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YK3UW-0002Mr-7q for emacs-orgmode@gnu.org; Sat, 07 Feb 2015 06:24:00 -0500 In-Reply-To: <87h9vrt8e9.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Fri, 16 Jan 2015 09:57:05 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Hello, Here is a new version of the patch, with some tests and a mention in ORG-NEWS. I did not know if I should mention the ORG-NEWS change in the Changelog (I did not). Best, Alan --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Function-org-link-search-does-exact-headline-search.patch Content-Transfer-Encoding: quoted-printable From=20ea6fb4d8134b1708ae195a342b41de268453b470 Mon Sep 17 00:00:00 2001 From: Alan Schmitt Date: Fri, 12 Dec 2014 08:26:05 +0100 Subject: [PATCH] Function `org-link-search' does exact headline search * lisp/org.el (org-link-search): Change headline search such that it always does an exact search, ignoring spaces. * testing/lisp/test-org.el (test-org/fuzzy-links): Test exact headline match with spaces and cookies. * doc/org.texi (External links): Cleanup footnote about the `org-link-search-must-match-exact-headline' option for text searches and add a footnote about the effect of the same option for heading searches. =2D-- doc/org.texi | 12 +++++++---- etc/ORG-NEWS | 5 +++++ lisp/org.el | 54 +++++++++++++++++++++++++++-----------------= ---- testing/lisp/test-org.el | 25 ++++++++++++++++++++++ 4 files changed, 69 insertions(+), 27 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 14eaf1a..3c967be 100644 =2D-- a/doc/org.texi +++ b/doc/org.texi @@ -3561,10 +3561,14 @@ file:projects.org::some words @r{text s= earch in Org file}@footnote{ The actual behavior of the search will depend on the value of the option @code{org-link-search-must-match-exact-headline}. If its value is @code{nil}, then a fuzzy text search will be done. If it is t, then on= ly the =2Dexact headline will be matched. If the value is @code{'query-to-create}, =2Dthen an exact headline will be searched; if it is not found, then the us= er =2Dwill be queried to create it.} =2Dfile:projects.org::*task title @r{heading search in Org file} +exact headline will be matched, ignoring spaces and cookies. If the value= is +@code{query-to-create}, then an exact headline will be searched; if it is = not +found, then the user will be queried to create it.} +file:projects.org::*task title @r{heading search in Org +file}@footnote{ Headline searches always match the exact headline, ignoring +spaces and cookies. If the headline is not found and the value of the opt= ion +@code{org-link-search-must-match-exact-headline} is @code{query-to-create}, +then the user will be queried to create it.} file+sys:/path/to/file @r{open via OS, like double-clic= k} file+emacs:/path/to/file @r{force opening by Emacs} docview:papers/last.pdf::NNN @r{open in doc-view mode at page} diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 2f8d2ab..cce762e 100644 =2D-- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -218,6 +218,11 @@ The build system has been enhanced to allow test selec= tion with a regular expression by defining =3DBTEST_RE=3D during the test invocation. This is especially useful during bisection to find just when a particular test failure was introduced. +*** Exact heading search for external links ignore spaces and cookies +Exact heading search for links now ignore spaces and cookies. This is +the case for links of the form ~file:projects.org::*task title~, as +well as links of the form ~file:projects.org::some words~ +when ~org-link-search-must-match-exact-headline~ is not nil. * Version 8.2 =20 ** Incompatible changes diff --git a/lisp/org.el b/lisp/org.el index a095f8d..271fe1f 100755 =2D-- a/lisp/org.el +++ b/lisp/org.el @@ -11007,8 +11007,7 @@ visibility around point, thus ignoring org-emphasis-alist) "\\|") "\\)")) (pos (point)) =2D (pre nil) (post nil) =2D words re0 re1 re2 re3 re4_ re4 re5 re2a re2a_ reall) + words re0 re2 re4_ re4 re5 re2a re2a_ reall) (cond ;; First check if there are any special search functions ((run-hook-with-args-until-success 'org-execute-file-search-functions= s)) @@ -11062,14 +11061,36 @@ visibility around point, thus ignoring ((derived-mode-p 'org-mode) (org-occur (match-string 1 s))) (t (org-do-occur (match-string 1 s))))) =2D ((and (derived-mode-p 'org-mode) org-link-search-must-match-exact-h= eadline) =2D (and (equal (string-to-char s) ?*) (setq s (substring s 1))) + ((and (derived-mode-p 'org-mode) + (or (and (equal (string-to-char s) ?*) (setq s (substring s 1))) + org-link-search-must-match-exact-headline)) + ;; Headline search (goto-char (point-min)) (cond ((let (case-fold-search) =2D (re-search-forward (format org-complex-heading-regexp-format =2D (regexp-quote s)) =2D nil t)) + (re-search-forward + (let* ((wspace "[ \t]") + (wspaceopt (concat wspace "*")) + (cookie (concat "\\(?:" + wspaceopt + "\\[[0-9]*\\(%\\|/[0-9]*\\)\\]" + wspaceopt + "\\)")) + (sep (concat "\\(?:" wspace "+\\|" cookie "+\\)"))) + (concat + "^\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(\\[#.\\]\\)\\)?" + sep "*" (mapconcat #'identity + (org-split-string + (regexp-quote s)) + (concat sep "+")) + sep "*" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?") + "[ \t]*$")) + ;; (format org-complex-heading-regexp-format + ;; (regexp-quote s)) + nil t)) ;; OK, found a match (setq type 'dedicated) (goto-char (match-beginning 0))) @@ -11085,11 +11106,6 @@ visibility around point, thus ignoring (error "No match")))) (t ;; A normal search string =2D (when (equal (string-to-char s) ?*) =2D ;; Anchor on headlines, post may include tags. =2D (setq pre "^\\*+[ \t]+\\(?:\\sw+\\)?[ \t]*" =2D post (org-re "[ \t]*\\(?:[ \t]+:[[:alnum:]_@#%:+]:[ \t]*\\)?$") =2D s (substring s 1))) (remove-text-properties 0 (length s) '(face nil mouse-face nil keymap nil fontified nil) s) @@ -11106,15 +11122,9 @@ visibility around point, thus ignoring "[^a-zA-Z_\r\n]+") "\\)[^a-zA-Z_]") re4 (concat "[^a-zA-Z_]" re4_) =20 =2D re1 (concat pre re2 post) =2D re3 (concat pre (if pre re4_ re4) post) =2D re5 (concat pre ".*" re4) =2D re2 (concat pre re2) =2D re2a (concat pre (if pre re2a_ re2a)) =2D re4 (concat pre (if pre re4_ re4)) =2D reall (concat "\\(" re0 "\\)\\|\\(" re1 "\\)\\|\\(" re2 =2D "\\)\\|\\(" re3 "\\)\\|\\(" re4 "\\)\\|\\(" =2D re5 "\\)")) + re5 (concat ".*" re4) + reall (concat "\\(" re0 "\\)\\|\\(" re2 "\\)\\|\\(" re4 + "\\)\\|\\(" re5 "\\)")) (cond ((eq type 'org-occur) (org-occur reall)) ((eq type 'occur) (org-do-occur (downcase reall) 'cleanup)) @@ -11122,10 +11132,8 @@ visibility around point, thus ignoring (setq type 'fuzzy) (if (or (and (org-search-not-self 1 re0 nil t) (setq type 'dedicated)) =2D (org-search-not-self 1 re1 nil t) (org-search-not-self 1 re2 nil t) (org-search-not-self 1 re2a nil t) =2D (org-search-not-self 1 re3 nil t) (org-search-not-self 1 re4 nil t) (org-search-not-self 1 re5 nil t)) (goto-char (match-beginning 1)) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 6faabdd..cd1df08 100644 =2D-- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -1331,6 +1331,31 @@ (goto-line 3) (org-open-at-point) (looking-at "\\* Test"))) + ;; With a leading star in link, enforce exact heading match, even + ;; with `org-link-search-must-match-exact-headline' set to nil. + (should-error + (org-test-with-temp-text "* Test 1\nFoo Bar\n[[*Test]]" + (goto-line 3) + (let ((org-link-search-must-match-exact-headline nil)) + (org-open-at-point)))) + ;; Heading match should not care about spaces, cookies, todo + ;; keywords, priorities, and tags. + (should + (let ((first-line "** TODO [#A] [/] Test [1/2] [33%] 1 \t 2 [%] :work= :urgent: ")) + (org-test-with-temp-text (concat first-line "\nFoo Bar\n[[*Test 1 2]]= ") + (goto-line 3) + (let ((org-link-search-must-match-exact-headline nil) + (org-todo-regexp "TODO")) + (org-open-at-point)) + (looking-at (regexp-quote first-line))))) + ;; Heading match should still be exact + (should-error + (let ((first-line "** TODO [#A] [/] Test [1/2] [33%] 1 \t 2 [%] :work= :urgent: ")) + (org-test-with-temp-text (concat first-line "\nFoo Bar\n[[*Test 1]]") + (goto-line 3) + (let ((org-link-search-must-match-exact-headline nil) + (org-todo-regexp "TODO")) + (org-open-at-point))))) ;; Correctly un-hexify fuzzy links. (should (org-test-with-temp-text "* With space\n[[*With%20space][With space]]" =2D-=20 2.2.2 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBCgAGBQJU1fXPAAoJEAQNCjtO0uXH3ZoH/AixPbAUeaTYc2HaQbY+WuSJ L7YICney5MccFdo2caNSe88pkO249FOx6PpW46ZwyqIBlhPUWIj0DI+w52R40GcT j0CESauCB7m54XIVUfYfbiGxP3t133K3vfrZNRCby6qsElgv8jcOt+ilfNSU3DqM t2QL2wWVdeS0e7aP3NHf9bZrpXbw0cKHpx1+D0KW4Lm5VjxGCMDJZMQhxo9v7zW+ z/1290xLHuaqN34Epi0XuEewRT/uLDPLtwrqbnpQe6rMRkpyZWOjj8xKwzzJq0LR /ZSmekJL4OjzeStB7mHWQ4MUVV4ltSY1YOTb4G4nBBOI4p9hKsnuGfJ/SKrZiwk= =QbXP -----END PGP SIGNATURE----- --==-=-=--