emacs-devel
[Top][All Lists]
Advanced

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

Re: Timing of input-method output


From: Phillip Lord
Subject: Re: Timing of input-method output
Date: Mon, 25 Mar 2019 21:48:23 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.92 (gnu/linux)

Stefan

I've done a bit more work on this and come up with a much simpler
solution which is specificially plumbed into quail. It looks like this:


modified   lisp/international/quail.el
@@ -59,6 +59,10 @@ quail
   "Quail: multilingual input method."
   :group 'leim)
 
+
+(defvar quail-pre-translation-hook nil
+  "Normal hook run before quail starts or updates a translation.")
+
 ;; Buffer local variables
 
 (defvar quail-current-package nil
@@ -1548,6 +1552,7 @@ quail-update-translation
 `quail-current-key'.  If CONTROL-FLAG is nil, proceed the translation
 with more keys."
   (let ((func (quail-update-translation-function)))
+    (run-hooks 'quail-pre-translation-hook)
     (if func
        (setq control-flag (funcall func control-flag))
       (cond ((numberp control-flag)



pabbrev.el uses this very simply like so:

    (add-hook 'quail-pre-translation-hook 'pabbrev-pre-command-hook nil t)
    (add-hook 'pre-command-hook 'pabbrev-pre-command-hook nil t)
    (add-hook 'post-command-hook 'pabbrev-post-command-hook nil t)

pabbrev-pre-command-hook was always badly named (since it's the function
to go on a hook, not a variable defining a hook), and is now
worse. Basically, we just run the "remove the abbreviation expansion
which is being offered in readiness for a command to run".

So, a couple of questions:

pre-command-hook is current run by "safe_run_hooks". Does
`quail-pre-translation-hook' need to be as well (in which case, it would
need uncovering in lisp)? I guess the counter here is that it's possible
to get out so long as you don't type certain characters, or you change
buffer. But, it leaves emacs fairly unusuable none the less.

And, where do you think I should document it? Perhaps "Invoking the
Input Method"; but "Command Loop Overview" is the place where the people
who might want to use it might actually see it?

Phil



reply via email to

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