emacs-devel
[Top][All Lists]
Advanced

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

Re: pre-command-hook with input methods


From: Phillip Lord
Subject: Re: pre-command-hook with input methods
Date: Tue, 10 Feb 2015 14:09:51 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Stefan Monnier <address@hidden> writes:
>>> Maybe what you're after is just an input-event-hook?
>> I think for consistency, the hook should run immediately before or after
>> Emacs responds to C-u (or C-x) depending on whether it is pre- or post-.
>> Effectively, the C-x of a C-xC-f is, I think equivalent to the first "a"
>> of a "a`" post-fix input key sequence.  The only reason that the former
>> works fine for me, and the latter is problematic is the latter changes the
>> display of the buffer while the former changes just the mini-buffer.
>
> So it sounds like you'd indeed be happy with an input-event-hook.

I think so yes -- so long as input-event means "user input-event" or I
have some way of telling. Something coming in from a process, or
file-watch notifications need to be ignored.


>> The other possibility is not to have an interaction hook but to have a
>> "the buffer has just changed in some way that is liable to cause a
>> redisplay"-hook. I don't know that this would be better.  I throw it out
>> as a possibility, depending on which is easier.
>
> Then maybe the (new in 24.4) pre-redisplay-function could be used
> for that.  Something like
>
>     (add-function :before pre-redisplay-function
>                   (lambda (wins)
>                     (if (or (eq t wins)
>                             (memq <mybuffer> (mapcar #'window-buffer wins)))
>                         <take-foo-down>)))
>
> Of course, this will require some care, since a redisplay happens
> probably right after you've set things up (i.e. before you start
> waiting for user input), and you don't want *that* redisplay to trigger
> the <take-foo-down>.


Yes, that would be tricky. I'd probably have to ignore the first
redisplay after a completion has been offered. Also, my package does
idle cycle operations which include "sit-for" as a way of returning
control to the user. These trigger redisplay also which would be
unfortunate.

Probably they shouldn't do that. I *think* I added that so I could have
the idle-cycle operations add visible overlays for debugging purposes,
so the sit-for is necessary.

Still, it's there now, so I will give it a go. But having the
input-event-hook might be better.

Phil



reply via email to

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