From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Date: Sat, 28 Nov 2009 15:21:49 -0500 Message-ID: References: <87einifskr.fsf@mail.jurta.org> Reply-To: Stefan Monnier , 5062@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1259441265 9535 80.91.229.12 (28 Nov 2009 20:47:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 Nov 2009 20:47:45 +0000 (UTC) Cc: Brent Goodrick , 5062@emacsbugs.donarmstrong.com To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 28 21:47:37 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NEUCe-0001Mv-NH for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Nov 2009 21:47:37 +0100 Original-Received: from localhost ([127.0.0.1]:48577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NEUCe-0006Vw-Ad for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Nov 2009 15:47:36 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NEUCZ-0006UK-HP for bug-gnu-emacs@gnu.org; Sat, 28 Nov 2009 15:47:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NEUCU-0006SC-DC for bug-gnu-emacs@gnu.org; Sat, 28 Nov 2009 15:47:30 -0500 Original-Received: from [199.232.76.173] (port=60122 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NEUCU-0006S6-5X for bug-gnu-emacs@gnu.org; Sat, 28 Nov 2009 15:47:26 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:49078) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NEUCT-00019s-Qs for bug-gnu-emacs@gnu.org; Sat, 28 Nov 2009 15:47:26 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nASKlNWu009050; Sat, 28 Nov 2009 12:47:23 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nASKU4cV007375; Sat, 28 Nov 2009 12:30:04 -0800 Resent-Date: Sat, 28 Nov 2009 12:30:04 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Sat, 28 Nov 2009 20:30:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 5062 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 5062-submit@emacsbugs.donarmstrong.com id=B5062.12594397176842 (code B ref 5062); Sat, 28 Nov 2009 20:30:04 +0000 Original-Received: (at 5062) by emacsbugs.donarmstrong.com; 28 Nov 2009 20:21:57 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from ironport2-out.pppoe.ca (ironport2-out.teksavvy.com [206.248.154.183]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nASKLukS006839 for <5062@emacsbugs.donarmstrong.com>; Sat, 28 Nov 2009 12:21:57 -0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqYEAHQVEUtFpYc//2dsb2JhbACBTtJ0hDEEihk X-IronPort-AV: E=Sophos;i="4.47,306,1257138000"; d="scan'208";a="50248688" Original-Received: from 69-165-135-63.dsl.teksavvy.com (HELO pastel.home) ([69.165.135.63]) by ironport2-out.pppoe.ca with ESMTP; 28 Nov 2009 15:21:50 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id E231D837A; Sat, 28 Nov 2009 15:21:49 -0500 (EST) In-Reply-To: <87einifskr.fsf@mail.jurta.org> (Juri Linkov's message of "Sat, 28 Nov 2009 19:49:08 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Sat, 28 Nov 2009 15:47:30 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:33020 Archived-At: > After switching to "text" mode, it sets the local map to > image-mode-text-map with a single key binding `C-c C-c' > instead of restoring the original map of the major mode. > The following patch fixes this bug. It saves a copy of the original > map to the internal buffer-local variable `image-mode-local-map' > with the additional image-mode specific key binding `C-c C-c' to > switch back to the image mode. And on switching to the text mode > restores the original major mode map from this variable. Better would be to save the major mode, and then switch to "saved-major-mode + image-minor-mode". No need to modify anybody's keymap. And I think that image-minor-mode should only be used while displaying text: basically, image-toggle-display should toggle between image-mode and the other major-mode (complemented with image-minor-mode). That would be cleaner, Stefan > Index: lisp/image-mode.el > =================================================================== > RCS file: /sources/emacs/emacs/lisp/image-mode.el,v > retrieving revision 1.58 > diff -u -r1.58 image-mode.el > --- lisp/image-mode.el 11 Nov 2009 05:49:13 -0000 1.58 > +++ lisp/image-mode.el 28 Nov 2009 17:48:00 -0000 > @@ -306,11 +306,8 @@ > map) > "Major mode keymap for viewing images in Image mode.") > -(defvar image-mode-text-map > - (let ((map (make-sparse-keymap))) > - (define-key map "\C-c\C-c" 'image-toggle-display) > - map) > - "Major mode keymap for viewing images as text in Image mode.") > +(defvar image-mode-local-map nil) > +(make-variable-buffer-local 'image-mode-local-map) > (defvar bookmark-make-record-function) > @@ -329,6 +326,9 @@ > ;; Keep track of [vh]scroll when switching buffers > (image-mode-setup-winprops) > + (setq image-mode-local-map (copy-keymap (current-local-map))) > + (define-key image-mode-local-map "\C-c\C-c" 'image-toggle-display) > + > (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) > (if (display-images-p) > (if (not (image-get-display-property)) > @@ -339,7 +339,7 @@ > (setq cursor-type nil truncate-lines t > image-type (plist-get (cdr (image-get-display-property)) :type))) > (setq image-type "text") > - (use-local-map image-mode-text-map)) > + (use-local-map image-mode-local-map)) > (setq mode-name (format "Image[%s]" image-type)) > (run-mode-hooks 'image-mode-hook) > (if (display-images-p) > @@ -354,12 +354,16 @@ > "Toggle Image minor mode. > With arg, turn Image minor mode on if arg is positive, off otherwise. > See the command `image-mode' for more information on this mode." > - nil (:eval (format " Image[%s]" image-type)) image-mode-text-map > + nil (:eval (format " Image[%s]" image-type)) nil > :group 'image > :version "22.1" > (if (not image-minor-mode) > (image-toggle-display-text) > (image-mode-setup-winprops) > + > + (setq image-mode-local-map (copy-keymap (current-local-map))) > + (define-key image-mode-local-map "\C-c\C-c" 'image-toggle-display) > + > (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t) > (if (display-images-p) > (if (not (image-get-display-property)) > @@ -367,7 +371,7 @@ > (setq cursor-type nil truncate-lines t > image-type (plist-get (cdr (image-get-display-property)) :type))) > (setq image-type "text") > - (use-local-map image-mode-text-map)) > + (use-local-map image-mode-local-map)) > (if (display-images-p) > (message "%s" (concat > (substitute-command-keys > @@ -425,7 +429,7 @@ > (kill-local-variable 'cursor-type) > (kill-local-variable 'truncate-lines) > (kill-local-variable 'auto-hscroll-mode) > - (use-local-map image-mode-text-map) > + (use-local-map image-mode-local-map) > (setq image-type "text") > (if (eq major-mode 'image-mode) > (setq mode-name "Image[text]")) > -- > Juri Linkov > http://www.jurta.org/emacs/