On 2015-01-12 09:43, Nicolas Goaziou writes: > Alan Schmitt 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