unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Tweaking quail input methods
@ 2017-03-08 17:36 Stefan Monnier
  2017-03-11 15:14 ` handa
  2017-09-24 13:36 ` Greg Minshall
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Monnier @ 2017-03-08 17:36 UTC (permalink / raw)
  To: emacs-devel

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.

The kind of changes I'd like to apply are things like:
- eliminate all mappings that start with a particular prefix
- add a few mappings
- move mapping from prefix <foo> to prefix <bar> (e.g. move all entries
  of the form "_<something>" so they use "\\_<something>" instead).

I looked at quail.el but can't seem to find anything that would let me
do that.


        Stefan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tweaking quail input methods
  2017-03-08 17:36 Tweaking quail input methods Stefan Monnier
@ 2017-03-11 15:14 ` handa
  2017-09-24 13:36 ` Greg Minshall
  1 sibling, 0 replies; 5+ messages in thread
From: handa @ 2017-03-11 15:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tweaking quail input methods
  2017-03-08 17:36 Tweaking quail input methods Stefan Monnier
  2017-03-11 15:14 ` handa
@ 2017-09-24 13:36 ` Greg Minshall
  2017-09-30 11:49   ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Greg Minshall @ 2017-09-24 13:36 UTC (permalink / raw)
  To: emacs-devel

hi.  my question is similar to Stefan's (of many months ago), at least
in being related to re-using quail.

i would like to add an Azerbaijani Cyrillic input method.  95% of this
method is the same as, e.g., "russian-computer".

is there an obvious way to "subclass" an existing method?  i notice (in
leim/quail/cyrillic.el), for example, that "russian-computer" doesn't
"subclass" "russian-typewriter" (though they share much).

i could do something like cyrillic.el does for "cyrillic-jcuken", i.e.,
capture the entire "russian-computer" under a new name, then use
quail-active-hook (suggested by K. Handa) to add some modifications.
when ever "azerbaijani-cyrillic" is activated.  but, that seems a bit
convoluted (but, maybe is what i should do?).

cheers, Greg



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tweaking quail input methods
  2017-09-24 13:36 ` Greg Minshall
@ 2017-09-30 11:49   ` Eli Zaretskii
  2017-10-15 10:42     ` Greg Minshall
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2017-09-30 11:49 UTC (permalink / raw)
  To: Greg Minshall; +Cc: emacs-devel

> From: Greg Minshall <minshall@acm.org>
> Date: Sun, 24 Sep 2017 16:36:47 +0300
> 
> hi.  my question is similar to Stefan's (of many months ago), at least
> in being related to re-using quail.
> 
> i would like to add an Azerbaijani Cyrillic input method.  95% of this
> method is the same as, e.g., "russian-computer".
> 
> is there an obvious way to "subclass" an existing method?  i notice (in
> leim/quail/cyrillic.el), for example, that "russian-computer" doesn't
> "subclass" "russian-typewriter" (though they share much).
> 
> i could do something like cyrillic.el does for "cyrillic-jcuken", i.e.,
> capture the entire "russian-computer" under a new name, then use
> quail-active-hook (suggested by K. Handa) to add some modifications.
> when ever "azerbaijani-cyrillic" is activated.  but, that seems a bit
> convoluted (but, maybe is what i should do?).

I think you should just copy the rules of russian-computer and modify
whatever you need for the Azerbaijani Cyrillic input method.

Thanks.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tweaking quail input methods
  2017-09-30 11:49   ` Eli Zaretskii
@ 2017-10-15 10:42     ` Greg Minshall
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Minshall @ 2017-10-15 10:42 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

hi, Eli,

> I think you should just copy the rules of russian-computer and modify
> whatever you need for the Azerbaijani Cyrillic input method.

thanks for the reply.  yes, that's basically what i've done.  but, it
seems a shame (sort of a "first-normal-form violation") to not be able
to re-use, pick up random tweaks.  for example, i'd like to have two
Turkish input methods, one for people used to Turkish keyboards (where
the letter in the 'i' position has no dot over it), and one for people
used to getting the dot over the i (and willing to type an introducer to
get the i without the dot).  it would be nice to define one as the
"tweak" on the other.

anyway, it all works, and i'm reasonably happy.

cheers, Greg



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-15 10:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-08 17:36 Tweaking quail input methods Stefan Monnier
2017-03-11 15:14 ` handa
2017-09-24 13:36 ` Greg Minshall
2017-09-30 11:49   ` Eli Zaretskii
2017-10-15 10:42     ` Greg Minshall

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).