bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Alex
Subject: bug#27267: 25.1; ffap-file-at-point erroneously returns "" in some cases
Date: Tue, 06 Jun 2017 16:43:32 -0600

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.


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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]