From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Brent Goodrick <bgoodr@gmail.com>, 5062@emacsbugs.donarmstrong.com
Subject: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map
Date: Sat, 28 Nov 2009 19:49:08 +0200 [thread overview]
Message-ID: <87einifskr.fsf@mail.jurta.org> (raw)
In-Reply-To: <jwvvdgv8jzx.fsf-monnier+emacsbugreports@gnu.org> (Stefan Monnier's message of "Fri, 27 Nov 2009 21:25:36 -0500")
> 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/
next prev parent reply other threads:[~2009-11-28 17:49 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <878wdixvgt.fsf@mail.jurta.org>
2009-11-28 0:44 ` bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Brent Goodrick
2009-11-28 2:25 ` Stefan Monnier
2009-11-28 15:26 ` Brent Goodrick
2009-11-28 17:49 ` Juri Linkov [this message]
2009-11-28 20:21 ` Stefan Monnier
2009-11-28 22:54 ` Juri Linkov
2009-11-29 15:36 ` Stefan Monnier
2009-11-29 16:03 ` Juri Linkov
2009-11-29 18:33 ` Stefan Monnier
2009-11-29 22:00 ` Lennart Borgman
2009-11-29 22:08 ` Juri Linkov
2009-11-29 23:16 ` Lennart Borgman
2009-12-03 0:59 ` bug#5062: " Juri Linkov
2009-12-03 1:37 ` Lennart Borgman
2009-12-03 3:08 ` Kevin Rodgers
2009-12-03 3:31 ` Lennart Borgman
2009-12-03 3:30 ` Stefan Monnier
2009-12-03 0:57 ` bug#5062: 23.1.50; " Juri Linkov
2009-12-03 3:28 ` Stefan Monnier
2009-12-03 5:00 ` Jason Rumney
2009-12-04 0:05 ` Juri Linkov
2009-12-04 22:00 ` bug#5062: marked as done (23.1.50; image-toggle-display overwrites nxml-mode local key map) Emacs bug Tracking System
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87einifskr.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=5062@emacsbugs.donarmstrong.com \
--cc=bgoodr@gmail.com \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).