emacs-devel
[Top][All Lists]
Advanced

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

Re: master a7c65fc666: Allow nil value for filter-buffer-substring-funct


From: Stefan Monnier
Subject: Re: master a7c65fc666: Allow nil value for filter-buffer-substring-function
Date: Tue, 20 Sep 2022 09:23:53 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Robert Pluim [2022-09-20 10:08:19] wrote:
>>>>>> On Mon, 19 Sep 2022 16:37:04 -0400, Stefan Monnier 
>>>>>> <monnier@iro.umontreal.ca> said:
>
>     >> Ick. If `buffer-substring--filter' is the default function to call, it
>     >> should not have the '--' internal function marker.
>
>     Stefan> Why?  You're *not* supposed to call `buffer-substring--filter'.
>     Stefan> Instead you're supposed to call the value contained in
>     Stefan> `filter-buffer-substring-function`, whichever it is.  (and if 
> you're
>     Stefan> modifying this variable, then you're supposed to modify it with
>     Stefan> `add-function` and your function will then receive the "previous"
>     Stefan> function to call).
>
> Itʼs not obvious to me that youʼre supposed to use `add-function'. And
> even if it were, having '--' appear in the public api just feels
> wrong. Oh well.

It's not the public API.
The public API is to call the value that's stored in the variable,
whatever that value is.

Look at it this way.  The choice is between:

    (defvar foo-function (lambda () ...blabla...))

vs

    (defvar foo-function #'foo--default)
    (defun foo--default ()
      ...blabla...)

In both cases the actual function is "internal".  The second version
just gives a name to the function because it's more convenient, hiding
a bit more of the internals, and making it possible to use `C-h o` to
jump to the definition of the function.

The "--" version makes it *possible* to call that function directly, but
it still *shouldn't* be called directly: it's still very much internal.


        Stefan




reply via email to

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