From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: doc patch: move footnote in external links
Date: Mon, 12 Jan 2015 12:12:21 +0100 [thread overview]
Message-ID: <m24mrws162.fsf@polytechnique.org> (raw)
In-Reply-To: <87lhl8e6db.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Mon, 12 Jan 2015 09:43:44 +0100")
[-- 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 --]
next prev parent reply other threads:[~2015-01-12 11:12 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
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 [this message]
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m24mrws162.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 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).