From: Jim Porter <jporterbugs@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 61221-done@debbugs.gnu.org
Subject: bug#61221: 30.0.50; [PATCH] Support completion of quoted variable refs in Eshell
Date: Thu, 23 Feb 2023 14:11:54 -0800 [thread overview]
Message-ID: <dfc6502e-3f91-ef8f-2891-e3cab123b342@gmail.com> (raw)
In-Reply-To: <jwvy1ooff6n.fsf-monnier+emacs@gnu.org>
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
next prev parent reply other threads:[~2023-02-23 22:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 2:28 bug#61221: 30.0.50; [PATCH] Support completion of quoted variable refs in Eshell Jim Porter
2023-02-05 15:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-23 6:42 ` Jim Porter
2023-02-23 18:02 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-23 22:11 ` Jim Porter [this message]
2023-02-23 22:39 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-23 23:17 ` Jim Porter
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=dfc6502e-3f91-ef8f-2891-e3cab123b342@gmail.com \
--to=jporterbugs@gmail.com \
--cc=61221-done@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/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).