unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Michalis V." <mvar.40k@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: "Michalis V." <mvar.40k@gmail.com>,
	Samer Masterson <nosefrog@gmail.com>,
	19626@debbugs.gnu.org
Subject: bug#19626: 25.0.50; eshell: extended directory syntax ("...") does not complete
Date: Fri, 27 Aug 2021 18:28:16 +0300	[thread overview]
Message-ID: <87sfyu29gv.fsf@cnu407c2zx.nsn-intra.net> (raw)
In-Reply-To: <87czq1lqk1.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 25 Aug 2021 13:19:42 +0200")

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

Lars Ingebrigtsen <larsi@gnus.org> writes:

> "Michalis V." <mvar.40k@gmail.com> writes:
>
>> i cannot reproduce this in 28.0.50. Basically what i did was
>>
>> mkdir ...
>>
>> then repeat the steps above. Eshell autocompletes .../ fine, even adding
>> another similar directory will bring up the dialog:
>
> I think eshell has an "extended directory" concept where "..." is
> supposed to expand to (I think) all parent directories?  So there isn't
> supposed to be any directory literally called "...".
>
> I think.  But I'm not overly familiar with eshell.  Let's see...  Yup:
>
> (defun eshell-expand-multiple-dots (filename)
>   "Convert `...' to `../..', `....' to `../../..', etc..

oops, i wasn't even aware of this eshell feature, sorry about that!

I did some debugging into how completion works and it looks like
eshell-complete-parse-arguments in em-cmpl.el is responsible for
parsing the arguments before passing them to the generic(?) completion
code. Attached is a patch that adds an additional check at the end of
said defun that will substitute any .../ dots into the proper expanded
form before returning. There are some other defuns that are called by
eshell-complete-parse-arguments, namely eshell-parse-argument(s) but i
*think* this substitution is better suited (read: safer) to be placed to
their caller.
Note that this works for "cd .../", completion for other operations like
cp do not work currently (most probably because cd has its own
implementation in eshell/cd?)

i'm not sure whether this is the correct solution to this problem so if
there are any concerns please let me know and i'll continue the digging

thanks,
Michalis


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: em-cmpl.patch --]
[-- Type: text/x-patch, Size: 822 bytes --]

diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index cbfe0b8154..2352dac7e7 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -377,8 +377,12 @@ eshell-complete-parse-arguments
                           (cl-assert (eq (car result) 'quote))
                           (cadr result))
                       arg)))
-               (if (numberp val)
-                   (setq val (number-to-string val)))
+               (cond ((numberp val)
+                      (setq val (number-to-string val)))
+                     ;; expand .../ etc that only eshell understands to
+                     ;; standard ../../
+                     ((string-match "\\.\\.\\.+/" val)
+                      (setq val (eshell-expand-multiple-dots val))))
                (or val "")))
 	   args)
 	  posns)))

  reply	other threads:[~2021-08-27 15:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19 11:19 bug#19626: 25.0.50; eshell: extended directory syntax ("...") does not complete Samer Masterson
2021-08-25  9:10 ` Michalis V.
2021-08-25 11:19   ` Lars Ingebrigtsen
2021-08-27 15:28     ` Michalis V. [this message]
2021-08-27 16:47       ` Lars Ingebrigtsen

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=87sfyu29gv.fsf@cnu407c2zx.nsn-intra.net \
    --to=mvar.40k@gmail.com \
    --cc=19626@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=nosefrog@gmail.com \
    /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).