From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Date: Sat, 28 Nov 2009 19:49:08 +0200 Organization: JURTA Message-ID: <87einifskr.fsf@mail.jurta.org> References: Reply-To: Juri Linkov , 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 1259432874 20483 80.91.229.12 (28 Nov 2009 18:27:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 Nov 2009 18:27:54 +0000 (UTC) Cc: Brent Goodrick , 5062@emacsbugs.donarmstrong.com To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 28 19:27:47 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 1NES1K-00010v-TV for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Nov 2009 19:27:47 +0100 Original-Received: from localhost ([127.0.0.1]:35057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NES1K-0000yO-EN for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Nov 2009 13:27:46 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NES16-0000tD-9Q for bug-gnu-emacs@gnu.org; Sat, 28 Nov 2009 13:27:32 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NES12-0000rw-1X for bug-gnu-emacs@gnu.org; Sat, 28 Nov 2009 13:27:31 -0500 Original-Received: from [199.232.76.173] (port=59520 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NES11-0000rs-Q4 for bug-gnu-emacs@gnu.org; Sat, 28 Nov 2009 13:27:27 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:50068) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NES11-0004xV-1p for bug-gnu-emacs@gnu.org; Sat, 28 Nov 2009 13:27:27 -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 nASIRMNZ026979; Sat, 28 Nov 2009 10:27:24 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nASIP8pI026741; Sat, 28 Nov 2009 10:25:08 -0800 Resent-Date: Sat, 28 Nov 2009 10:25:08 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Juri Linkov Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Sat, 28 Nov 2009 18:25:08 +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.125943235326032 (code B ref 5062); Sat, 28 Nov 2009 18:25:08 +0000 Original-Received: (at 5062) by emacsbugs.donarmstrong.com; 28 Nov 2009 18:19:13 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from mx2.starman.ee (smtp-out4.starman.ee [85.253.0.6]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nASIJBnS026024 for <5062@emacsbugs.donarmstrong.com>; Sat, 28 Nov 2009 10:19:13 -0800 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Original-Received: from mail.starman.ee (82.131.33.180.cable.starman.ee [82.131.33.180]) by mx2.starman.ee (Postfix) with ESMTP id 9ACF83F4068; Sat, 28 Nov 2009 20:19:03 +0200 (EET) In-Reply-To: (Stefan Monnier's message of "Fri, 27 Nov 2009 21:25:36 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Sat, 28 Nov 2009 13:27:31 -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:33016 Archived-At: > Indeed, SVG files should be handled like postscript files, i.e. use > image-minor-mode rather than image-mode. Currently PS files are handled by DocView, but there is the same problem for .xbm/.xpm files that use c-mode. > Can someone figure out how to to do that? The problem is in `(use-local-map image-mode-text-map)'. 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. 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/