emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] doc patch: move footnote in external links


From: Alan Schmitt
Subject: Re: [O] doc patch: move footnote in external links
Date: Wed, 14 Jan 2015 14:19:31 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4 (darwin)

On 2015-01-12 23:56, Nicolas Goaziou <address@hidden> writes:

> Alan Schmitt <address@hidden> 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: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]