unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43925: 28.0.50; fido-mode can't find-file further back than ~/
@ 2020-10-11 15:30 Rasmus
  2021-06-11 23:07 ` João Távora
  0 siblings, 1 reply; 4+ messages in thread
From: Rasmus @ 2020-10-11 15:30 UTC (permalink / raw)
  To: 43925

[-- Attachment #1: Type: text/plain, Size: 1846 bytes --]

Hi,

I am trying to replace ido with fido.

One heuristic that I miss from ido is the ability to easily get to 
root via find(ing)-file.

In particular, from emacs -q, I might do something like this

    (let ((default-directory "~/")) 
      (fido-mode) (call-interactively 'find-file) ;; click 
      <backspace><backspace> to get to root )

Being an ido-user, I would expect to be able to go to /home/ by 
clicking backspace and then to root.  But I doesn’t work with 
fido.

I don’t know if I have missed some obvious configuration-step 
here?  I looked through the customization groups of both icomplete 
and minibuffer.

The attached patch expand the file-name if it is “~/”.

I am not really familiar with this part of Emacs so I am not sure 
it’s the right way to go about it.  In particular, I am really not 
sure whether the internal functions (e.g. ‘icomplete--field-beg’) 
are used correctly.


Aside: Another annoyance with fido is that $HOME isn’t being 
abbreviated
to “~” when browsing from root.  E.g.
 
    (let ((default-directory "/home/")) 
      (fido-mode) (call-interactively 'find-file) ;; now select 
      your username ) 

I would like “/home/$USER” to be abbreviated to “~” (like ido) to 
conserve space.

Any ideas as to where such a change migh be injected to fido?  I 
didn’t see an obvious place.

Thanks in advance,
Rasmus

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 
3.24.23, cairo version 1.17.3) 
 of 2020-10-06 built on X260 
Repository revision: d36cfa21b6b695862dae772a94c63ce3aca8467e 
Repository branch: makepkg Windowing system distributor 'The X.Org 
Foundation', version 11.0.12009000 System Description: Arch Linux 

-- 
Tack, ni svenska vakttorn. Med plutonium tvingar vi dansken på 
knä!

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-icomplete.el-icomplete-fido-backward-updir-Expa.patch --]
[-- Type: text/x-patch, Size: 1577 bytes --]

From fbf036230d092b4a1e5f7dadd3bf7ad0dea47ed4 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Sun, 11 Oct 2020 13:54:20 +0200
Subject: [PATCH] * lisp/icomplete.el (icomplete-fido-backward-updir): Expand
 "~/"

---
 lisp/icomplete.el | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 4e546807b7..1687404eef 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -312,13 +312,17 @@ icomplete-fido-exit
 (defun icomplete-fido-backward-updir ()
   "Delete char before or go up directory, like `ido-mode'."
   (interactive)
