From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: Re: Inconsistent behavior in generating file link search strings Date: Mon, 27 Mar 2017 10:01:20 -0500 Message-ID: <871stibw73.fsf@fastmail.fm> References: <87h92gx9ak.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:32872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csW97-0003Up-Hx for emacs-orgmode@gnu.org; Mon, 27 Mar 2017 11:01:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csW94-0007EW-9U for emacs-orgmode@gnu.org; Mon, 27 Mar 2017 11:01:25 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:41929) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csW94-0007Cc-1j for emacs-orgmode@gnu.org; Mon, 27 Mar 2017 11:01:22 -0400 Received: from archpad (c-24-14-63-242.hsd1.il.comcast.net [24.14.63.242]) by mail.messagingengine.com (Postfix) with ESMTPA id DDB6A7E352 for ; Mon, 27 Mar 2017 11:01:20 -0400 (EDT) In-Reply-To: <87h92gx9ak.fsf@fastmail.fm> (Matt Lundin's message of "Sun, 26 Mar 2017 12:21:32 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Org Mode Matt Lundin writes: > 1. First, org-insert-link truncates the search string. Here are the > steps to reproduce with emacs -Q: > > - Store a link in a plain text file. The value of org-stored-links is: > > org-stored-links is a variable defined in =E2=80=98org.el=E2=80=99. > Its value is > > (("file:~/test.txt::Duis aute irure dolor in\nreprehenderit in volupt= ate velit esse cillum dolore eu fugiat nulla\npariatur." nil)) > > - Insert the link in an org buffer using org-insert-link. The resulting > link looks like this: > > [[file:~/test.txt::Duis%20aute%20irure%20dolor%20in]] > > - This seems to run counter to the advertised behavior in > org-context-in-file-links, which says the entire region will be > stored by default. > > - The problem is the regex on line 10333 or org.el: > > (string-match "^file:\\(.+?\\)::\\(.+\\)" link)) It turns out that the line I mentioned above is actually relevant only in some cases, as it applies only when linking to an item in the current file.=20 The regex that cause the problem in most cases is line 10343: (when (string-match "^\\(file:\\|docview:\\)\\(.*\\)" link) In this case, insert link will also fail if the filename happens to contain a new line (a corner-case, I admit!). Matt