all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* re-search-forward hang in org-link-search
@ 2015-08-13 18:00 Matthew MacLean
       [not found] ` <CAOqdjBcwTCOUePnCkS5tamMROs+SEmruyAquDXykbkO4j3Hwag@mail.gmail.com>
  2015-08-18 17:30 ` Bastien
  0 siblings, 2 replies; 13+ messages in thread
From: Matthew MacLean @ 2015-08-13 18:00 UTC (permalink / raw)
  To: emacs-orgmode


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

So, I found a hang in org-link-search... (In what I think is an Emacs bug,
but posting this here certainly can't hurt.)

When you have a headline with a tag (For example "Mawile" with
":something:" as a tag), and another headline later in the buffer beginning
with the other headline's title within a word boundary (For example "Mawile
stuff", but not "Mawile's stuff"), if you try to create a link to the
second headline, Emacs hangs.

I've attached an Org file where, if you click the link, the buffer will
freeze.

I've narrowed down the problem to the "(re-search-forward re nil t)" form
of the "Regular text search" section of org-link-search in org.el.

The regular expression generated for me when I click that link is:

  ^\*+ \(?:\(BUG\|CANCELLED\|DONE\|FIXED\|KNOWNCAUSE\|REPORT\|TODO\)[
]+\)?\(?:\[#.\][ ]+\)?\(?:COMMENT[ ]+\)?\(?:[ ]+\|\(?:[
]*\[[0-9]*\(?:%\|/[0-9]*\)\][ ]*\)+\)*Mawile\(?:[ ]+\|\(?:[
]*\[[0-9]*\(?:%\|/[0-9]*\)\][ ]*\)+\)+stuff\(?:[ ]+\|\(?:[
]*\[[0-9]*\(?:%\|/[0-9]*\)\][ ]*\)+\)*\(?:[ ]+:[[:alnum:]_@#%%:]+:\)?[ ]*$

And indeed, in the buffer, if you have the point before the first headline
and M-x re-search-forward the above regex, Emacs hangs. (However, if you
have point after the headline, it finds the correct location fine.)

In the org-link-search function, point is set to (point-min) before
performing the re-search-forward, so the hang will occur regardless of
where the link or headline is, as long as the tagged headline comes first.

This happens with the latest Org mode code from the master branch on Emacs
24.5.1 (x86_64) on Linux Mint 17.2.

I think this is an Emacs bug with re-search-forward since that function is
a built-in C function and is hanging, though I figured I should give a
heads up here first. (To either verify my findings in case I missed
something and check it on other Emacs versions, or to find a defensive
workaround.)

This is just speculation, but I think it might be caused by how
re-search-forward is reacting to the tag of the first heading because it is
wrapped in ":" characters.

[-- Attachment #1.2: Type: text/html, Size: 2240 bytes --]

[-- Attachment #2: hang.org --]
[-- Type: application/octet-stream, Size: 110 bytes --]

[[Mawile stuff]]
* Mawile                                                          :something:
* Mawile stuff

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

end of thread, other threads:[~2015-08-18 18:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-13 18:00 re-search-forward hang in org-link-search Matthew MacLean
     [not found] ` <CAOqdjBcwTCOUePnCkS5tamMROs+SEmruyAquDXykbkO4j3Hwag@mail.gmail.com>
2015-08-13 18:36   ` Matthew MacLean
2015-08-13 18:50     ` Pip Cet
2015-08-13 18:55       ` Matthew MacLean
2015-08-13 23:37       ` Nicolas Goaziou
2015-08-14 16:55         ` Pip Cet
2015-08-14 20:41           ` Nicolas Goaziou
2015-08-18 17:30 ` Bastien
2015-08-18 17:48   ` Matthew MacLean
2015-08-18 17:54     ` Bastien
2015-08-18 17:58       ` Matthew MacLean
2015-08-18 18:01         ` Bastien
2015-08-18 17:57     ` Pip Cet

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.