GNU bug report logs - #19839
24.4; ffap does not detect file paths with curly braced shell variables

Previous Next

Package: emacs;

Reported by: Kaushal <kaushal.modi <at> gmail.com>

Date: Wed, 11 Feb 2015 19:25:01 UTC

Severity: minor

Found in version 24.4

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19839 in the body.
You can then email your comments to 19839 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#19839; Package emacs. (Wed, 11 Feb 2015 19:25:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kaushal <kaushal.modi <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 11 Feb 2015 19:25:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Kaushal <kaushal.modi <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4;
 ffap does not detect file paths with curly braced shell variables
Date: Wed, 11 Feb 2015 14:23:14 -0500
[Message part 1 (text/plain, inline)]
Hi,

The ffap gives an error if I try to do =C-x C-f= while the path is on a
path containing curly braces wrapped shell variable.

e.g. ${PRJ_HOME}/dir1/file1.el

I traced the problem to the ffap-string-at-point-mode-alist variable in
lisp/ffap.el.

The fix is to replace

    (file "--:\\\\$+<>@-Z_[:alpha:]~*?" "<@" "@>;.,!:") ; broken

with

    (file "--:\\\\$\\{\\}+<>@-Z_[:alpha:]~*?" "<@" "@>;.,!:") ; fixed


I added "\\{\\}" to the regexp for 'file'.

---

*Original* lisp/ffap.el in emacs 24.4

