GNU bug report logs - #48782
28.0.50; fido-mode: shell variables distort find-file behaviour

Previous Next

Package: emacs;

Reported by: simon254 <at> mailbox.org

Date: Tue, 1 Jun 2021 17:53:02 UTC

Severity: normal

Tags: confirmed

Found in version 28.0.50

Done: João Távora <joaotavora <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48782 in the body.
You can then email your comments to 48782 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#48782; Package emacs. (Tue, 01 Jun 2021 17:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to simon254 <at> mailbox.org:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 01 Jun 2021 17:53:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: simon254 <at> mailbox.org
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: 28.0.50; fido-mode: shell variables distort find-file behaviour
Date: Tue, 1 Jun 2021 18:29:17 +0100 (BST)
with emacs -Q

1) 
M-x -> fido-mode
C-x C-f -> type "$HOME" -> enter opens dired buffer in $HOME directory
instead of continuing find-file $HOME to select a file to open

2)
similar thing happens if:
M-x -> fido-mode
C-x C-f -> type "$HOME/.emacs.d" -> enter opens dired buffer in $HOME/emacs.d directory
instead of continuing find-file $HOME/emacs.d to select a file to open

in pure icomplete-mode find-file seems to work as expected after typing "$HOME/" 
-> descent into directories via C-M-i?

ido-mode will not match environment variables but when typing

M-x -> ido-mode
C-x C-f -> type "$HOME/" -> ido expands $HOME to the actuall path and
find-file continues as expected

ido.el has

