Subject: bug#19839: 24.4; ffap does not detect file paths with curly braced shell variables

From: Kaushal <[email-masked]>
Date: Tue, 07 Apr 2015 02:26:35 +0000

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 <[email-masked]> 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).
>