unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Mendler via "Emacs development discussions." <emacs-devel@gnu.org>
To: Eshel Yaron <me@eshelyaron.com>
Cc: Juri Linkov <juri@linkov.net>,
	 Stefan Kangas <stefankangas@gmail.com>,
	emacs-devel@gnu.org
Subject: Re: Possible minibuffer completion enhancements
Date: Tue, 23 Jan 2024 09:08:01 +0100	[thread overview]
Message-ID: <87r0i8iiam.fsf@daniel-mendler.de> (raw)
In-Reply-To: <m1jzo14kcr.fsf@eshelyaron.com> (Eshel Yaron's message of "Mon, 22 Jan 2024 13:35:00 +0100")

Eshel Yaron <me@eshelyaron.com> writes:

> Eshel Yaron <me@eshelyaron.com> writes:
>
>> Daniel Mendler <mail@daniel-mendler.de> writes:
>>
>>> ...the implementation of completion-table-with-metadata I've seen in
>>> Eshel's branch did not seem correct. The function should be simpler:
>>
>> Hmm, define "correct" and "should" :)
>> My implementation is indeed more sophisticated, since it does more.  In
>> particular, it lets you override some metadata while preserving other
>> metadata that come from the original table.  Could you elaborate about
>> how this simplified version is preferable in your opinion?
>>
>>> (defun completion-table-with-metadata (table metadata)
>>>   (lambda (str pred action)
>>>     (if (eq action 'metadata)
>>>         `(metadata ,@metadata
>>>                    ,@(and (functionp table)
>>>                           (cdr (funcall table str pred action))))
>>>       (complete-with-action action table str pred))))
>
> On second thought, your version should indeed work just as well as mine,
> expect that my implementation also allows the extra metadata to be
> computed just in time.  In the common case where the metadata is
> computed ahead of time, both versions basically behave the same, right?

Indeed. Your `completion-table-with-metadata' function allows to compute
the metadata on the fly. Are there use cases for this? From my
experience the completion table metadata is mostly static, except in
cases where completion table boundaries are used. But in that case a
simple helper like `completion-table-with-metadata' seems to too limited
anyway?

The above function can be adapted as follows if a dynamic
recomputation feature is desirable:

(defun completion-table-with-metadata (table metadata)
  (lambda (str pred action)
    (if (eq action 'metadata)
        `(metadata ,@(if (functionp metadata)
                         (funcall metadata str pred)
                       metadata)
                   ,@(and (functionp table)
                          (cdr (funcall table str pred action))))
      (complete-with-action action table str pred))))

Daniel



  reply	other threads:[~2024-01-23  8:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-14 17:28 Possible minibuffer completion enhancements Eshel Yaron
2024-01-15 12:19 ` Eli Zaretskii
2024-01-16 13:47   ` Eshel Yaron
2024-01-16 14:10     ` Eli Zaretskii
2024-01-17 18:57       ` Eshel Yaron
2024-01-15 21:35 ` Stefan Kangas
2024-01-16 13:58   ` Eshel Yaron
2024-01-16 22:44     ` Stefan Kangas
2024-01-17 19:17       ` Eshel Yaron
2024-01-17 21:17         ` Stefan Kangas
2024-01-19 12:31           ` Eshel Yaron
2024-01-21  9:03             ` Eshel Yaron
2024-01-21 11:04               ` Daniel Mendler via Emacs development discussions.
2024-01-21 14:49                 ` Eshel Yaron
2024-01-22  7:50               ` Juri Linkov
2024-01-22  8:12                 ` Daniel Mendler via Emacs development discussions.
2024-01-22 12:18                   ` Eshel Yaron
2024-01-22 12:35                     ` Eshel Yaron
2024-01-23  8:08                       ` Daniel Mendler via Emacs development discussions. [this message]
2024-01-22 20:31                     ` Daniel Mendler via Emacs development discussions.
2024-01-23  7:04                       ` Eshel Yaron
2024-01-23  8:00                         ` Daniel Mendler via Emacs development discussions.
2024-01-23 16:23                           ` Eshel Yaron
2024-01-23 18:32                             ` Daniel Mendler via Emacs development discussions.
2024-01-24  2:32                   ` Madhu
2024-01-22 21:11               ` Philip Kaludercic
2024-01-23  7:33                 ` Eshel Yaron

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=87r0i8iiam.fsf@daniel-mendler.de \
    --to=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    --cc=mail@daniel-mendler.de \
    --cc=me@eshelyaron.com \
    --cc=stefankangas@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).