emacs-devel
[Top][All Lists]
Advanced

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

Re: a few MULE criticisms


From: Stefan Monnier
Subject: Re: a few MULE criticisms
Date: Sun, 18 May 2003 01:23:54 -0400

Regarding the use of ? in input methods.
I've never looked at the code of quail before, so clearly
this is not working 100% (not even 90%, I'd say), but
maybe someone more knowledgeable can fix it ?

It maybe won't be a workable approach for dense quail
maps (like most are, I expect :-( ) but it works OK on
the TeX input method where I can say \righ?????? and get
a right arrow.

Generalizing to * is going to be even less workable, so I think
that a different approach is necessary.


        Stefan


--- quail.el.~1.128.~   Tue Apr 15 18:46:10 2003
+++ quail.el    Sun May 18 01:19:08 2003
@@ -1,6 +1,6 @@
 ;;; quail.el --- provides simple input method for multilingual text
 
-;; Copyright (C) 1995, 2000 Electrotechnical Laboratory, JAPAN.
+;; Copyright (C) 1995, 2000, 2003 Electrotechnical Laboratory, JAPAN.
 ;; Licensed to the Free Software Foundation.
 ;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
 
@@ -1218,6 +1216,28 @@
    (t
     (error "Invalid object in Quail map: %s" def))))
 
+(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))))
+
 (defun quail-lookup-key (key &optional len)
   "Lookup KEY of length LEN in the current Quail map and return the definition.
 The returned value is a Quail map specific to KEY."
@@ -1236,7 +1256,9 @@
       (setq slot (assq ch (cdr map)))
       (if (and (cdr slot) (symbolp (cdr slot)))
          (setcdr slot (funcall (cdr slot) key idx)))
-      (setq map (cdr slot)))
+      (if (and (null slot) (eq ch ??))
+         (setq map (apply 'quail-merge-maps (mapcar 'cdr (cdr map))))
+       (setq map (cdr slot))))
     (setq def (car map))
     (setq quail-current-translations nil)
     (if (and map (setq translation (quail-get-translation def key len)))





reply via email to

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