emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* doc patch: move footnote in external links
@ 2014-12-12  7:31 Alan Schmitt
  2014-12-12 17:29 ` Nicolas Goaziou
  0 siblings, 1 reply; 18+ messages in thread
From: Alan Schmitt @ 2014-12-12  7:31 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 211 bytes --]

Hello,

I think the footnote in
http://orgmode.org/manual/External-links.html#fn-1 is in the wrong
place, it should be on the next line.

Here is a patch to fix it. If you prefer I can push it directly myself.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org.texi-Move-footnote.patch --]
[-- Type: text/x-patch, Size: 1818 bytes --]

From 4f3ccb3531744fb57d2b26a7844daf54e034e38f Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
Date: Fri, 12 Dec 2014 08:26:05 +0100
Subject: [PATCH] org.texi: Move footnote

* doc/org.texi (External links): Move footnote about the
`org-link-search-must-match-exact-headline' option from text search to
heading search.
---
 doc/org.texi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index d617259..dab6e1a 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3555,14 +3555,14 @@ file:/myself@@some.where:papers/last.pdf   @r{file, path on remote machine}
 /myself@@some.where:papers/last.pdf        @r{same as above}
 file:sometextfile::NNN                    @r{file, jump to line number}
 file:projects.org                         @r{another Org file}
