GNU bug report logs - #61221
30.0.50; [PATCH] Support completion of quoted variable refs in Eshell

Previous Next

Package: emacs;

Reported by: Jim Porter <jporterbugs <at> gmail.com>

Date: Thu, 2 Feb 2023 02:29:01 UTC

Severity: normal

Tags: patch

Found in version 30.0.50

Done: Jim Porter <jporterbugs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#61221: closed (30.0.50; [PATCH] Support completion of quoted
 variable refs in Eshell)
Date: Thu, 23 Feb 2023 22:13:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 23 Feb 2023 14:11:54 -0800
with message-id <dfc6502e-3f91-ef8f-2891-e3cab123b342 <at> gmail.com>
and subject line Re: bug#61221: 30.0.50; [PATCH] Support completion of quoted variable refs in Eshell
has caused the debbugs.gnu.org bug report #61221,
regarding 30.0.50; [PATCH] Support completion of quoted variable refs in Eshell
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
61221: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61221
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Jim Porter <jporterbugs <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; [PATCH] Support completion of quoted variable refs in Eshell
Date: Wed, 1 Feb 2023 18:28:08 -0800
[Message part 3 (text/plain, inline)]
X-Debbugs-Cc: monnier <at> iro.umontreal.ca

Eshell lets you put quotes around variable names so that the parser can 
tell where the name ends, sort of like ${var} in other shells:

  ~ $ echo $'user-login-name'-suffix
  user-suffix

  ~ $ echo $"user-login-name"-suffix
  user-suffix

However, you can't tab-complete variable names when you do this. Here's 
a fix. I also fixed a couple small issues with completing directory 
names where it would sometimes complete to "whatever/ ". That extra 
trailing space isn't helpful, since you'd have to delete it before 
typing in a subdir.

Probably the most controversial part of this patch is in #0002, where I 
added another dynamic variable 'pcomplete-exit-function' that Pcomplete 
handlers can set to tell Pcomplete what to do after exiting a 
completion. Maybe it would be better to have handlers throw some special 
value for 'pcomplete-completions' that contains this info (sort of like 
the value that a 'completion-at-point-function' returns). I'm not sure 
what the best (and most-compatible) way to do this would be...
[0001-Throw-strings-as-the-values-for-eshell-incomplete.patch (text/plain, attachment)]
[0002-Add-support-for-completing-quoted-variables-in-Eshel.patch (text/plain, attachment)]
[0003-Don-t-add-a-space-after-the-trailing-slash-when-comp.patch (text/plain, attachment)]
[Message part 7 (message/rfc822, inline)]
From: Jim Porter <jporterbugs <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 61221-done <at> debbugs.gnu.org
Subject: Re: bug#61221: 30.0.50; [PATCH] Support completion of quoted variable
 refs in Eshell
Date: Thu, 23 Feb 2023 14:11:54 -0800
On 2/23/2023 10:02 AM, Stefan Monnier via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> The patches look good, feel free to push, AFAIC.

Thanks, merged as 9d48c9844b.

>> +    (mapcar (lambda (x) (car x))
> 
> Aka (mapcar #'car

Fixed.

>> +      (setq pcomplete-stub (substring arg (match-beginning 1))
>> +            delimiter (match-string 2 arg))
> 
> You could let-bind `delimiter` here instead of let-binding it earlier
> and then `setq`ing it here.  Better for karma and marginally more
> efficient (avoids the creation of a `cons` cell to contain the value of
> the var).

Done.

>> +     (append (eshell-envvar-names)
>> +             (all-completions argname obarray 'boundp))
>> +     #'string-lessp)))
> 
> Since you use #' for `string-lessp`, it would make sense to use #' for
> `boundp` as well :-)

Fixed.

>> +                   ('lambda               ; test-completion
>> +                     (let ((result (test-completion string names pred)))
>> +                       (if (eq result t) string result)))
> 
> Hmm... why not just always return `result`?

As I understand it, returning 't' means "there is just one matching 
completion, and the match is exact"[1], but in this case, that's not 
really true: after completing "~user/" there are still more matching 
completions (the contents of the user's home directory).

This is really just trying to match what happens when calling 
'completion-file-name-table':

  (completion-file-name-table "~user/" nil nil)
    => "~user/"

  (try-completion "~user/" '("~user/") nil)
    => t

So if we get 't' from 'try-completion', we "downgrade" that to the 
original string.

[1] 
https://www.gnu.org/software/emacs/manual/html_node/elisp/Basic-Completion.html


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

Previous Next


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