unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: handa <handa@gnu.org>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: Tweaking quail input methods
Date: Sun, 12 Mar 2017 00:14:00 +0900	[thread overview]
Message-ID: <87pohnq213.fsf@gnu.org> (raw)
In-Reply-To: <jwvefy71xwp.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Wed, 08 Mar 2017 12:36:00 -0500)

In article <jwvefy71xwp.fsf-monnier+emacs@gnu.org>, Stefan Monnier <monnier@IRO.UMontreal.CA> 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
handa@gnu.org



  reply	other threads:[~2017-03-11 15:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-08 17:36 Tweaking quail input methods Stefan Monnier
2017-03-11 15:14 ` handa [this message]
2017-09-24 13:36 ` Greg Minshall
2017-09-30 11:49   ` Eli Zaretskii
2017-10-15 10:42     ` Greg Minshall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pohnq213.fsf@gnu.org \
    --to=handa@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).