[Top][All Lists]

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

Re: [Emacs-diffs] master 7b31de4: Add hook for all events

From: Phillip Lord
Subject: Re: [Emacs-diffs] master 7b31de4: Add hook for all events
Date: Thu, 24 Jan 2019 10:41:18 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.91 (gnu/linux)

Stefan Monnier <address@hidden> writes:
>> The problem is that company uses pre-command-hook to remove old offered
>> completions. But self-insert hasn't run yet, because the user hasn't
>> decided whether to type "e" or "e'". With this hook, I can pick up the
>> intermediate keypresses.
> So, IIUC the issue is to detect when to pop down the completions offered
> by the likes of company/pabbrev/...
> And the idea is that those packages can stop using pre-command-hook and
> use input-event-functions.

I'm currently using both pre-command and input-event but yes, you are
probably correct I wouldn't need pre-command any more.

Currently, I am doing this:

(defun pabbrev-input-event-functions (event)
  "Remove offering expansion from buffer on events.

This function is normally run off `input-event-functions'. It
main purpose is to remove completions during multi-keystroke
keyboard events associated with many input methods. These do not
signal a pre-command-hook because the command only completes when
they are unambiguously complete."
   ((mouse-movement-p event) nil)
> So, IIUC now company will pop down its menu as soon as you hit a prefix
> key like C-x or C-c, right?  Is that a desirable or undesirable
> side-effect?

Yes, I think it would do that. I don't know if this is desirable or
not. I will have to try it. I expect it is a difference most people
wouldn't see.

It also has a practical impact; it is not possible to complete when an
input method is in the middle of the multi key press. So, for example,
with italian-postfix you can no longer complete on a prefix ending in
an "e" or and "i"; pressing "e" removes completion suggestions, but does
not trigger adding them because "e" could be "e`".

> I guess the previously available alternative was to use sit-for to wait
> for the next event, right (and indeed, I think input-event-functions is
> a better option than sit-for)?

Well, you should find it better; this hook is your code (I stole it from
a patch you sent in 2015). Sit-for, yes, would be a possibility, that I
hadn't thought off; you'd still need to filter the event using
`last-input-event' I guess. That would be a way of fixing company and
pabbrev in current Emacs. I will investigate.


reply via email to

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