(defun ido-complete ()
  "Try and complete the current pattern amongst the file names."
  (interactive)
  (let (res)
    (cond
     (ido-incomplete-regexp
      ;; Do nothing
      )
     ((and (memq ido-cur-item '(file dir))
	   (string-match "[$]" ido-text))
      (let ((evar (substitute-in-file-name (concat ido-current-directory ido-text))))
	(if (not (file-exists-p (file-name-directory evar)))
	    (message "Expansion generates non-existing directory name")
	  (if (file-directory-p evar)
	      (ido-set-current-directory evar)
	    (let ((d (or (file-name-directory evar) "/"))
		  (f (file-name-nondirectory evar)))
	      (when (file-directory-p d)
		  (ido-set-current-directory d)
		  (setq ido-text-init f))))
	  (setq ido-exit 'refresh)
	  (exit-minibuffer))))

This was tested in emacs 28 but also 27

In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.4.0, NS appkit-2022.44 Version 11.3.1 (Build 20E241))
 of 2021-05-20 built on Zwei.local
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.4

Configured using:
 'configure --disable-dependency-tracking --disable-silent-rules
 --enable-locallisppath=/usr/local/share/emacs/site-lisp
 --infodir=/usr/local/Cellar/emacs-plus <at> 28/28.0.50/share/info/emacs
 --prefix=/usr/local/Cellar/emacs-plus <at> 28/28.0.50 --with-xml2
 --with-gnutls --with-native-compilation --without-dbus
 --with-imagemagick --with-modules --with-rsvg --with-ns
 --disable-ns-self-contained 'CFLAGS=-I/usr/local/opt/gcc/include
 -I/usr/local/opt/libgccjit/include -I/usr/local/opt/gmp/include
 -I/usr/local/opt/jpeg/include' 'LDFLAGS=-L/usr/local/lib/gcc/11
 -I/usr/local/opt/gcc/include -I/usr/local/opt/libgccjit/include
 -I/usr/local/opt/gmp/include -I/usr/local/opt/jpeg/include''

Configured features:
ACL GIF GLIB GMP GNUTLS IMAGEMAGICK JPEG JSON LCMS2 LIBXML2 MODULES
NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG THREADS TIFF
TOOLKIT_SCROLL_BARS XIM ZLIB

Important settings:
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 67326 7749)
 (symbols 48 6525 0)
 (strings 32 18694 1859)
 (string-bytes 1 645296)
 (vectors 16 13385)
 (vector-slots 8 280235 8834)
 (floats 8 22 29)
 (intervals 56 226 0)
 (buffers 992 10))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48782; Package emacs. (Fri, 04 Jun 2021 17:55:02 GMT) Full text and rfc822 format available.

Message #8 received at 48782 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: simon254 <at> mailbox.org, 48782 <at> debbugs.gnu.org,
 João Távora <joaotavora <at> gmail.com>
Subject: Re: bug#48782: 28.0.50; fido-mode: shell variables distort find-file
 behaviour
Date: Fri, 4 Jun 2021 20:54:40 +0300
Joao, could you take a look?

On 01.06.2021 20:29, simon254--- via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> with emacs -Q
> 
> 1)
> M-x -> fido-mode
> C-x C-f -> type "$HOME" -> enter opens dired buffer in $HOME directory
> instead of continuing find-file $HOME to select a file to open
> 
> 2)
> similar thing happens if:
> M-x -> fido-mode
> C-x C-f -> type "$HOME/.emacs.d" -> enter opens dired buffer in $HOME/emacs.d directory
> instead of continuing find-file $HOME/emacs.d to select a file to open
> 
> in pure icomplete-mode find-file seems to work as expected after typing "$HOME/"
> -> descent into directories via C-M-i?
> 
> ido-mode will not match environment variables but when typing
> 
> M-x -> ido-mode
> C-x C-f -> type "$HOME/" -> ido expands $HOME to the actuall path and
> find-file continues as expected
> 
> ido.el has
> 
> (defun ido-complete ()
>    "Try and complete the current pattern amongst the file names."
>    (interactive)
>    (let (res)
>      (cond
>       (ido-incomplete-regexp
>        ;; Do nothing
>        )
>       ((and (memq ido-cur-item '(file dir))
> 	   (string-match "[$]" ido-text))
>        (let ((evar (substitute-in-file-name (concat ido-current-directory ido-text))))
> 	(if (not (file-exists-p (file-name-directory evar)))
> 	    (message "Expansion generates non-existing directory name")
> 	  (if (file-directory-p evar)
> 	      (ido-set-current-directory evar)
> 	    (let ((d (or (file-name-directory evar) "/"))
> 		  (f (file-name-nondirectory evar)))
> 	      (when (file-directory-p d)
> 		  (ido-set-current-directory d)
> 		  (setq ido-text-init f))))
> 	  (setq ido-exit 'refresh)
> 	  (exit-minibuffer))))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48782; Package emacs. (Sat, 05 Jun 2021 19:45:01 GMT) Full text and rfc822 format available.

Message #11 received at 48782 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: simon254--- via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: simon254 <at> mailbox.org, 48782 <at> debbugs.gnu.org
Subject: Re: bug#48782: 28.0.50; fido-mode: shell variables distort
 find-file behaviour
Date: Sat, 05 Jun 2021 19:39:48 +0100
tag 48782 important
thanks

simon254--- via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs <at> gnu.org> writes:

> with emacs -Q
>
> 1) 
> M-x -> fido-mode
> C-x C-f -> type "$HOME" -> enter opens dired buffer in $HOME directory
> instead of continuing find-file $HOME to select a file to open

Thanks, I reproduced this and will try to fix it.  Doesn't seem very
hard, but we'll see.

João




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48782; Package emacs. (Sat, 05 Jun 2021 20:04:02 GMT) Full text and rfc822 format available.

Added tag(s) confirmed. Request was from João Távora <joaotavora <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 05 Jun 2021 20:34:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48782; Package emacs. (Sat, 05 Jun 2021 20:52:01 GMT) Full text and rfc822 format available.

Message #19 received at submit <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: simon254--- via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: simon254 <at> mailbox.org, 48782-done <at> debbugs.gnu.org
Subject: Re: bug#48782: 28.0.50; fido-mode: shell variables distort
 find-file behaviour
Date: Sat, 05 Jun 2021 21:51:39 +0100
João Távora <joaotavora <at> gmail.com> writes:

> tag 48782 important
> thanks
>
> simon254--- via "Bug reports for GNU Emacs, the Swiss army knife of text
> editors" <bug-gnu-emacs <at> gnu.org> writes:
>
>> with emacs -Q
>>
>> 1) 
>> M-x -> fido-mode
>> C-x C-f -> type "$HOME" -> enter opens dired buffer in $HOME directory
>> instead of continuing find-file $HOME to select a file to open
>
> Thanks, I reproduced this and will try to fix it.  Doesn't seem very
> hard, but we'll see.

I pushed a commit to master that should fix it. It's
45d711a356b4c5e75d0b6e4391313ca34f57b4bb, a very simple patch:

diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 03a191cb0b..08b4ef2030 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -331,7 +331,8 @@ icomplete-fido-ret
                    (file-name-directory (icomplete--field-string))))
          (current (car completion-all-sorted-completions))
          (probe (and dir current
-                     (expand-file-name (directory-file-name current) dir))))
+                     (expand-file-name (directory-file-name current)
+                                       (substitute-env-vars dir)))))
     (cond ((and probe (file-directory-p probe) (not (string= current "./")))
            (icomplete-force-complete))
           (t


Closing this bug, but I'll reopen if it ends up not doing what you
wanted.

João




Reply sent to João Távora <joaotavora <at> gmail.com>:
You have taken responsibility. (Sat, 05 Jun 2021 20:52:02 GMT) Full text and rfc822 format available.

Notification sent to simon254 <at> mailbox.org:
bug acknowledged by developer. (Sat, 05 Jun 2021 20:52:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48782; Package emacs. (Sun, 06 Jun 2021 08:43:04 GMT) Full text and rfc822 format available.

Message #27 received at submit <at> debbugs.gnu.org (full text, mbox):

From: simon254 <at> mailbox.org
To: João Távora <joaotavora <at> gmail.com>,
 "simon254--- via Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: 48782-done <at> debbugs.gnu.org
Subject: Re: bug#48782: 28.0.50; fido-mode: shell variables distort
 find-file behaviour
Date: Sun, 6 Jun 2021 09:01:27 +0100 (BST)
Thank you very much for looking at this! 

Now, if I type $HOM I get candidate $HOME, then I have to M-Tab to insert the candidate and type "/" to continue find-file in the directory, and then everything works as expected. This makes it now definitely usable for me! 

It might still be a bit confusing that in case of an environment variable which value is a directory, Enter does open dired instead of transversing into the directory with find-file (typing $HOM followed by Enter opens dired in home). But I don't know if changing this would be better or worse than the current behaviour after your fix - or possible at all.

Simon

> On 05/06/2021 21:51 João Távora <joaotavora <at> gmail.com> wrote:
> 
>  
> João Távora <joaotavora <at> gmail.com> writes:
> 
> > tag 48782 important
> > thanks
> >
> > simon254--- via "Bug reports for GNU Emacs, the Swiss army knife of text
> > editors" <bug-gnu-emacs <at> gnu.org> writes:
> >
> >> with emacs -Q
> >>
> >> 1) 
> >> M-x -> fido-mode
> >> C-x C-f -> type "$HOME" -> enter opens dired buffer in $HOME directory
> >> instead of continuing find-file $HOME to select a file to open
> >
> > Thanks, I reproduced this and will try to fix it.  Doesn't seem very
> > hard, but we'll see.
> 
> I pushed a commit to master that should fix it. It's
> 45d711a356b4c5e75d0b6e4391313ca34f57b4bb, a very simple patch:
> 
> diff --git a/lisp/icomplete.el b/lisp/icomplete.el
> index 03a191cb0b..08b4ef2030 100644
> --- a/lisp/icomplete.el
> +++ b/lisp/icomplete.el
> @@ -331,7 +331,8 @@ icomplete-fido-ret
>                     (file-name-directory (icomplete--field-string))))
>           (current (car completion-all-sorted-completions))
>           (probe (and dir current
> -                     (expand-file-name (directory-file-name current) dir))))
> +                     (expand-file-name (directory-file-name current)
> +                                       (substitute-env-vars dir)))))
>      (cond ((and probe (file-directory-p probe) (not (string= current "./")))
>             (icomplete-force-complete))
>            (t
> 
> 
> Closing this bug, but I'll reopen if it ends up not doing what you
> wanted.
> 
> João




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48782; Package emacs. (Sun, 06 Jun 2021 08:43:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48782; Package emacs. (Sun, 06 Jun 2021 16:17:01 GMT) Full text and rfc822 format available.

Message #33 received at submit <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: simon254 <at> mailbox.org
Cc: "simon254--- via Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
Subject: Re: bug#48782: 28.0.50;
 fido-mode: shell variables distort find-file behaviour
Date: Sun, 6 Jun 2021 17:16:29 +0100
[Message part 1 (text/plain, inline)]
On Sun, Jun 6, 2021, 09:01 <simon254 <at> mailbox.org> wrote:

> Thank you very much for looking at this!
>
> Now, if I type $HOM I get candidate $HOME, then I have to M-Tab to insert
> the candidate and type "/" to continue find-file in the directory, and then
> everything works as expected. This makes it now definitely usable for me!
>
> It might still be a bit confusing that in case of an environment variable
> which value is a directory, Enter does open dired instead of transversing
> into the directory with find-file (typing $HOM followed by Enter opens
> dired in home). But I don't know if changing this would be better or worse
> than the current behaviour after your fix - or possible at all.
>

May be possible. Is that what Ido does? I'll try in a couple of days, ping
me here if I forget.

João
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48782; Package emacs. (Mon, 07 Jun 2021 18:27:02 GMT) Full text and rfc822 format available.

Message #36 received at submit <at> debbugs.gnu.org (full text, mbox):

From: simon254 <at> mailbox.org
To: João Távora <joaotavora <at> gmail.com>
Cc: "simon254--- via Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Subject: Re: bug#48782: 28.0.50; fido-mode: shell variables distort
 find-file behaviour
Date: Mon, 7 Jun 2021 19:23:11 +0100 (BST)
great, will do!

off topic:

would also be nice to have some simple helper functions to go to the first and last match in case of fido-vertical-mode, something along the lines of

(defun icomplete-vertical-last-completions ()
  "Go to last completions entry..."
  (interactive)
  (let* ((beg (icomplete--field-beg))
         (end (icomplete--field-end))
         (comps (completion-all-sorted-completions beg end))
         (last (last comps)))
    (while (consp (cdr comps))
      (push (pop comps) icomplete--scrolled-past)
      (setq icomplete--scrolled-completions comps)
      (completion--cache-all-sorted-completions beg end comps))))

(defun icomplete-vertical-first-completions ()
  "Go to first completions entry..."
  (interactive)
  (let* ((beg (icomplete--field-beg))
         (end (icomplete--field-end))
         (comps (completion-all-sorted-completions beg end))
	 last-but-one)
    (while icomplete--scrolled-past
           (push (pop icomplete--scrolled-past) comps)
           (setq icomplete--scrolled-completions comps))
    (completion--cache-all-sorted-completions beg end comps)))


> On 06/06/2021 17:16 João Távora <joaotavora <at> gmail.com> wrote:
> 
> 
> On Sun, Jun 6, 2021, 09:01 <simon254 <at> mailbox.org> wrote:
> > Thank you very much for looking at this! 
> >  
> >  Now, if I type $HOM I get candidate $HOME, then I have to M-Tab to insert the candidate and type "/" to continue find-file in the directory, and then everything works as expected. This makes it now definitely usable for me! 
> >  
> >  It might still be a bit confusing that in case of an environment variable which value is a directory, Enter does open dired instead of transversing into the directory with find-file (typing $HOM followed by Enter opens dired in home). But I don't know if changing this would be better or worse than the current behaviour after your fix - or possible at all.
> 
> May be possible. Is that what Ido does? I'll try in a couple of days, ping me here if I forget.
> 
> João




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 06 Jul 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 294 days ago.

Previous Next


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