GNU bug report logs - #27267
25.1; ffap-file-at-point erroneously returns "" in some cases

Previous Next

Package: emacs;

Reported by: Alex <agrambot <at> gmail.com>

Date: Tue, 6 Jun 2017 22:44:01 UTC

Severity: minor

Found in version 25.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alex <agrambot <at> gmail.com>
To: 27267 <at> debbugs.gnu.org
Subject: bug#27267: 25.1; ffap-file-at-point erroneously returns "" in some cases
Date: Tue, 06 Jun 2017 16:43:32 -0600
[Message part 1 (text/plain, inline)]
Execute ffap-file-at-point with the following buffer contents (| for
cursor position):

7:|

The result is "", which leads to ffap's default input being ~ (not ~/ as
expected).

Similarly, try ffap-file-at-point on:

:6|

This is due to ffap-file-at-point stripping off the colon and numbers,
and sending "" to ffap-file-exists-string. (file-exists-p "") returns t,
so ffap-file-at-point treats "" as an existent file.

The following diff fixes this, but I'm not sure if it's the best
approach. Perhaps ffap-file-at-point just checks that the argument to
ffap-file-exists-string is non-empty each time it's called.


[ffap2.diff (text/x-diff, inline)]
diff --git a/lisp/ffap.el b/lisp/ffap.el
index 87531110b8..21312b34c3 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -514,6 +514,7 @@ ffap-file-exists-string
 The optional NOMODIFY argument suppresses the extra search."
   (cond
    ((not file) nil)			; quietly reject nil
+   ((string-empty-p file) nil)		; reject empty string
    ((file-exists-p file) file)		; try unmodified first
    ;; three reasons to suppress search:
    (nomodify nil)

This bug report was last modified 6 years and 26 days ago.

Previous Next


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