-file:projects.org::some words             @r{text search in Org file}@footnote{
+file:projects.org::some words             @r{text search in Org file}
+file:projects.org::*task title            @r{heading search 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 only the
 exact headline will be matched.  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}
 file+sys:/path/to/file                    @r{open via OS, like double-click}
 file+emacs:/path/to/file                  @r{force opening by Emacs}
 docview:papers/last.pdf::NNN              @r{open in doc-view mode at page}
-- 
2.2.0


[-- Attachment #1.3: Type: text/plain, Size: 50 bytes --]


Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2014-12-12  7:31 doc patch: move footnote in external links Alan Schmitt
@ 2014-12-12 17:29 ` Nicolas Goaziou
  2014-12-13  9:43   ` Alan Schmitt
  0 siblings, 1 reply; 18+ messages in thread
From: Nicolas Goaziou @ 2014-12-12 17:29 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Hello,

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> I think the footnote in
> http://orgmode.org/manual/External-links.html#fn-1 is in the wrong
> place, it should be on the next line.
>
> Here is a patch to fix it. If you prefer I can push it directly
> myself.

I think the current documentation is correct. Only

                     file:projects.org::some words

can trigger a text search. OTOH

                      file:projects.org::*Headline

is always an exact match against headlines in the file.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2014-12-12 17:29 ` Nicolas Goaziou
@ 2014-12-13  9:43   ` Alan Schmitt
  2014-12-13 14:17     ` Nicolas Goaziou
  0 siblings, 1 reply; 18+ messages in thread
From: Alan Schmitt @ 2014-12-13  9:43 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2151 bytes --]

Hello,

On 2014-12-12 18:29, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> I think the footnote in
>> http://orgmode.org/manual/External-links.html#fn-1 is in the wrong
>> place, it should be on the next line.
>>
>> Here is a patch to fix it. If you prefer I can push it directly
>> myself.
>
> I think the current documentation is correct. Only
>
>                      file:projects.org::some words
>
> can trigger a text search. OTOH
>
>                       file:projects.org::*Headline
>
> is always an exact match against headlines in the file.

I've re-read the code, and I think this is partially correct. The only
place the `org-link-search-must-match-exact-headline' is used is below,
in a big conditional in `org-link-search'. The clauses before are used
to check special cases.

#+begin_src emacs-lisp
     ((and (derived-mode-p 'org-mode) org-link-search-must-match-exact-headline)
      (and (equal (string-to-char s) ?*) (setq s (substring s 1)))
      (goto-char (point-min))
      (cond
       ((let (case-fold-search)
	  (re-search-forward (format org-complex-heading-regexp-format
				     (regexp-quote s))
			     nil t))
	;; OK, found a match
	(setq type 'dedicated)
	(goto-char (match-beginning 0)))
       ((and (not org-link-search-inhibit-query)
	     (eq org-link-search-must-match-exact-headline 'query-to-create)
	     (y-or-n-p "No match - create this as a new heading? "))
	(goto-char (point-max))
	(or (bolp) (newline))
	(insert "* " s "\n")
	(beginning-of-line 0))
       (t
	(goto-char pos)
	(error "No match"))))
#+end_src

So you are correct the footnote applies to the text search. However, I
think is also applies to the headline search (as suggested by the second
line of the snippet). In other words, if I search for

  file:projects.org::*Headline

with `org-link-search-must-match-exact-headline' set to
'query-to-create, then I will be asked to create a headline. 

Should I add a footnote to that effect?

Thanks,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2014-12-13  9:43   ` Alan Schmitt
@ 2014-12-13 14:17     ` Nicolas Goaziou
  2014-12-16 17:20       ` Alan Schmitt
  0 siblings, 1 reply; 18+ messages in thread
From: Nicolas Goaziou @ 2014-12-13 14:17 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> So you are correct the footnote applies to the text search. However, I
> think is also applies to the headline search (as suggested by the second
> line of the snippet). In other words, if I search for
>
>   file:projects.org::*Headline
>
> with `org-link-search-must-match-exact-headline' set to
> 'query-to-create, then I will be asked to create a headline. 
>
> Should I add a footnote to that effect?

Sure. While you're at it, it should be @code{query-to-create}, not
@code{'query-to-create}.

Also, `org-link-search-must-match-exact-headline' docstring could be
improved: "When nil, the link..." doesn't apply to "*headline" type
paths.

Thanks.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2014-12-13 14:17     ` Nicolas Goaziou
@ 2014-12-16 17:20       ` Alan Schmitt
  2014-12-16 21:54         ` Nicolas Goaziou
  0 siblings, 1 reply; 18+ messages in thread
From: Alan Schmitt @ 2014-12-16 17:20 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 763 bytes --]

On 2014-12-13 15:17, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Also, `org-link-search-must-match-exact-headline' docstring could be
> improved: "When nil, the link..." doesn't apply to "*headline" type
> paths.

As I was writing this, I experimented a little. It seems that, for
"*headline" links, the following applies depending on the value of
`org-link-search-must-match-exact-headline': 
- nil: do a substring search on headlines, jump to the first one that
matches, fail if no match
- t: do an exact search on headlines, fail if no match
- 'query-to-create: do an exact search on headlines, propose to create
if no match.

The one case I'm less sure about is the first one, but this small org
file shows it seems to be the case.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: test2.org --]
[-- Type: text/x-org, Size: 312 bytes --]

Try to fool the search: ead

* Head 1
  
Evaluate this:
  
#+begin_src emacs-lisp
(setq org-link-search-must-match-exact-headline nil)
#+end_src

* Head 2

Follow these links

[[file:./test2.org::*ead 2]] goes to Head 2
[[file:./test2.org::*ead]] goes to Head 1
[[file:./test2.org::*had]] fails

[-- Attachment #1.3: Type: text/plain, Size: 106 bytes --]


If this is correct, I'll add a footnote accordingly.

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2014-12-16 17:20       ` Alan Schmitt
@ 2014-12-16 21:54         ` Nicolas Goaziou
  2014-12-17 16:33           ` Alan Schmitt
  0 siblings, 1 reply; 18+ messages in thread
From: Nicolas Goaziou @ 2014-12-16 21:54 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> On 2014-12-13 15:17, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>
>> Also, `org-link-search-must-match-exact-headline' docstring could be
>> improved: "When nil, the link..." doesn't apply to "*headline" type
>> paths.
>
> As I was writing this, I experimented a little. It seems that, for
> "*headline" links, the following applies depending on the value of
> `org-link-search-must-match-exact-headline': 
> - nil: do a substring search on headlines, jump to the first one that
> matches, fail if no match
> - t: do an exact search on headlines, fail if no match
> - 'query-to-create: do an exact search on headlines, propose to create
> if no match.

I think "*headline" links should assume this variable is non-nil,
notwithstanding its real value. Of course, a `query-to-create' value
still makes sense.

WDYT?


Regards,

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2014-12-16 21:54         ` Nicolas Goaziou
@ 2014-12-17 16:33           ` Alan Schmitt
  2014-12-20 22:15             ` Nicolas Goaziou
  0 siblings, 1 reply; 18+ messages in thread
From: Alan Schmitt @ 2014-12-17 16:33 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 443 bytes --]

On 2014-12-16 22:54, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> I think "*headline" links should assume this variable is non-nil,
> notwithstanding its real value. Of course, a `query-to-create' value
> still makes sense.
>
> WDYT?

I'm fine with this. Here is the patch extended to take this into
account, which is mostly deleting all the code that deals with headline
match when `org-link-search-must-match-exact-headline' is nil.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Function-org-link-search-does-exact-headline-search.patch --]
[-- Type: text/x-patch, Size: 4863 bytes --]

From d94259f988b84a73df4bc4111cd0b569b31e56e5 Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
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.

* 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.
---
 doc/org.texi |  7 +++++--
 lisp/org.el  | 27 +++++++--------------------
 2 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 7c464ca..7a91f70 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3559,10 +3559,13 @@ file:projects.org::some words             @r{text search 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 only the
-exact headline will be matched.  If the value is @code{'query-to-create},
+exact headline will be matched.  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}
+file:projects.org::*task title            @r{heading search in Org file}@footnote{
+Headline searches always match the exact headline. If the headline is not
+found and the value of the option @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-click}
 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/lisp/org.el b/lisp/org.el
index 1383d76..4ddb4b0 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11062,8 +11062,7 @@ visibility around point, thus ignoring
 						    org-emphasis-alist)
 					    "\\|") "\\)"))
 	(pos (point))
-	(pre nil) (post nil)
-	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))
@@ -11117,8 +11116,9 @@ visibility around point, thus ignoring
        ((derived-mode-p 'org-mode)
 	(org-occur (match-string 1 s)))
        (t (org-do-occur (match-string 1 s)))))
-     ((and (derived-mode-p 'org-mode) org-link-search-must-match-exact-headline)
-      (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))
       (goto-char (point-min))
       (cond
        ((let (case-fold-search)
@@ -11140,11 +11140,6 @@ visibility around point, thus ignoring
 	(error "No match"))))
      (t
       ;; A normal search string
-      (when (equal (string-to-char s) ?*)
-	;; Anchor on headlines, post may include tags.
-	(setq pre "^\\*+[ \t]+\\(?:\\sw+\\)?[ \t]*"
-	      post (org-re "[ \t]*\\(?:[ \t]+:[[:alnum:]_@#%:+]:[ \t]*\\)?$")
-	      s (substring s 1)))
       (remove-text-properties
        0 (length s)
        '(face nil mouse-face nil keymap nil fontified nil) s)
@@ -11161,15 +11156,9 @@ visibility around point, thus ignoring
 					  "[^a-zA-Z_\r\n]+") "\\)[^a-zA-Z_]")
 	    re4 (concat "[^a-zA-Z_]" re4_)
 
-	    re1 (concat pre re2 post)
-	    re3 (concat pre (if pre re4_ re4) post)
-	    re5 (concat pre ".*" re4)
-	    re2 (concat pre re2)
-	    re2a (concat pre (if pre re2a_ re2a))
-	    re4 (concat pre (if pre re4_ re4))
-	    reall (concat "\\(" re0 "\\)\\|\\(" re1 "\\)\\|\\(" re2
-			  "\\)\\|\\(" re3 "\\)\\|\\(" re4 "\\)\\|\\("
-			  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))
@@ -11177,10 +11166,8 @@ visibility around point, thus ignoring
 	  (setq type 'fuzzy)
 	  (if (or (and (org-search-not-self 1 re0 nil t)
 		       (setq type 'dedicated))
-		  (org-search-not-self 1 re1 nil t)
 		  (org-search-not-self 1 re2 nil t)
 		  (org-search-not-self 1 re2a nil t)
-		  (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))
-- 
2.2.0


[-- Attachment #1.3: Type: text/plain, Size: 59 bytes --]


Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2014-12-17 16:33           ` Alan Schmitt
@ 2014-12-20 22:15             ` Nicolas Goaziou
  2015-01-10 12:45               ` Alan Schmitt
  0 siblings, 1 reply; 18+ messages in thread
From: Nicolas Goaziou @ 2014-12-20 22:15 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> I'm fine with this. Here is the patch extended to take this into
> account, which is mostly deleting all the code that deals with headline
> match when `org-link-search-must-match-exact-headline' is nil.

Thanks. Some comments follow.

> -file:projects.org::*task title            @r{heading search in Org file}
> +file:projects.org::*task title            @r{heading search in Org file}@footnote{
> +Headline searches always match the exact headline. If the headline is not
                                                    ^^^
                                                 two spaces

It looks good.

However, there is a small discrepancy between `org-link-search' and
`org-export-resolve-fuzzy-link' ("ox.el"). In the latter, matches
against headlines ignore white spaces between words. I think it should
be fixed either way (removing the feature in "ox.el" or adding it in
"org.el") at some point.

Also, would you mind adding a test in test-org/fuzzy-links
("test-org.el") and an entry in ORG-NEWS?


Regards,

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2014-12-20 22:15             ` Nicolas Goaziou
@ 2015-01-10 12:45               ` Alan Schmitt
  2015-01-11 22:00                 ` Nicolas Goaziou
  0 siblings, 1 reply; 18+ messages in thread
From: Alan Schmitt @ 2015-01-10 12:45 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 585 bytes --]

Sorry for the delay in answering …

On 2014-12-20 23:15, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

>> -file:projects.org::*task title            @r{heading search in Org file}
>> +file:projects.org::*task title            @r{heading search in Org file}@footnote{
>> +Headline searches always match the exact headline. If the headline is not
>                                                     ^^^
>                                                  two spaces
>
> It looks good.

Here is an updated patch. I can push it or not, depending on the issue
below.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Function-org-link-search-does-exact-headline-search.patch --]
[-- Type: text/x-patch, Size: 4864 bytes --]

From 7fa07604c85a6a5dd06a198232ae65c4f5c0272f Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
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.

* 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.
---
 doc/org.texi |  7 +++++--
 lisp/org.el  | 27 +++++++--------------------
 2 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 54b6fe9..a179250 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3561,10 +3561,13 @@ file:projects.org::some words             @r{text search 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 only the
-exact headline will be matched.  If the value is @code{'query-to-create},
+exact headline will be matched.  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}
+file:projects.org::*task title            @r{heading search in Org file}@footnote{
+Headline searches always match the exact headline.  If the headline is not
+found and the value of the option @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-click}
 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/lisp/org.el b/lisp/org.el
index e8e3356..4ed1f17 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11021,8 +11021,7 @@ visibility around point, thus ignoring
 						    org-emphasis-alist)
 					    "\\|") "\\)"))
 	(pos (point))
