emacs-devel
[Top][All Lists]
Advanced

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

Re: Is there a way to create an input method based on another one?


From: Stefan Monnier
Subject: Re: Is there a way to create an input method based on another one?
Date: Thu, 28 Feb 2013 10:58:21 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> I would like to create my own input method that’s an extension of an
> existing one (rfc1345).  As far as I can tell from reading the source,
> the “public” (undocumented) API seems to be quail-define-package
> followed by quail-define-rules, which seems to be unable to
> accommodate my desires.

Indeed, this kind of functionality is missing :-(
I'd welcome a patch the lets one combine input methods.
I did take a crack at it at some distant point in the past, but
I didn't go very far.  Here's the result:

(defun quail-merge-maps (map1 &rest maps)
  (if (null maps) map1
    (let* ((map2 (pop maps))
           (h1 (pop map1))
           (h2 (pop map2)))
      (apply 'quail-merge-maps
             (cons
              (if (and h1 h2)
                  (vconcat (if (vectorp h1) h1 (vector h1))
                           (if (vectorp h2) h2 (vector h2)))
                (or h1 h2))
              (let ((tail nil) conflict)
                (dolist (entry map1)
                  (setq conflict (assq (car entry) map2))
                  (push (if (not conflict) entry
                          (setq map2 (delq conflict map2))
                          (cons (car entry)
                                (quail-merge-maps (cdr entry) (cdr conflict))))
                        tail))
                (append map2 tail)))
             maps))))

IIRC this was just good enough for "stateless" input methods
(i.e. methods which just map some char sequences to corresponding chars,
as is done for latin and TeX input methods).


        Stefan



reply via email to

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