From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.devel Subject: iso-transl pach (bug#6527: C-h b alters key-translation-map (in a bad way)) Date: Sun, 18 Jul 2010 12:06:03 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1279451183 13268 80.91.229.12 (18 Jul 2010 11:06:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 18 Jul 2010 11:06:23 +0000 (UTC) To: Emacs-Devel devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 18 13:06:19 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OaRhK-000642-4h for ged-emacs-devel@m.gmane.org; Sun, 18 Jul 2010 13:06:18 +0200 Original-Received: from localhost ([127.0.0.1]:46521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OaRhJ-000366-GQ for ged-emacs-devel@m.gmane.org; Sun, 18 Jul 2010 07:06:17 -0400 Original-Received: from [140.186.70.92] (port=37119 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OaRhB-000361-Ux for emacs-devel@gnu.org; Sun, 18 Jul 2010 07:06:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OaRhA-0004vP-Ga for emacs-devel@gnu.org; Sun, 18 Jul 2010 07:06:09 -0400 Original-Received: from mail-wy0-f169.google.com ([74.125.82.169]:63274) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OaRhA-0004vG-4q for emacs-devel@gnu.org; Sun, 18 Jul 2010 07:06:08 -0400 Original-Received: by wyj26 with SMTP id 26so4006385wyj.0 for ; Sun, 18 Jul 2010 04:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :subject:from:in-reply-to:date:content-transfer-encoding:message-id :references:to:x-mailer; bh=OOdZdJcVXnsjor2rg/EMeNTcYG42iINT4832nNvEfI0=; b=pWUYSojXuKI7vcisc3u9hB9h1UXEHM0s7ZrykbYc9PNQLblTtwoe5Ns41gBn8xBs0n tKNen+Q8J9NSHF2z2oAJmwjNqOy6ENHWDJWqSPYNCZ6IeMj5wTuGpZINTNPEWwwGH/TY ifd6uoEi3oLFMTQ4Ie7hhbHwAt+XE0Gl7roLI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=RzmsSt7X1NWsCPwUn4Ufe4EOE7okpKKWPXJBr9Km/9dtDahcE/l59FtcwW+EW7LCYJ Bm/Pz//6+pfuKC/bAa62JUE98IcGzYbUGQnLz5ZJTHPtYi8cUiYVW0g45LdITzFeR/cq hWptW4u+0Xfkp+nPupppQ/lFplbOn4EECMztw= Original-Received: by 10.227.32.82 with SMTP id b18mr2788067wbd.149.1279451166638; Sun, 18 Jul 2010 04:06:06 -0700 (PDT) Original-Received: from [192.168.0.100] (cpc1-sgyl8-0-0-cust16.sgyl.cable.virginmedia.com [80.192.30.17]) by mx.google.com with ESMTPS id l6sm1668104wed.1.2010.07.18.04.06.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 18 Jul 2010 04:06:05 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.1081) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:127549 Archived-At: I reported bug 6527 a while ago. > 6527: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D6527 The problem was that iso-trans.el is autoloaded (e.g., when doing C-h b) = and unconditionally binds Alt key combinations, overriding any = user/package defined A- keys. Once loaded, there is no obvious way to = undo those bindings. Here's a fix for this. It defines a new minor mode, `iso-transl-mode', = which controls those A-... key bindings. I chose to automatically define the C-x 8 prefix key combinations when = the package is loaded, so that the C-x 8 autoloading mechanism remains = in place for the comfort of the occasional user.=20 I don't know how much iso-transl is used by people, so I can't gauge the = impact of this. Please advise. diff --combined lisp/international/iso-transl.el index 8a88b50,b11a7a2..0000000 --- a/lisp/international/iso-transl.el +++ b/lisp/international/iso-transl.el @@@ -25,21 -25,16 +25,21 @@@ ;;; Commentary: =20 ;; Loading this package defines three ways of entering the non-ASCII -;; printable characters with codes above 127: the prefix C-x 8, or the -;; Alt key, or a dead accent key. For example, you can enter = uppercase -;; A-umlaut as `C-x 8 " A' or `Alt-" A' (if you have an Alt key) or -;; `umlaut A' (if you have an umlaut/diaeresis key). +;; printable characters with codes above 127: the prefix C-x 8, and, +;; with `iso-transl-mode' enabled, also the Alt key, and a dead accent +;; key. For example, you can enter uppercase A-umlaut as `C-x 8 " A' +;; or, `iso-transl-mode' is enabled, `Alt-" A' (if you have an Alt +;; key) or `umlaut A' (if you have an umlaut/diaeresis key). =20 -;; C-x 8 is set up to autoload this package, -;; but Alt keys and dead accent keys are only defined -;; once you have loaded the package. It is nontrivial -;; to make all of the Alt keys autoload, and it is not clear -;; that the dead accent keys SHOULD autoload this package. +;; C-x 8 is set up to autoload this package, but Alt keys and dead +;; accent keys are only defined once you have loaded the package and +;; enabled `iso-transl-mode'. It is nontrivial to make all of the Alt +;; keys autoload, and it is not clear that the dead accent keys SHOULD +;; autoload this package. + +;; Note that C-h b will autoload this package, which is one reason +;; why the more destructive key sequences (without C-x 8 prefix) are +;; only defined in `iso-transl-mode', and are thus reversible. =20 ;;; Code: =20 @@@ -252,41 -247,29 +252,41 @@@ sequence VECTOR. (VECTOR is normally o (setq key-translation-map (make-sparse-keymap))) (define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map) =20 +(defmacro iso-transl-define-key (keymap key def) + "Back up definition of KEY in KEYMAP, then `define-key'." + `(progn + (push (cons ,key (or (lookup-key ,keymap ,key) 'none)) + (get ',keymap 'iso-transl-backup)) + (define-key ,keymap ,key ,def))) + ;; 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 ;; the first key of the sequence; and (if applicable) replacing the = first ;; key of the sequence with the corresponding dead key. For example, = a ;; character associated with the string "~n" can be input with `C-x 8 = ~ n' ;; or `Alt-~ n' or `mute-asciitilde n'. +(defun iso-transl-define-prefix-keys (alist) + (while alist + (let ((translated-vec (cdr (car alist)))) + (iso-transl-define-key iso-transl-ctl-x-8-map (car (car alist)) = translated-vec)) + (setq alist (cdr alist)))) (defun iso-transl-define-keys (alist) (while alist (let ((translated-vec (cdr (car alist)))) - (define-key iso-transl-ctl-x-8-map (car (car alist)) = translated-vec) + ;(iso-transl-define-key iso-transl-ctl-x-8-map (car (car alist)) = translated-vec) (let ((inchar (aref (car (car alist)) 0)) (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) + (iso-transl-define-key key-translation-map vec translated-vec) + (iso-transl-define-key isearch-mode-map (vector (aref vec 0)) = nil) (while tail (if (eq (car (car tail)) inchar) (let ((deadvec (copy-sequence vec)) (deadkey (cdr (car tail)))) (aset deadvec 0 deadkey) - (define-key isearch-mode-map (vector deadkey) nil) - (define-key key-translation-map deadvec = translated-vec))) + (iso-transl-define-key isearch-mode-map (vector deadkey) = nil) + (iso-transl-define-key key-translation-map deadvec = translated-vec))) (setq tail (cdr tail))))) (setq alist (cdr alist)))) =20 @@@ -297,45 -280,14 +297,45 @@@ (iso-transl-define-keys (cdr (assoc lang = iso-transl-language-alist)))) =20 =20 -;; 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) - +;; unconditional definitions +(iso-transl-define-prefix-keys iso-transl-char-map) (define-key isearch-mode-map "\C-x" nil) (define-key isearch-mode-map [?\C-x t] 'isearch-other-control-char) (define-key isearch-mode-map "\C-x8" nil) =20 +(define-minor-mode iso-transl-mode + "ISO Key translation mode. +This mode defines two ways of entering the non-ASCII printable +characters with codes above 127: the Alt key and=20 +a dead accent key. For example, you can enter uppercase A-umlaut as +`Alt-\" A' (if you have an Alt key) or `umlaut A' (if +you have an umlaut/diaeresis key). + +This character can always be entered as `C-x 8 \" A' regardless of +this mode." + :group 'i18n + :lighter " ISO" + + (if iso-transl-mode + ;; 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) + (mapc + (lambda (key-def)=20 + (define-key key-translation-map (car key-def)=20 + (and (not (eq (cdr key-def) 'none)) (cdr key-def)))) + (nreverse (get 'key-translation-map 'iso-transl-backup))) + (put 'key-translation-map 'iso-transl-backup nil) + (mapc + (lambda (key-def)=20 + (condition-case nil + (define-key isearch-mode-map (car key-def)=20 + (and (not (eq (cdr key-def) 'none)) (cdr key-def))) + ;; if some of the unconditional definitions above are instead = made conditional + ;; restoring the default keys fails. + (error nil))) + (nreverse (get 'isearch-mode-map 'iso-transl-backup))) + (put 'isearch-mode-map 'iso-transl-backup nil))) =20 (provide 'iso-transl) =20