(defvar ffap-string-at-point-mode-alist
  '(
    ;; The default, used when the `major-mode' is not found.
    ;; Slightly controversial decisions:
    ;; * strip trailing "@" and ":"
    ;; * no commas (good for latex)
    (file "--:\\\\$+<>@-Z_[:alpha:]~*?" "<@" "@>;.,!:")
    ;; An url, or maybe a email/news message-id:
    (url "--:=&?$+@-Z_[:alpha:]~#,%;*()!'" "^[0-9a-zA-Z]" ":;.,!?")
    ;; Find a string that does *not* contain a colon:
    (nocolon "--9$+<>@-Z_[:alpha:]~" "<@" "@>;.,!?")
    ;; A machine:
    (machine "-[:alnum:]." "" ".")
    ;; Mathematica paths: allow backquotes
    (math-mode ",-:$+<>@-Z_[:lower:]~`" "<" "@>;.,!?`:")
    )


In GNU Emacs 24.4.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.10.4)
 of 2015-01-29 on ulcf20.cld.MYCOMPANY.com
Windowing system distributor `The X.Org Foundation', version 11.0.60900000
System Description: Red Hat Enterprise Linux Client release 5.10 (Tikanga)

Configured using:
 `configure --prefix=/home/kmodi/usr_local/apps/emacs/24.4
 CPPFLAGS=-fgnu89-inline'

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp



--
Kaushal Modi
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19839; Package emacs. (Mon, 06 Apr 2015 19:15:02 GMT) Full text and rfc822 format available.

Message #8 received at 19839 <at> debbugs.gnu.org (full text, mbox):

From: Kaushal <kaushal.modi <at> gmail.com>
To: 19839 <at> debbugs.gnu.org
Subject: 24.4;
 ffap does not detect file paths with curly braced shell variables
Date: Mon, 06 Apr 2015 19:13:53 +0000
[Message part 1 (text/plain, inline)]
Did anyone get a chance to review this?

Thanks.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19839; Package emacs. (Mon, 06 Apr 2015 23:54:02 GMT) Full text and rfc822 format available.

Message #11 received at 19839 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Kaushal <kaushal.modi <at> gmail.com>, 19839 <at> debbugs.gnu.org
Subject: Re: bug#19839: 24.4; ffap does not detect file paths with
 curly braced shell variables
Date: Tue, 07 Apr 2015 02:53:14 +0300
Hi!

On 02/11/2015 09:23 PM, Kaushal wrote:

> The ffap gives an error if I try to do =C-x C-f= while the path is on a
> path containing curly braces wrapped shell variable.

What kind of error?

I don't see any errors doing `M-x ffap' or `C-x C-f', it just doesn't 
find anything.

> I added "\\{\\}" to the regexp for 'file'.

What's the thinking here? We don't expand env variables in `find-file', 
right? So there will be no match anyway?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19839; Package emacs. (Tue, 07 Apr 2015 00:01:01 GMT) Full text and rfc822 format available.

Message #14 received at 19839 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Kaushal <kaushal.modi <at> gmail.com>, 19839 <at> debbugs.gnu.org
Subject: Re: bug#19839: 24.4; ffap does not detect file paths with
 curly braced shell variables
Date: Tue, 07 Apr 2015 03:00:18 +0300
On 04/07/2015 02:53 AM, Dmitry Gutov wrote:

> I don't see any errors doing `M-x ffap' or `C-x C-f', it just doesn't
> find anything.

...in Emacs built from the master branch (forgot to mention that).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19839; Package emacs. (Tue, 07 Apr 2015 02:27:02 GMT) Full text and rfc822 format available.

Message #17 received at 19839 <at> debbugs.gnu.org (full text, mbox):

From: Kaushal <kaushal.modi <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>, 19839 <at> debbugs.gnu.org
Subject: Re: bug#19839: 24.4; ffap does not detect file paths with curly
 braced shell variables
Date: Tue, 07 Apr 2015 02:26:35 +0000
[Message part 1 (text/plain, inline)]
I was able to recreate this consistently in master branch.

You need to enable the ido ffap feature for this to work.

Also I noticed that no error is thrown any more (it probably changed 24.4
onwards) but ffap still does not work over paths with curly braces. My fix
fixes that.


* Copy the below content to *scratch* buffer on an emacs -Q session and
follow the steps. *

;; STEP 1: Enable ido ffap

(require 'ido)
(setq ido-use-filename-at-point 'guess)
(ido-mode 1)

;; STEP 2: Test that when you put the point over the below link and do `M-x
ido-find-file', it does not try to open that particular file
;; ${HOME}/.emacs.d/init.el
;; Change the above link to ${HOME}/.emacs or the where you save your emacs
config file for the sake of this example

It did not work because the following call order returns nil by default
(before the below fix in STEP 3)

ido-find-file > ido-file-internal > ffap-guesser > ffap-file-at-point >
ffap-string-at-point

;; STEP 3:
;; Patch `ffap-string-at-point-mode-alist' to support file paths with curly
braces:
(require 'ffap)
;; Delete from `ffap-string-at-point-mode-alist' all elements whose `car'
is `file'
(setq ffap-string-at-point-mode-alist
      (assq-delete-all 'file ffap-string-at-point-mode-alist))
;; and then add a new list `(file ..)' that supports the curly braces.
(add-to-list 'ffap-string-at-point-mode-alist
             '(file "--:\\\\$\\{\\}+<>@-Z_[:alpha:]~*?" "<@" "@>;.,!:"))

;; STEP 4: Repeat STEP 2. Now when you do `M-x ido-find-file` over that
path, emacs will try to open the file in that path (it auto expands the
environment variable $HOME)


Let me know if you also can repeat these steps.


On Mon, Apr 6, 2015 at 8:00 PM Dmitry Gutov <dgutov <at> yandex.ru> wrote:

> On 04/07/2015 02:53 AM, Dmitry Gutov wrote:
>
>  > I don't see any errors doing `M-x ffap' or `C-x C-f', it just doesn't
> > find anything.
>
> ...in Emacs built from the master branch (forgot to mention that).
>
[Message part 2 (text/html, inline)]

Reply sent to Dmitry Gutov <dgutov <at> yandex.ru>:
You have taken responsibility. (Wed, 08 Apr 2015 00:23:02 GMT) Full text and rfc822 format available.

Notification sent to Kaushal <kaushal.modi <at> gmail.com>:
bug acknowledged by developer. (Wed, 08 Apr 2015 00:23:02 GMT) Full text and rfc822 format available.

Message #22 received at 19839-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Kaushal <kaushal.modi <at> gmail.com>, 19839-done <at> debbugs.gnu.org
Subject: Re: bug#19839: 24.4; ffap does not detect file paths with
 curly braced shell variables
Date: Wed, 08 Apr 2015 03:22:09 +0300
On 04/07/2015 05:26 AM, Kaushal wrote:
> I was able to recreate this consistently in master branch.

Ok, me too.

> Also I noticed that no error is thrown any more (it probably changed
> 24.4 onwards) but ffap still does not work over paths with curly braces.
> My fix fixes that.

Previously, I stopped looking after seeing no error. Didn't actually 
expect that the expansion works.

>               '(file "--:\\\\$\\{\\}+<>@-Z_[:alpha:]~*?" "<@" "@>;.,!:"))

Thank you, the suggested change in now on master.

> Let me know if you also can repeat these steps.

Seems to work now.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 06 May 2015 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 45 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.