emacs-devel
[Top][All Lists]
Advanced

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

Re: 27.0.50: How can I test a buffer-local window-configuration-change-h


From: Phil Sainty
Subject: Re: 27.0.50: How can I test a buffer-local window-configuration-change-hook in batch mode?
Date: Fri, 25 Oct 2019 23:31:33 +1300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 25/10/19 9:37 PM, Eli Zaretskii wrote:
>> * window-configuration-change-hook
>> * window-size-change-functions
>>
>> AFAICS the latter cannot be invoked from lisp?
>
> Why not?

Hmmm.  It's no longer clear to me.  I'd assumed from the existence
of the C wrapper function that it *required* a wrapper function
(and, as no lisp wrapper existed, that it could therefore only be
used in C).  run_window_size_change_functions() does more than just
`run-hook-with-args' at any rate, so maybe it's inadvisable to run
it without the wrapper, but I don't really know.



> they are just Lisp functions, so you can invoke them from
> Lisp as usual, no?

I guess I'm equating "can" with "should" here.  If a hook is normally
called via a wrapper, and that wrapper does more than just the usual
`run-hooks' behaviours, then I'm assuming that the only correct way
to call the hook is using the wrapper -- which, in this instance, was
not exposed to lisp.



> I don't know why Martin needed run-window-configuration-change-hook,
> it doesn't seem to be called anywhere in Emacs.

Well the underlying run_window_configuration_change_hook (as opposed
to simply using `run-hooks') is needed because this doesn't behave
like a typical hook at all.

The global value is run once with the modified frame selected;
and then, for EACH window of that frame, if the window's buffer
has a buffer-local value for the hook then that local value is
run with that window selected.  So multiple buffer-local values
could be triggered by a single run of this hook (not necessarily
including the current buffer).

Exposing it to lisp as `run-window-configuration-change-hook' might
be a hold-over from versions prior to 27 -- in 26.3 it is called
many times from window.el.  In 27 the lisp function is no longer
used (except in my new test code, so I'm glad that it still remains).



> But in general, I see no reason why we would expect a hook to be
> callable from Lisp via some wrapper, as opposed to directly, what
> would be the use case for that?

As above, it behaves unusually for a hook, so the use-case is simply
any lisp code which needs to run that hook, because `run-hooks'
isn't going to do the trick for this one.



>> However the only *calls* to 'run_window_size_change_functions' in
>> Emacs 26.3 are in xdisp.c -- so I'm presuming this hook was already
>> untestable in batch mode?
>
> "Untestable" in what sense?  If you mean a test that would make sure
> the hook is called under some specific situations related to display,
> then we are back to the problem that the display code does nothing in
> batch mode.

Yes, that's all I meant -- that it's not possible to write a batch mode
test which relies upon `window-size-change-functions' being triggered
by Emacs in the usual way, when "the usual way" is via redisplay, and
redisplay isn't doing anything.



>> +As 'window-configuration-change-hook' is now invoked by redisplay,
>> +existing tests relying on it may fail.  Adding a call to 'redisplay'
>> +is sufficient for interactive test runs; but for batch mode you will
>> +need to run the hook explicitly, as 'redisplay' has no effect:
>> +
>> +  (unless (version< emacs-version "27")
>> +    (redisplay)
>> +    (when noninteractive
>> +      (run-window-configuration-change-hook)))
>
> I think the example is too much for NEWS, and is also a bit
> misleading, per the above discussion.

See above, I guess, if you're referring here to whether or not
`run-window-configuration-change-hook' should exist?



> I'd also suggest to make the text more general, because
> window-configuration-change-hook is not the only hook/feature
> affected by this issue.

I think it is?  My suggested addition to this specific NEWS item is
purely about flagging a potential backwards-incompatibility, and this
is the only hook out of the original two which is affected in this way
(because `window-size-change-functions' was already run only by
redisplay).

The other four hooks are new to 27, so no backwards-incompatibility
issues can exist for them.


-Phil




reply via email to

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