bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#6527: C-h b autoloads iso-transl and alters key-translation-map


From: Chong Yidong
Subject: bug#6527: C-h b autoloads iso-transl and alters key-translation-map
Date: Wed, 18 Jul 2012 19:22:09 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> I'd just like to see the implementation changed to make use of the new
> multiple inheritance in keymaps:
> - define the added bindings statically in a separate keymap (call it
>   iso-transl-mode-translation-map).
> - when enabling/disabling the mode, just add/remove that map from the
>   parents of key-translation-map.

How about something like the following (modulo comment changes and
fixing the isearch integration)?

There's still no facility for cleanly adding/removing a keymap parent.
So this patch makes iso-transl-map the parent to key-translation-map at
top-level, and leaves it as the parent.  To enable the key translations,
it calls define-key on iso-transl-map; to disable the key translations,
it does (setcdr iso-transl-map nil), which turns iso-transl-map back
into a sparse keymap.  (Hence this relies on knowledge of the internal
representation of keymaps, but I don't see how to avoid that.)


=== modified file 'lisp/international/iso-transl.el'
*** lisp/international/iso-transl.el    2012-07-18 09:27:23 +0000
--- lisp/international/iso-transl.el    2012-07-18 11:20:36 +0000
***************
*** 236,249 ****
       ("N"  . [?Ñ])
       ("n"  . [?ñ]))))
  
! (defvar iso-transl-ctl-x-8-map nil
    "Keymap for C-x 8 prefix.")
! (or iso-transl-ctl-x-8-map
!     (fset 'iso-transl-ctl-x-8-map
!         (setq iso-transl-ctl-x-8-map (make-sparse-keymap))))
! (or key-translation-map
!     (setq key-translation-map (make-sparse-keymap)))
! (define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map)
  
  ;; For each entry in the alist, we'll make up to three ways to generate
  ;; the character in question: the prefix `C-x 8'; the ALT modifier on
--- 236,247 ----
       ("N"  . [?Ñ])
       ("n"  . [?ñ]))))
  
! (defvar iso-transl-map (make-sparse-keymap))
! (set-keymap-parent key-translation-map iso-transl-map)
! 
! (defvar iso-transl-ctl-x-8-map (make-sparse-keymap)
    "Keymap for C-x 8 prefix.")
! (fset 'iso-transl-ctl-x-8-map iso-transl-ctl-x-8-map)
  
  ;; For each entry in the alist, we'll make up to three ways to generate
  ;; the character in question: the prefix `C-x 8'; the ALT modifier on
***************
*** 259,265 ****
            (vec (vconcat (car (car alist))))
            (tail iso-transl-dead-key-alist))
        (aset vec 0 (logior (aref vec 0) ?\A-\^@))
!       (define-key key-translation-map vec translated-vec)
        (define-key isearch-mode-map (vector (aref vec 0)) nil)
        (while tail
          (if (eq (car (car tail)) inchar)
--- 257,263 ----
            (vec (vconcat (car (car alist))))
            (tail iso-transl-dead-key-alist))
        (aset vec 0 (logior (aref vec 0) ?\A-\^@))
!       (define-key iso-transl-map vec translated-vec)
        (define-key isearch-mode-map (vector (aref vec 0)) nil)
        (while tail
          (if (eq (car (car tail)) inchar)
***************
*** 267,273 ****
                    (deadkey (cdr (car tail))))
                (aset deadvec 0 deadkey)
                (define-key isearch-mode-map (vector deadkey) nil)
!               (define-key key-translation-map deadvec translated-vec)))
          (setq tail (cdr tail)))))
      (setq alist (cdr alist))))
  
--- 265,271 ----
                    (deadkey (cdr (car tail))))
                (aset deadvec 0 deadkey)
                (define-key isearch-mode-map (vector deadkey) nil)
!               (define-key iso-transl-map deadvec translated-vec)))
          (setq tail (cdr tail)))))
      (setq alist (cdr alist))))
  
***************
*** 280,286 ****
  
  ;; The standard mapping comes automatically.  You can partially overlay it
  ;; with a language-specific mapping by using `M-x iso-transl-set-language'.
! (iso-transl-define-keys iso-transl-char-map)
  
  (provide 'iso-transl)
  
--- 278,295 ----
  
  ;; The standard mapping comes automatically.  You can partially overlay it
  ;; with a language-specific mapping by using `M-x iso-transl-set-language'.
! 
! (define-minor-mode iso-transl-mode
!   "Toggle ISO-8859 Key Translation mode."
!   :group 'i18n
!   :global t
!   (setcdr iso-transl-map nil)
!   (setcdr iso-transl-ctl-x-8-map nil)
!   (when iso-transl-mode
!     (iso-transl-define-keys iso-transl-char-map)
!     (define-key iso-transl-map "\C-x8" iso-transl-ctl-x-8-map)))
! 
! (iso-transl-mode)
  
  (provide 'iso-transl)
  






reply via email to

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