unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
To: "積丹尼 Dan Jacobson" <jidanni@jidanni.org>
Cc: 35693@debbugs.gnu.org
Subject: bug#35693: The prompt for find-file becomes a ~ instead of ~/
Date: Tue, 14 May 2019 14:56:12 +0900	[thread overview]
Message-ID: <b4m8sv9eg03.fsf@jpl.org> (raw)
In-Reply-To: <87pnoo8l1m.2.fsf@jidanni.org>

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,





  reply	other threads:[~2019-05-14  5:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-12  2:27 bug#35693: The prompt for find-file becomes a ~ instead of ~/ 積丹尼 Dan Jacobson
2019-05-14  5:56 ` Katsumi Yamaoka [this message]
2019-05-14  9:42   ` 積丹尼 Dan Jacobson
2019-05-17  1:35     ` Katsumi Yamaoka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4m8sv9eg03.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=35693@debbugs.gnu.org \
    --cc=jidanni@jidanni.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).