emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matthew MacLean <archenoth@gmail.com>
To: emacs-orgmode@gnu.org
Subject: re-search-forward hang in org-link-search
Date: Thu, 13 Aug 2015 12:00:27 -0600	[thread overview]
Message-ID: <CA+GZiYrXZCAVOEO=Ka+DfZTee6aKvZphk=XicpwoEiXvQ-_cOg@mail.gmail.com> (raw)


[-- 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

             reply	other threads:[~2015-08-13 18:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13 18:00 Matthew MacLean [this message]
     [not found] ` <CAOqdjBcwTCOUePnCkS5tamMROs+SEmruyAquDXykbkO4j3Hwag@mail.gmail.com>
2015-08-13 18:36   ` re-search-forward hang in org-link-search 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

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='CA+GZiYrXZCAVOEO=Ka+DfZTee6aKvZphk=XicpwoEiXvQ-_cOg@mail.gmail.com' \
    --to=archenoth@gmail.com \
    --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).