-  (if (and (eq (char-before) ?/)
-           (eq (icomplete--category) 'file))
-      (save-excursion
-        (goto-char (1- (point)))
-        (when (search-backward "/" (point-min) t)
-          (delete-region (1+ (point)) (point-max))))
-    (call-interactively 'backward-delete-char)))
+  (cond ((and (eq (char-before) ?/)
+              (eq (icomplete--category) 'file))
+         (when (string-equal (icomplete--field-string) "~/")
+           (delete-region (icomplete--field-beg) (icomplete--field-end))
+           (insert (expand-file-name "~/"))
+           (goto-char (line-end-position)))
+         (save-excursion
+           (goto-char (1- (point)))
+           (when (search-backward "/" (point-min) t)
+             (delete-region (1+ (point)) (point-max)))))
+        (t (call-interactively 'backward-delete-char))))

 (defvar icomplete-fido-mode-map
   (let ((map (make-sparse-keymap)))
--
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#43925: 28.0.50; fido-mode can't find-file further back than ~/
  2020-10-11 15:30 bug#43925: 28.0.50; fido-mode can't find-file further back than ~/ Rasmus
@ 2021-06-11 23:07 ` João Távora
  2021-11-12  8:03   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: João Távora @ 2021-06-11 23:07 UTC (permalink / raw)
  To: Rasmus; +Cc: 43925

Rasmus <rasmus@gmx.us> writes:

> Hi,
>
> I am trying to replace ido with fido.
>
> One heuristic that I miss from ido is the ability to easily get to
> root via find(ing)-file.
>
> In particular, from emacs -q, I might do something like this
>
>    (let ((default-directory "~/"))       (fido-mode)
>    (call-interactively 'find-file) ;; click
>    <backspace><backspace> to get to root )
>
> Being an ido-user, I would expect to be able to go to /home/ by
> clicking backspace and then to root.  But I doesn’t work with fido.
>
> I don’t know if I have missed some obvious configuration-step here?  I
> looked through the customization groups of both icomplete and
> minibuffer.
>
> The attached patch expand the file-name if it is “~/”.
>
> I am not really familiar with this part of Emacs so I am not sure it’s
> the right way to go about it.  In particular, I am really not sure
> whether the internal functions (e.g. ‘icomplete--field-beg’) are used
> correctly.
>
>
> Aside: Another annoyance with fido is that $HOME isn’t being
> abbreviated
> to “~” when browsing from root.  E.g.
>
>    (let ((default-directory "/home/"))       (fido-mode)
>    (call-interactively 'find-file) ;; now select       your username )
>    I would like “/home/$USER” to be abbreviated to “~” (like ido) to
>    conserve space.
>
> Any ideas as to where such a change migh be injected to fido?  I
> didn’t see an obvious place.
>
> Thanks in advance,
> Rasmus

Thanks for the report and sorry for the long delay.  Indeed it would be
nice to have this in fido.  I remember this behaviour in ido, too.  I've
tried your patch and I don't have anything against it, so feel free to
push it if you want.  The second idea is also welcome, but I don't know
where to put it either.  Maybe in a fido-specific post-command hook that
adds the string "~/" to the input.  Then the current "rfn-shadow"
behaviour in icomplete.el would do the rest.

João






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#43925: 28.0.50; fido-mode can't find-file further back than ~/
  2021-06-11 23:07 ` João Távora
@ 2021-11-12  8:03   ` Lars Ingebrigtsen
  2021-11-13 11:08     ` bug#43925: " Rasmus
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-11-12  8:03 UTC (permalink / raw)
  To: João Távora; +Cc: 43925, Rasmus

João Távora <joaotavora@gmail.com> writes:

> Thanks for the report and sorry for the long delay.  Indeed it would be
> nice to have this in fido.  I remember this behaviour in ido, too.  I've
> tried your patch and I don't have anything against it, so feel free to
> push it if you want.

Since João approved the patch, I've pushed it to Emacs 29 now.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#43925: fido-mode can't find-file further back than ~/
  2021-11-12  8:03   ` Lars Ingebrigtsen
@ 2021-11-13 11:08     ` Rasmus
  0 siblings, 0 replies; 4+ messages in thread
From: Rasmus @ 2021-11-13 11:08 UTC (permalink / raw)
  To: larsi; +Cc: 43925, joaotavora

Lars Ingebrigtsen <larsi@gnus.org> writes:

> João Távora <joaotavora@gmail.com> writes:
>
>> Thanks for the report and sorry for the long delay.  Indeed it would be
>> nice to have this in fido.  I remember this behaviour in ido, too.  I've
>> tried your patch and I don't have anything against it, so feel free to
>> push it if you want.
>
> Since João approved the patch, I've pushed it to Emacs 29 now.

Thanks, Lars, I don’t seem to have push access to savannah any more; maybe
due to inactivity...

Forgot to reply to the João’s email after I discovered I didn’t have push access.

Rasmus 

-- 
Enough with the blah blah!





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-13 11:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-11 15:30 bug#43925: 28.0.50; fido-mode can't find-file further back than ~/ Rasmus
2021-06-11 23:07 ` João Távora
2021-11-12  8:03   ` Lars Ingebrigtsen
2021-11-13 11:08     ` bug#43925: " Rasmus

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).