emacs-devel
[Top][All Lists]
Advanced

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

Re: Tweaking quail input methods


From: handa
Subject: Re: Tweaking quail input methods
Date: Sun, 12 Mar 2017 00:14:00 +0900

In article <address@hidden>, Stefan Monnier <address@hidden> writes:

> Is there a way for the end-user to tweak a quail input method?
> I like to use the TeX input method and could almost live with it being
> always enabled, except for some of its mappings which sometimes get in
> the way.  So I'd like to either define a new input method derived from
> TeX, or to tweak the TeX input method.

You can use quail-active-hook to modify a specific input method as
this:

(defun TeX-input-method-tweaked nil)

(defun my-quail-activate-hook ()
  (when (and (not TeX-input-method-tweaked)
             (string= (quail-name) "TeX"))
    ;; code for tweaking TeX input method.
    ;; ...
    (setq TeX-input-method-tweaked t)))
       
(add-hook 'quail-activate-hook 'my-quail-activate-hook)

> The kind of changes I'd like to apply are things like:
> - eliminate all mappings that start with a particular prefix

You can modify the keymap returned by (quail-translation-keymap).
For instance, if you want to disable all mappints starting with "\\",
call this in my-quail-activate-hook:

(define-key (quail-translation-keymap) "\\" 'self-insert-command)

> - add a few mappings

Call something like this in my-quail-activate-hook:

(quail-defrule "\\hline" ["------------------------"])

> - move mapping from prefix <foo> to prefix <bar> (e.g. move all entries
>   of the form "_<something>" so they use "\\_<something>" instead).

It is possible but you must modify the internal structure of a Quail map.
For instance, the Quail map of an input method have only these maps:
  "a" -> "X"
  "ab" -> "Y"
  "abc" -> "Z" or "z"
  "b" -> "W"
is like the folloinw list:
  (nil (?b ["w"]) (?a ["x"] (?b ["y"] (?c ("z" "Z")))))
So, if you want to change the prefix "a" to "A", you must modify the
list to:
  (nil (?b ["w"]) (?A ["x"] (?b ["y"] (?c ("z" "Z")))))

And, this works only for such "simple" input method that does not use
dynamic rules (i.e. TRANSLATION of quail-defrule is a cons).  It seems
that TeX is "simple" input method.

---
K. Handa
address@hidden



reply via email to

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