-	(pre nil) (post nil)
-	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))
@@ -11076,8 +11075,9 @@ visibility around point, thus ignoring
        ((derived-mode-p 'org-mode)
 	(org-occur (match-string 1 s)))
        (t (org-do-occur (match-string 1 s)))))
-     ((and (derived-mode-p 'org-mode) org-link-search-must-match-exact-headline)
-      (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))
       (goto-char (point-min))
       (cond
        ((let (case-fold-search)
@@ -11099,11 +11099,6 @@ visibility around point, thus ignoring
 	(error "No match"))))
      (t
       ;; A normal search string
-      (when (equal (string-to-char s) ?*)
-	;; Anchor on headlines, post may include tags.
-	(setq pre "^\\*+[ \t]+\\(?:\\sw+\\)?[ \t]*"
-	      post (org-re "[ \t]*\\(?:[ \t]+:[[:alnum:]_@#%:+]:[ \t]*\\)?$")
-	      s (substring s 1)))
       (remove-text-properties
        0 (length s)
        '(face nil mouse-face nil keymap nil fontified nil) s)
@@ -11120,15 +11115,9 @@ visibility around point, thus ignoring
 					  "[^a-zA-Z_\r\n]+") "\\)[^a-zA-Z_]")
 	    re4 (concat "[^a-zA-Z_]" re4_)
 
-	    re1 (concat pre re2 post)
-	    re3 (concat pre (if pre re4_ re4) post)
-	    re5 (concat pre ".*" re4)
-	    re2 (concat pre re2)
-	    re2a (concat pre (if pre re2a_ re2a))
-	    re4 (concat pre (if pre re4_ re4))
-	    reall (concat "\\(" re0 "\\)\\|\\(" re1 "\\)\\|\\(" re2
-			  "\\)\\|\\(" re3 "\\)\\|\\(" re4 "\\)\\|\\("
-			  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))
@@ -11136,10 +11125,8 @@ visibility around point, thus ignoring
 	  (setq type 'fuzzy)
 	  (if (or (and (org-search-not-self 1 re0 nil t)
 		       (setq type 'dedicated))
-		  (org-search-not-self 1 re1 nil t)
 		  (org-search-not-self 1 re2 nil t)
 		  (org-search-not-self 1 re2a nil t)
-		  (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))
-- 
2.2.1


[-- Attachment #1.3: Type: text/plain, Size: 782 bytes --]


> However, there is a small discrepancy between `org-link-search' and
> `org-export-resolve-fuzzy-link' ("ox.el"). In the latter, matches
> against headlines ignore white spaces between words. I think it should
> be fixed either way (removing the feature in "ox.el" or adding it in
> "org.el") at some point.

I have looked at the code and it works *very* differently. I think I can
make the `org-export-resolve-fuzzy-link' take spaces into accounts for
headlines, but I don't see how it is "fuzzy".

> Also, would you mind adding a test in test-org/fuzzy-links
> ("test-org.el") and an entry in ORG-NEWS?

I guess this should be done if I change `org-export-resolve-fuzzy-link',
or should I do it anyway?

Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2015-01-10 12:45               ` Alan Schmitt
@ 2015-01-11 22:00                 ` Nicolas Goaziou
  2015-01-12  7:40                   ` Alan Schmitt
  0 siblings, 1 reply; 18+ messages in thread
From: Nicolas Goaziou @ 2015-01-11 22:00 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Here is an updated patch. I can push it or not, depending on the issue
> below.

Thanks. The patch is OK.

> I have looked at the code and it works *very* differently. I think I can
> make the `org-export-resolve-fuzzy-link' take spaces into accounts for
> headlines, but I don't see how it is "fuzzy".

I'd rather ignore whitespace when matching headlines. It can be useful
when skipping statistics cookies. E.g.,

 * Completed: [33%] so far

can be matched with either [[Completed: so far]] and [[Completed:  so far]].

[[fuzzy]]-like links are fuzzy because they can match either a headline,
a #+NAME or a <<target>>.

I lean towards making the change the other way.

>> Also, would you mind adding a test in test-org/fuzzy-links
>> ("test-org.el") and an entry in ORG-NEWS?
>
> I guess this should be done if I change `org-export-resolve-fuzzy-link',
> or should I do it anyway?

I think a test would be nice for the change you are making to
`org-link-search', i.e, you can extend "test-org/fuzzy-links" (part with
[[*Test]]) to ensure that match is exact, independently on
`org-link-search-must-match-exact-headline'.

Regards,

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2015-01-11 22:00                 ` Nicolas Goaziou
@ 2015-01-12  7:40                   ` Alan Schmitt
  2015-01-12  8:43                     ` Nicolas Goaziou
  0 siblings, 1 reply; 18+ messages in thread
From: Alan Schmitt @ 2015-01-12  7:40 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1959 bytes --]

On 2015-01-11 23:00, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> Here is an updated patch. I can push it or not, depending on the issue
>> below.
>
> Thanks. The patch is OK.

Great. I won't commit it, though, as I prefer to solve the space thing.

>> I have looked at the code and it works *very* differently. I think I can
>> make the `org-export-resolve-fuzzy-link' take spaces into accounts for
>> headlines, but I don't see how it is "fuzzy".
>
> I'd rather ignore whitespace when matching headlines. It can be useful
> when skipping statistics cookies. E.g.,
>
>  * Completed: [33%] so far
>
> can be matched with either [[Completed: so far]] and [[Completed:  so far]].

I don't understand: won't you need the "[33%]" bit for an exact search?

Also, does ignoring whitespace mean replacing any (non-empty) amount of
whitespace by non-empty whitespace, or can you also insert or delete
whitespace between contiguous strings:
- do "foobar" and "foo bar" match?
- do "foo bar" and "foobar" match?

> [[fuzzy]]-like links are fuzzy because they can match either a headline,
> a #+NAME or a <<target>>.

I see.

> I lean towards making the change the other way.

OK, I think I can do it if we do not allow to insert whitespace in
arbitrary positions (searching "foobar" will not match "foo bar").

>>> Also, would you mind adding a test in test-org/fuzzy-links
>>> ("test-org.el") and an entry in ORG-NEWS?
>>
>> I guess this should be done if I change `org-export-resolve-fuzzy-link',
>> or should I do it anyway?
>
> I think a test would be nice for the change you are making to
> `org-link-search', i.e, you can extend "test-org/fuzzy-links" (part with
> [[*Test]]) to ensure that match is exact, independently on
> `org-link-search-must-match-exact-headline'.

OK, I'll look into it.

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2015-01-12  7:40                   ` Alan Schmitt
@ 2015-01-12  8:43                     ` Nicolas Goaziou
  2015-01-12 11:12                       ` Alan Schmitt
  0 siblings, 1 reply; 18+ messages in thread
From: Nicolas Goaziou @ 2015-01-12  8:43 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> I don't understand: won't you need the "[33%]" bit for an exact
> search?

A statistics cookie is a variable part. If it ever changes, all your
links become invalid. It is better to simply ignore them (which is
already the case).

> Also, does ignoring whitespace mean replacing any (non-empty) amount of
> whitespace by non-empty whitespace, or can you also insert or delete
> whitespace between contiguous strings:
> - do "foobar" and "foo bar" match?
> - do "foo bar" and "foobar" match?

The former. Or use `split string', like in
`org-export-resolve-fuzzy-link'.

> OK, I'll look into it.

Thanks.


Regards,

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2015-01-12  8:43                     ` Nicolas Goaziou
@ 2015-01-12 11:12                       ` Alan Schmitt
  2015-01-12 22:56                         ` Nicolas Goaziou
  0 siblings, 1 reply; 18+ messages in thread
From: Alan Schmitt @ 2015-01-12 11:12 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2374 bytes --]

On 2015-01-12 09:43, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> I don't understand: won't you need the "[33%]" bit for an exact
>> search?
>
> A statistics cookie is a variable part. If it ever changes, all your
> links become invalid. It is better to simply ignore them (which is
> already the case).

OK. I see that the current regexp for headline matching is defined as
follows:

#+begin_src emacs-lisp
(concat "^\\(\\*+\\)"
        "\\(?: +" org-todo-regexp "\\)?"
        "\\(?: +\\(\\[#.\\]\\)\\)?"
        "\\(?: +"
        ;; Stats cookies can be stuck to body.
        "\\(?:\\[[0-9%%/]+\\] *\\)*"
        "\\(%s\\)"
        "\\(?: *\\[[0-9%%/]+\\]\\)*"
        "\\)"
        (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?")
        "[ \t]*$")
#+end_src

used like this (the regexp is `org-complex-heading-regexp-format'):

#+begin_src emacs-lisp
(re-search-forward (format org-complex-heading-regexp-format
                           (regexp-quote s))
                   nil t)
#+end_src

I see that the cookie is ignored, but it seems that it can only be at
the end of the searched heading.

The approach taken in ox.el is different: it gets rid of the cookie in
the found headlines:

#+begin_src emacs-lisp
(org-element-map data 'headline
  (lambda (headline)
    (when (equal (org-split-string
		  (replace-regexp-in-string
		   "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
		   (org-element-property :raw-value headline)))
		 name)
      headline))
  info 'first-match)
#+end_src

This allows the cookie to be anywhere (in fact not even surrounded by
white space).

Should we assume the cookie is at the end of the headline or not?

>> Also, does ignoring whitespace mean replacing any (non-empty) amount of
>> whitespace by non-empty whitespace, or can you also insert or delete
>> whitespace between contiguous strings:
>> - do "foobar" and "foo bar" match?
>> - do "foo bar" and "foobar" match?
>
> The former. Or use `split string', like in
> `org-export-resolve-fuzzy-link'.

I'd gladly do this, but to use the `org-element-map' function it seem
that I need a parse tree. How can I get it? Or is it possible to use
directly `org-element-map' on a buffer?

Thanks,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2015-01-12 11:12                       ` Alan Schmitt
@ 2015-01-12 22:56                         ` Nicolas Goaziou
  2015-01-14 13:19                           ` Alan Schmitt
  0 siblings, 1 reply; 18+ messages in thread
From: Nicolas Goaziou @ 2015-01-12 22:56 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Should we assume the cookie is at the end of the headline or not?

The cookie can be anywhere within the headline text.

> I'd gladly do this, but to use the `org-element-map' function it seem
> that I need a parse tree. How can I get it? Or is it possible to use
> directly `org-element-map' on a buffer?

You don't need to use `org-element-map'[fn:1]. However, you cannot just use
`re-search-forward' either. You probably need to map over entries (e.g.,
with `org-map-entries'), apply some filter to current headline, and
compare it with link's path. This is slower than the current
implementation.

Another option would be to ignore only contents of statistics cookies,
not the whole cookie. This way we still can turn path into a proper
regexp.

WDYT?


Regards,

[fn:1] Btw, you get a parse tree with `org-element-parse-buffer'.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2015-01-12 22:56                         ` Nicolas Goaziou
@ 2015-01-14 13:19                           ` Alan Schmitt
  2015-01-16  8:57                             ` Nicolas Goaziou
  0 siblings, 1 reply; 18+ messages in thread
From: Alan Schmitt @ 2015-01-14 13:19 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1830 bytes --]

On 2015-01-12 23:56, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> Should we assume the cookie is at the end of the headline or not?
>
> The cookie can be anywhere within the headline text.
>
>> I'd gladly do this, but to use the `org-element-map' function it seem
>> that I need a parse tree. How can I get it? Or is it possible to use
>> directly `org-element-map' on a buffer?
>
> You don't need to use `org-element-map'[fn:1]. However, you cannot just use
> `re-search-forward' either. You probably need to map over entries (e.g.,
> with `org-map-entries'), apply some filter to current headline, and
> compare it with link's path. This is slower than the current
> implementation.
>
> Another option would be to ignore only contents of statistics cookies,
> not the whole cookie. This way we still can turn path into a proper
> regexp.

Would the following work as a regexp builder that allows arbitrary space
and cookies between each word (making sure there is at least one)?

#+begin_src emacs-lisp
(defun org-heading-regexp-build (s)
  (let* ((sp (reverse (org-split-string s)))
         (wspace "[ \t]")
         (wspaceopt (concat wspace "*"))
         (cookie (concat "\\(?:"
                         wspaceopt
                         "\\(?:\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]\\)"
                         wspaceopt
                         "\\)"))
         (sep (concat "\\(?:" wspace "+\\|" cookie "+\\)"))
         res)
    (dolist (w sp) (setq res (concat w sep res)))
    (concat sep res)))
#+end_src

This of course needs to be extended with the other headline features
(todo keyword, tags, …), this is just to know if I'm on the right track.

Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2015-01-14 13:19                           ` Alan Schmitt
@ 2015-01-16  8:57                             ` Nicolas Goaziou
  2015-02-07 11:23                               ` Alan Schmitt
  0 siblings, 1 reply; 18+ messages in thread
From: Nicolas Goaziou @ 2015-01-16  8:57 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Would the following work as a regexp builder that allows arbitrary space
> and cookies between each word (making sure there is at least one)?
>
> #+begin_src emacs-lisp
> (defun org-heading-regexp-build (s)
>   (let* ((sp (reverse (org-split-string s)))

You can ignore SP for the time being.

>          (wspace "[ \t]")
>          (wspaceopt (concat wspace "*"))
>          (cookie (concat "\\(?:"
>                          wspaceopt
>                          "\\(?:\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]\\)"

  "\\[[0-9]*\\(%\\|/[0-9]*\\)\\]"

statistics cookies can be empty.

>                          wspaceopt
>                          "\\)"))
>          (sep (concat "\\(?:" wspace "+\\|" cookie "+\\)"))
>          res)
>     (dolist (w sp) (setq res (concat w sep res)))
>     (concat sep res))

(concat sep (mapconcat #'identity (org-split-string s) sep) sep)

> This of course needs to be extended with the other headline features
> (todo keyword, tags, …)

I don't think so. Other features can be ignored (see, e.g.,
`org-get-heading').


Regards,

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2015-01-16  8:57                             ` Nicolas Goaziou
@ 2015-02-07 11:23                               ` Alan Schmitt
  2015-02-07 21:44                                 ` Nicolas Goaziou
  0 siblings, 1 reply; 18+ messages in thread
From: Alan Schmitt @ 2015-02-07 11:23 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 186 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Function-org-link-search-does-exact-headline-search.patch --]
[-- Type: text/x-patch, Size: 8560 bytes --]

From ea6fb4d8134b1708ae195a342b41de268453b470 Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
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.
---
 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
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3561,10 +3561,14 @@ file:projects.org::some words             @r{text search 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 only the
-exact headline will be matched.  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}
+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 option
+@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-click}
 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
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -218,6 +218,11 @@ The build system has been enhanced to allow test selection with a
 regular expression by defining =BTEST_RE= 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
 
 ** Incompatible changes
diff --git a/lisp/org.el b/lisp/org.el
index a095f8d..271fe1f 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11007,8 +11007,7 @@ visibility around point, thus ignoring
 						    org-emphasis-alist)
 					    "\\|") "\\)"))
 	(pos (point))
-	(pre nil) (post nil)
-	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)))))
-     ((and (derived-mode-p 'org-mode) org-link-search-must-match-exact-headline)
-      (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)
-	  (re-search-forward (format org-complex-heading-regexp-format
-				     (regexp-quote s))
-			     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
-      (when (equal (string-to-char s) ?*)
-	;; Anchor on headlines, post may include tags.
-	(setq pre "^\\*+[ \t]+\\(?:\\sw+\\)?[ \t]*"
-	      post (org-re "[ \t]*\\(?:[ \t]+:[[:alnum:]_@#%:+]:[ \t]*\\)?$")
-	      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_)
 
-	    re1 (concat pre re2 post)
-	    re3 (concat pre (if pre re4_ re4) post)
-	    re5 (concat pre ".*" re4)
-	    re2 (concat pre re2)
-	    re2a (concat pre (if pre re2a_ re2a))
-	    re4 (concat pre (if pre re4_ re4))
-	    reall (concat "\\(" re0 "\\)\\|\\(" re1 "\\)\\|\\(" re2
-			  "\\)\\|\\(" re3 "\\)\\|\\(" re4 "\\)\\|\\("
-			  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))
-		  (org-search-not-self 1 re1 nil t)
 		  (org-search-not-self 1 re2 nil t)
 		  (org-search-not-self 1 re2a nil t)
-		  (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
--- 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]]"
-- 
2.2.2


[-- Attachment #1.3: Type: text/plain, Size: 44 bytes --]



-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: doc patch: move footnote in external links
  2015-02-07 11:23                               ` Alan Schmitt
@ 2015-02-07 21:44                                 ` Nicolas Goaziou
  0 siblings, 0 replies; 18+ messages in thread
From: Nicolas Goaziou @ 2015-02-07 21:44 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Hello,

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Here is a new version of the patch, with some tests and a mention in
> ORG-NEWS.

Applied. Thank you.

I slightly modified the regexp used for the match (mainly removing
unnecessary match groups).

> I did not know if I should mention the ORG-NEWS change in the
> Changelog (I did not).

I added it.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2015-02-07 21:43 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-12  7:31 doc patch: move footnote in external links Alan Schmitt
2014-12-12 17:29 ` Nicolas Goaziou
2014-12-13  9:43   ` Alan Schmitt
2014-12-13 14:17     ` Nicolas Goaziou
2014-12-16 17:20       ` Alan Schmitt
2014-12-16 21:54         ` Nicolas Goaziou
2014-12-17 16:33           ` Alan Schmitt
2014-12-20 22:15             ` Nicolas Goaziou
2015-01-10 12:45               ` Alan Schmitt
2015-01-11 22:00                 ` Nicolas Goaziou
2015-01-12  7:40                   ` Alan Schmitt
2015-01-12  8:43                     ` Nicolas Goaziou
2015-01-12 11:12                       ` Alan Schmitt
2015-01-12 22:56                         ` Nicolas Goaziou
2015-01-14 13:19                           ` Alan Schmitt
2015-01-16  8:57                             ` Nicolas Goaziou
2015-02-07 11:23                               ` Alan Schmitt
2015-02-07 21:44                                 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).