From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: handa Newsgroups: gmane.emacs.devel Subject: Re: Tweaking quail input methods Date: Sun, 12 Mar 2017 00:14:00 +0900 Message-ID: <87pohnq213.fsf@gnu.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1489245268 15119 195.159.176.226 (11 Mar 2017 15:14:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 11 Mar 2017 15:14:28 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 11 16:14:25 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cmiiu-0003U8-2R for ged-emacs-devel@m.gmane.org; Sat, 11 Mar 2017 16:14:24 +0100 Original-Received: from localhost ([::1]:43734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmiiz-0007iH-VE for ged-emacs-devel@m.gmane.org; Sat, 11 Mar 2017 10:14:30 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmiiu-0007iA-2d for emacs-devel@gnu.org; Sat, 11 Mar 2017 10:14:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cmiiq-0002AE-Td for emacs-devel@gnu.org; Sat, 11 Mar 2017 10:14:24 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46021) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmiih-00025B-7r; Sat, 11 Mar 2017 10:14:11 -0500 Original-Received: from fl1-125-197-241-176.iba.mesh.ad.jp ([125.197.241.176]:42018 helo=shatin) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1cmiig-0006ck-Me; Sat, 11 Mar 2017 10:14:11 -0500 Original-Received: from handa by shatin with local (Exim 4.86_2) (envelope-from ) id 1cmiiW-0005eg-JO; Sun, 12 Mar 2017 00:14:00 +0900 In-Reply-To: (message from Stefan Monnier on Wed, 08 Mar 2017 12:36:00 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:212905 Archived-At: In article , Stefan Monnier 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 to prefix (e.g. move all entries > of the form "_" so they use "\\_" 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