[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35693: The prompt for find-file becomes a ~ instead of ~/
From: |
Katsumi Yamaoka |
Subject: |
bug#35693: The prompt for find-file becomes a ~ instead of ~/ |
Date: |
Tue, 14 May 2019 14:56:12 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-cygwin) |
On Sun, 12 May 2019 10:27:01 +0800, 積丹尼 wrote:
> M-x gnus
> C-x C-f
> The prompt for find-file becomes a ~ instead of ~/
`C-x C-f' invokes `find-file-at-point' because of `ffap-bindings'.
> It turns out because since one uses ffap-bindings
> and the cursor is now resting after a ":", the find-file prompt is
> affected.
> OK it is not a gnus bug, but most commonly seen when using gnus...
Yes, it's not a Gnus bug. That happens when performing `C-x C-f'
just after the colon in the group line like this:
123: nnfoo:bar
There ffap grabs a string "123:", recognizes it as a colon separated
paths list, and extracts a path where the cursor is, that is "".
That *path* string is used to create a prompt string by way of:
(abbreviate-file-name (expand-file-name ""))
It returns "~" because you are in the home directory. That is why
you are prompted with "~" instead of "~/".
There would be many ways to solve it, though I'm not sure what is
the best. Here are two of them (based on ffap.el in the trunk):
1. (ffap-file-at-point): Don't recognize "" as a path name.
--- ffap.el~ 2019-05-12 21:20:25.967974700 +0000
+++ ffap.el 2019-05-14 05:51:47.038159300 +0000
@@ -1326,6 +1326,7 @@
;; If it contains a colon, get rid of it (and return if exists)
((and (string-match path-separator name)
(setq name (ffap-string-at-point 'nocolon))
+ (> (length name) 0)
(ffap-file-exists-string name)))
;; File does not exist, try the alist:
((let ((alist ffap-alist) tem try case-fold-search)
2. (ffap-file-exists-string): Don't recognize "" as a file name.
--- ffap.el~ 2019-05-12 21:20:25.967974700 +0000
+++ ffap.el 2019-05-14 05:51:47.038159300 +0000
@@ -513,7 +513,7 @@
name may have a suffix added from `ffap-compression-suffixes'.
The optional NOMODIFY argument suppresses the extra search."
(cond
- ((not file) nil) ; quietly reject nil
+ ((zerop (length file)) nil) ; quietly reject nil and ""
((file-exists-p file) file) ; try unmodified first
;; three reasons to suppress search:
(nomodify nil)
Regards,