emacs-orgmode
[Top][All Lists]
Advanced

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

[O] re-search-forward hang in org-link-search


From: Matthew MacLean
Subject: [O] re-search-forward hang in org-link-search
Date: Thu, 13 Aug 2015 12:00:27 -0600

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:address@hidden:]+:\)?[ ]*$

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: hang.org
Description: Binary data


reply via email to

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