emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 49e06183f5 1/3: Allow REQUIRE-MATCH to be a function


From: Stefan Monnier
Subject: Re: master 49e06183f5 1/3: Allow REQUIRE-MATCH to be a function
Date: Tue, 14 Jun 2022 08:44:58 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Lars Ingebrigtsen [2022-06-14 14:02:20] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> And in order not to have to understand them, you should move this code
>> out into its own function and call it in the same way that
>> `minibuffer-completion-confirm` is called (such that
>> `minibuffer-completion-confirm` can simply call this function to
>> reproduce that default behavior).
>
> Sorry; I don't follow.

The current code does more or less:

    (cond
     ((functionp minibuffer-completion-confirm)
      (funcall minibuffer-completion-confirm ...))
     <blabla>)

and we should change it to:

    (defun minibuffer-default-handle-completion-options (...)
      (cond
       <blabla>))

    [...]
    (funcall
      (if (functionp minibuffer-completion-confirm)
          minibuffer-completion-confirm
        #'minibuffer-default-handle-completion-options)
      ...)

so that we know for sure that `minibuffer-completion-confirm` can
reproduce the default behavior (i.e. that the API is not obviously
incomplete), simply by calling
`minibuffer-default-handle-completion-options`.

You don't need to understand the subtleties of <blabla>, because you
just move the code as-is and then the compiler will tell you if there's
a problem (typically because <blabla> uses vars from the context, which
you then need to pass as additional arguments).

[ For the same reason, most/all `<foo>-function` variables should
  ideally have a non-nil default value.  ]


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]