From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: doc patch: move footnote in external links
Date: Sat, 10 Jan 2015 13:45:49 +0100 [thread overview]
Message-ID: <m2y4pau7lu.fsf@polytechnique.org> (raw)
In-Reply-To: <87vbl6x91a.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Sat, 20 Dec 2014 23:15:29 +0100")
[-- 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 --]
next prev parent reply other threads:[~2015-01-10 12:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2y4pau7lu.fsf@polytechnique.org \
--to=alan.schmitt@polytechnique.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.