From bgoodr@gmail.com Fri Nov 27 16:44:36 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 28 Nov 2009 00:44:36 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-1.9 required=4.0 tests=AWL,FOURLA,FVGT_m_MULTI_ODD autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAS0iYwe019529 for ; Fri, 27 Nov 2009 16:44:35 -0800 Received: from mx10.gnu.org ([199.232.76.166]:38389) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1NEBQP-0007JP-Sg for emacs-pretest-bug@gnu.org; Fri, 27 Nov 2009 19:44:34 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NEBQO-0007c6-B3 for emacs-pretest-bug@gnu.org; Fri, 27 Nov 2009 19:44:33 -0500 Received: from mail-bw0-f215.google.com ([209.85.218.215]:53031) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NEBQN-0007bs-T5 for emacs-pretest-bug@gnu.org; Fri, 27 Nov 2009 19:44:32 -0500 Received: by bwz7 with SMTP id 7so768807bwz.26 for ; Fri, 27 Nov 2009 16:44:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=YRJl5EjRw/eBqVwSfjuMghhCOFebK734CvWRRZeOYkU=; b=XKDfAaHnqVPpRPGSNU4GaTUBOBk/r0M06G2NqTlqND06D7HehlxfPU41o6s1uqZ71y j6o3LUHmUO558q1FQHWDYj/ySHq3tGbDn6xpsnKRBjQcQ/zmH2OYj7hqH8fJ+NMyIcV8 9exiuPvrfrKbITE+zet3KnxA12LaHVZF13cUk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Bm47T/67TCy750JphoA9bImUl/HX/nhxKzSN32Q0xK8/0C4MEN73omZwCpLxCYqCXo HaUzu5Rzz6Mf6btvkf+YaGH3RNxGjZmXyJb+7N5fD0xT27K1YnBhJ1oyDlDpbMSuBhlK BJWlFrb7Z3CTUlXFcwgry6P2QgqQT7/MVvL8A= MIME-Version: 1.0 Received: by 10.204.152.154 with SMTP id g26mr1745214bkw.54.1259369070066; Fri, 27 Nov 2009 16:44:30 -0800 (PST) Date: Fri, 27 Nov 2009 16:44:30 -0800 Message-ID: Subject: 23.1.50; image-toggle-display overwrites nxml-mode local key map From: Brent Goodrick To: emacs-pretest-bug@gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Please write in English if possible, because the Emacs maintainers usually do not have translators to read other languages for them. Your bug report will be posted to the emacs-pretest-bug@gnu.org mailing list. Please describe exactly what actions triggered the bug and the precise symptoms of the bug. If you can, give a recipe starting from `emacs -Q': Insure that you have Emacs 23 built on Debian Squeeze Linux with librsvg2 library (or similar OS's and libraries), just to get the image-mode to interact with nxml-mode in its keybindings for a .svg file which is an XML derivative for SVG files. Then proceed as follows: 1. Store the following XML content into a file called /tmp/test.svg --- cut below this line --- Sample Title Sample Description 10px 1px --- cut above this line --- 2. Run emacs -Q and wait for it to load and map into the display. 3. Type C-x C-f /tmp/test.svg and see that the image of the file is displayed. 4. Type C-c C-c and note that the XML is shown. All correct behavior so far. 5. Type C-h k C-M-n and notice that the key for C-M-n is bound to `forward-list' which is not correct because the .svg file is a xml file, that, by default, should be bound to `nxml-forward-element' by the defvar for nxml-mode-map inside share/emacs/23.1.50/lisp/nxml/nxml-mode.el.gz. Notice also that nxml-mode applies its own local map with this call inside the `nxml-mode' function: (use-local-map nxml-mode-map) But compare that with `image-toggle-display' where it either calls: (use-local-map image-mode-text-map) or (use-local-map image-mode-map) Neither of which respects the nxml-mode's bindings. For validation, you can inject a "trampoline" function on `use-local-map' to show who overwrites the local map, as follows: (progn (defun xx-new-use-local-map (&rest args) (message "xx-new-use-local-map called from:\n") (backtrace) (apply xx-orig-use-local-map args)) (when (not (boundp 'xx-orig-use-local-map)) (setq xx-orig-use-local-map (symbol-function 'use-local-map)) (fset 'use-local-map 'xx-new-use-local-map))) where the "xx-*" functions were arbitrary for this bug report. Once xx-new-use-local-map is injected as given above, then use C-h C-e to see what happens when you first execute C-x C-f /tmp/test.svg, and then see it again when hitting C-c C-c while in the test.svg buffer. You will see that image-mode function obliterates the local map set by the `nxml-mode' function. I don't know what the correct solution here should be, and many questions arise: a. Should image-mode be a minor mode of nxml-mode, or, b. Should `image-mode' stash a copy of the current buffers (current-local-map), and restore it afterwards, but also applying the special binding for C-c C-c, or, c. Should `image-mode' make the other modes local map be the parent of its own local map? I'm thinking (c)? Thanks to whomever added SVG capabilities to Emacs! bgoodr If Emacs crashed, and you have the Emacs process in the gdb debugger, please include the output from the following gdb commands: `bt full' and `xbacktrace'. For information about debugging Emacs, please read the file /home/brentg/install/Linux.x86_64/share/emacs/23.1.50/etc/DEBUG. Emacs did not crash. In GNU Emacs 23.1.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.18.2) of 2009-10-31 on hungover Windowing system distributor `The X.Org Foundation', version 11.0.10605000 configured using `configure '--with-x-toolkit' '--with-xft' '--prefix=/home/brentg/install/Linux.x86_64'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.UTF-8 value of $XMODIFIERS: nil locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: nXML Minor modes in effect: image-minor-mode: t tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: C-x C-f C-v / t m p / C-x h C-b C-b C-b C-g C-x C-f C-SPC M-b C-b / t m p C-d C-d C-d C-d C-d / t e s t . s v g C-v C-x C-s C-x C-v C-c C-c C-h k C-M-n M-x r e p o r t - e m Recent messages: File mode specification error: (error "Cannot determine image type") call-interactively: End of buffer Mark set Saving file /tmp/test.svg... Wrote /tmp/test.svg Using vacuous schema Type C-c C-c to view the image as text. Repeat this command to go back to displaying the image Type C-x 1 to delete the help window. Load-path shadows: None found. Features: (shadow mail-extr message ecomplete rfc822 mml mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1 hex-util hashcash mail-utils emacsbug sendmail help-fns help-mode view nxml-uchnm rng-xsd xsd-regexp rng-cmpct regexp-opt rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns easymenu nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok cl cl-19 jka-compr image-mode tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces cus-face text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind gtk x-toolkit x multi-tty emacs) From monnier@iro.umontreal.ca Fri Nov 27 18:25:43 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 28 Nov 2009 02:25:44 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.8 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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 nAS2PgOI028816 for <5062@emacsbugs.donarmstrong.com>; Fri, 27 Nov 2009 18:25:43 -0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArcEAFQYEEtFpYc//2dsb2JhbACBTtE/hDEEihk X-IronPort-AV: E=Sophos;i="4.47,305,1257138000"; d="scan'208";a="50215311" Received: from 69-165-135-63.dsl.teksavvy.com (HELO pastel.home) ([69.165.135.63]) by ironport2-out.pppoe.ca with ESMTP; 27 Nov 2009 21:25:36 -0500 Received: by pastel.home (Postfix, from userid 20848) id 7B0EB80E3; Fri, 27 Nov 2009 21:25:36 -0500 (EST) From: Stefan Monnier To: Brent Goodrick Cc: 5062@debbugs.gnu.org Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Message-ID: References: Date: Fri, 27 Nov 2009 21:25:36 -0500 In-Reply-To: (Brent Goodrick's message of "Fri, 27 Nov 2009 16:44:30 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > 2. Run emacs -Q and wait for it to load and map into the display. > 3. Type C-x C-f /tmp/test.svg and see that the image of the file is > displayed. > 4. Type C-c C-c and note that the XML is shown. All correct behavior > so far. > 5. Type C-h k C-M-n and notice that the key for C-M-n is bound to > `forward-list' which is not correct because the .svg file is a xml Indeed, SVG files should be handled like postscript files, i.e. use image-minor-mode rather than image-mode. Can someone figure out how to to do that? Stefan From bgoodr@gmail.com Sat Nov 28 07:26:21 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 28 Nov 2009 15:26:21 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-3.0 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from mail-bw0-f227.google.com (mail-bw0-f227.google.com [209.85.218.227]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nASFQJ4Y009379 for <5062@emacsbugs.donarmstrong.com>; Sat, 28 Nov 2009 07:26:20 -0800 Received: by bwz27 with SMTP id 27so1752689bwz.1 for <5062@emacsbugs.donarmstrong.com>; Sat, 28 Nov 2009 07:26:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=TKPECNBHM4Ckj3LB9xn10QIF0DK53IE24AjovfkQYFs=; b=in25YbE2OAxu+0HGxZP9Jd8SL+mUQzBHQhSxM7AF70YhD3KDP636WIWm3E9PBNAslh /2GYS0n9O8s/GELaa3k9K00awszvkq9pXbkPdlg+gS4JDl9B5E5TPNaR1NYsgu4+9K25 KmdTNP6kvnshgBEL7Y1kguAfnQlX1Tmnh/uTY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=QdD2vY7p5mVmJWCpmksC8TK+yMzVtrXe2yOauCQYYu04sMx47jiBJ9oQlyIhjUYYuG OJJAEic5ReDSOZUPOIQiP4DMXQM93LUyIuHkAgDanr7S+w45BRI3N13YBmJff3iol1Y3 +lNi7Pms30Qx/qNVJxp12Co4VFTD7NprhOM4k= MIME-Version: 1.0 Received: by 10.204.15.145 with SMTP id k17mr2312489bka.212.1259421973220; Sat, 28 Nov 2009 07:26:13 -0800 (PST) In-Reply-To: References: Date: Sat, 28 Nov 2009 07:26:13 -0800 Message-ID: Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map From: Brent Goodrick To: Stefan Monnier Cc: 5062@debbugs.gnu.org Content-Type: text/plain; charset=ISO-8859-1 On Fri, Nov 27, 2009 at 6:25 PM, Stefan Monnier wrote: > > > 2. Run emacs -Q and wait for it to load and map into the display. > > 3. Type C-x C-f /tmp/test.svg and see that the image of the file is > > displayed. > > 4. Type C-c C-c and note that the XML is shown. All correct behavior > > so far. > > 5. Type C-h k C-M-n and notice that the key for C-M-n is bound to > > `forward-list' which is not correct because the .svg file is a xml > > Indeed, SVG files should be handled like postscript files, i.e. use > image-minor-mode rather than image-mode. > Can someone figure out how to to do that? Hmmm, seems that image-minor-mode is enabled in this case, with a major mode of nxml-mode. But image-minor-mode ultimately calls image-toggle-display, and image-toggle-display is calling use-local-map to obliterate whatever map is already there. image-minor-mode can also call use-local-map, too. All of that arrangement seems to be set up by the image-mode-maybe function. I wonder what the correct "policy" is for a minor mode w.r.t. keybindings that can shadow a major mode? Should the major mode's keymap be the top-most local keymap, with all minor modes as parent maps of that top-most local keymap? Or is it the other way around, with each minor mode "pushing" its own local mode map to be top-most, and causing the current major modes local map to be that parent of that new one that was "pushed"? bg From juri@jurta.org Sat Nov 28 10:19:13 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 28 Nov 2009 18:19:13 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.6 required=4.0 tests=AWL,FVGT_m_MULTI_ODD, HAS_BUG_NUMBER,MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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 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) From: Juri Linkov To: Stefan Monnier Cc: 5062@debbugs.gnu.org, Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Organization: JURTA References: Date: Sat, 28 Nov 2009 19:49:08 +0200 In-Reply-To: (Stefan Monnier's message of "Fri, 27 Nov 2009 21:25:36 -0500") Message-ID: <87einifskr.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > 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/ From monnier@iro.umontreal.ca Sat Nov 28 12:21:57 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 28 Nov 2009 20:21:57 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.8 required=4.0 tests=AWL,FVGT_m_MULTI_ODD, HAS_BUG_NUMBER,MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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" 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 Received: by pastel.home (Postfix, from userid 20848) id E231D837A; Sat, 28 Nov 2009 15:21:49 -0500 (EST) From: Stefan Monnier To: Juri Linkov Cc: 5062@debbugs.gnu.org, Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Message-ID: References: <87einifskr.fsf@mail.jurta.org> Date: Sat, 28 Nov 2009 15:21:49 -0500 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) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > 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/ From juri@jurta.org Sat Nov 28 15:28:14 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 28 Nov 2009 23:28:14 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.6 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from mx1.starman.ee (smtp-out3.starman.ee [85.253.0.5]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nASNSCPm024801 for <5062@emacsbugs.donarmstrong.com>; Sat, 28 Nov 2009 15:28:14 -0800 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Received: from mail.starman.ee (82.131.33.180.cable.starman.ee [82.131.33.180]) by mx1.starman.ee (Postfix) with ESMTP id 2DB073F40D2; Sun, 29 Nov 2009 01:28:06 +0200 (EET) From: Juri Linkov To: Stefan Monnier Cc: 5062@debbugs.gnu.org, Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Organization: JURTA References: <87einifskr.fsf@mail.jurta.org> Date: Sun, 29 Nov 2009 00:54:16 +0200 In-Reply-To: (Stefan Monnier's message of "Sat, 28 Nov 2009 15:21:49 -0500") Message-ID: <87bpim8d5b.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > 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, I see now how this is implemented with `doc-view-previous-major-mode' in doc-view. Perhaps we should "sync" this with image-mode to use the same logic. -- Juri Linkov http://www.jurta.org/emacs/ From monnier@iro.umontreal.ca Sun Nov 29 07:37:07 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 29 Nov 2009 15:37:07 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.8 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from ironport2-out.pppoe.ca (ironport2-out.teksavvy.com [206.248.154.181]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nATFb55H014850 for <5062@emacsbugs.donarmstrong.com>; Sun, 29 Nov 2009 07:37:07 -0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AroEAGIkEktFpYc//2dsb2JhbACBTdE4hDEEihk X-IronPort-AV: E=Sophos;i="4.47,308,1257138000"; d="scan'208";a="50280094" Received: from 69-165-135-63.dsl.teksavvy.com (HELO ceviche.home) ([69.165.135.63]) by ironport2-out.pppoe.ca with ESMTP; 29 Nov 2009 10:36:59 -0500 Received: by ceviche.home (Postfix, from userid 20848) id 4AB5FB40E6; Sun, 29 Nov 2009 10:36:59 -0500 (EST) From: Stefan Monnier To: Juri Linkov Cc: 5062@debbugs.gnu.org, Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Message-ID: References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> Date: Sun, 29 Nov 2009 10:36:59 -0500 In-Reply-To: <87bpim8d5b.fsf@mail.jurta.org> (Juri Linkov's message of "Sun, 29 Nov 2009 00:54:16 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii >> 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, > I see now how this is implemented with `doc-view-previous-major-mode' > in doc-view. Perhaps we should "sync" this with image-mode to use > the same logic. Yes. Those two modes really need to be made more alike (ideally, they should be merged, tho there might be some good reasons to keep some of it separate). Stefan From juri@jurta.org Sun Nov 29 08:07:37 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 29 Nov 2009 16:07:38 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.6 required=4.0 tests=AWL,FVGT_m_MULTI_ODD, HAS_BUG_NUMBER,MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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 nATG7aHL018117 for <5062@emacsbugs.donarmstrong.com>; Sun, 29 Nov 2009 08:07:37 -0800 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Received: from mail.starman.ee (82.131.68.144.cable.starman.ee [82.131.68.144]) by mx2.starman.ee (Postfix) with ESMTP id 8A9F73F40C9; Sun, 29 Nov 2009 18:07:30 +0200 (EET) From: Juri Linkov To: Stefan Monnier Cc: 5062@debbugs.gnu.org, Tassilo Horn , Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Organization: JURTA References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> Date: Sun, 29 Nov 2009 18:03:50 +0200 In-Reply-To: (Stefan Monnier's message of "Sun, 29 Nov 2009 10:36:59 -0500") Message-ID: <87fx7x5np9.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii >>> 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, >> I see now how this is implemented with `doc-view-previous-major-mode' >> in doc-view. Perhaps we should "sync" this with image-mode to use >> the same logic. > > Yes. Those two modes really need to be made more alike (ideally, they > should be merged, tho there might be some good reasons to keep some of > it separate). Even though doc-view is a superset of image-mode, currently I see no way to merge them cleanly. But using the same handling of major/minor modes would be good. The patch below leaves the role for `image-minor-mode' to only provide the `C-c C-c' binding, and also toggles between `image-mode' and `image-mode-maybe' in `image-toggle-display' . If this is the right direction, I'd finish refactoring of image.el (some variable settings could be moved from `image-toggle-display' to `image-mode', etc.) One open question is about using `image-mode-maybe'. With this patch, it's essentially a combination of a non-image major mode (`normal-mode' with image-mode entries removed from `auto-mode-alist') and `image-minor-mode'. So when `image-mode-maybe' is present in `auto-mode-alist' this means "to set a non-image major mode and image-minor-mode". It would be more nice to get rid of `image-mode-maybe', and to use `image-minor-mode' in `auto-mode-alist'. But I don't know how to specify both a non-image major mode and image-minor-mode at the same time using `auto-mode-alist'. The approach currently used in doc-view for PS files is more ugly than using `image-mode-maybe'. It adds to ps-mode.el the line: (declare-function doc-view-minor-mode "doc-view") and calls `(doc-view-minor-mode 1)' at the end of `ps-mode'. I think this should be changed to use the solution described above adding e.g. `doc-view-mode-maybe' (or a better name) as a combination of a non-image major mode and image minor-mode. Index: lisp/image-mode.el =================================================================== RCS file: /sources/emacs/emacs/lisp/image-mode.el,v retrieving revision 1.59 diff -u -w -b -C 2 -r1.59 image-mode.el cvs diff: conflicting specifications of output style *** lisp/image-mode.el 28 Nov 2009 20:45:22 -0000 1.59 --- lisp/image-mode.el 29 Nov 2009 16:02:54 -0000 *************** *** 287,290 **** --- 287,293 ---- (make-variable-buffer-local 'image-type) + (defvar image-mode-previous-major-mode nil + "Internal variable to save the major mode.") + (defvar image-mode-map (let ((map (make-sparse-keymap))) *************** *** 307,311 **** "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) --- 310,314 ---- "Major mode keymap for viewing images in Image mode.") ! (defvar image-minor-mode-map (let ((map (make-sparse-keymap))) (define-key map "\C-c\C-c" 'image-toggle-display) *************** *** 323,335 **** (kill-all-local-variables) (setq major-mode 'image-mode) - ;; Use our own bookmarking function for images. - (set (make-local-variable 'bookmark-make-record-function) - 'image-bookmark-make-record) ! ;; Keep track of [vh]scroll when switching buffers ! (image-mode-setup-winprops) - (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) - (if (display-images-p) (if (not (image-get-display-property)) (image-toggle-display) --- 326,335 ---- (kill-all-local-variables) (setq major-mode 'image-mode) ! (unless (display-images-p) ! (setq image-type "text") ! (image-toggle-display-text) ! (error "Cannot display image")) (if (not (image-get-display-property)) (image-toggle-display) *************** *** 339,352 **** (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)) (setq mode-name (format "Image[%s]" image-type)) (run-mode-hooks 'image-mode-hook) - (if (display-images-p) (message "%s" (concat (substitute-command-keys "Type \\[image-toggle-display] to view as ") (if (image-get-display-property) ! "text" "an image") ".")))) ;;;###autoload --- 339,358 ---- (setq cursor-type nil truncate-lines t image-type (plist-get (cdr (image-get-display-property)) :type))) ! ! ;; Use our own bookmarking function for images. ! (set (make-local-variable 'bookmark-make-record-function) ! 'image-bookmark-make-record) ! ! ;; Keep track of [vh]scroll when switching buffers ! (image-mode-setup-winprops) ! ! (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) (setq mode-name (format "Image[%s]" image-type)) (run-mode-hooks 'image-mode-hook) (message "%s" (concat (substitute-command-keys "Type \\[image-toggle-display] to view as ") (if (image-get-display-property) ! "text" "an image") "."))) ;;;###autoload *************** *** 355,386 **** 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 :group 'image :version "22.1" ! (if (not image-minor-mode) ! (image-toggle-display-text) ! (image-mode-setup-winprops) (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t) ! (if (display-images-p) ! (condition-case err ! (progn ! (if (not (image-get-display-property)) ! (image-toggle-display) ! (setq cursor-type nil truncate-lines t ! image-type (plist-get (cdr (image-get-display-property)) ! :type))) ! (message "%s" ! (concat ! (substitute-command-keys ! "Type \\[image-toggle-display] to view the image as ") ! (if (image-get-display-property) ! "text" "an image") "."))) ! (error ! (image-toggle-display-text) ! (funcall ! (if (called-interactively-p 'any) 'error 'message) ! "Cannot display image: %s" (cdr err)))) ! (setq image-type "text") ! (use-local-map image-mode-text-map)))) ;;;###autoload --- 361,371 ---- 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 (if image-type (format " Image[%s]" image-type) " Image")) ! image-minor-mode-map :group 'image :version "22.1" ! (if image-minor-mode (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t) ! (set (make-local-variable 'image-mode-previous-major-mode) major-mode))) ;;;###autoload *************** *** 395,399 **** information on these modes." (interactive) ! (let* ((mode-alist (delq nil (mapcar (lambda (elt) --- 380,387 ---- information on these modes." (interactive) ! ;; image-mode-maybe = normal-mode + image-minor-mode ! (if image-mode-previous-major-mode ! (funcall image-mode-previous-major-mode) ! (let ((auto-mode-alist (delq nil (mapcar (lambda (elt) *************** *** 401,411 **** '(image-mode image-mode-maybe)) elt)) ! auto-mode-alist)))) ! (if (assoc-default buffer-file-name mode-alist 'string-match) ! (let ((auto-mode-alist mode-alist) ! (magic-mode-alist nil)) ! (set-auto-mode) ! (image-minor-mode t)) ! (image-mode)))) (defun image-toggle-display-text () --- 389,405 ---- '(image-mode image-mode-maybe)) elt)) ! auto-mode-alist))) ! (magic-fallback-mode-alist ! (delq nil (mapcar ! (lambda (elt) ! (unless (memq (or (car-safe (cdr elt)) (cdr elt)) ! '(image-mode image-mode-maybe)) ! elt)) ! magic-fallback-mode-alist)))) ! (normal-mode) ! (set (make-local-variable 'image-mode-previous-major-mode) major-mode))) ! (image-minor-mode 1)) (defun image-toggle-display-text () *************** *** 431,441 **** read-only front-sticky)) (set-buffer-modified-p modified) - (kill-local-variable 'cursor-type) - (kill-local-variable 'truncate-lines) - (kill-local-variable 'auto-hscroll-mode) - (use-local-map image-mode-text-map) (setq image-type "text") ! (if (eq major-mode 'image-mode) ! (setq mode-name "Image[text]")) (if (called-interactively-p 'any) (message "Repeat this command to go back to displaying the image"))) --- 425,430 ---- read-only front-sticky)) (set-buffer-modified-p modified) (setq image-type "text") ! (image-mode-maybe) (if (called-interactively-p 'any) (message "Repeat this command to go back to displaying the image"))) *************** *** 477,482 **** ;; Allow navigation of large images (set (make-local-variable 'auto-hscroll-mode) nil) - (use-local-map image-mode-map) (setq image-type type) (if (eq major-mode 'image-mode) (setq mode-name (format "Image[%s]" type))) --- 466,471 ---- ;; Allow navigation of large images (set (make-local-variable 'auto-hscroll-mode) nil) (setq image-type type) + (image-mode) (if (eq major-mode 'image-mode) (setq mode-name (format "Image[%s]" type))) -- Juri Linkov http://www.jurta.org/emacs/ From monnier@iro.umontreal.ca Sun Nov 29 10:33:14 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 29 Nov 2009 18:33:14 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.7 required=4.0 tests=AWL,FOURLA,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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 nATIXCMZ031666 for <5062@emacsbugs.donarmstrong.com>; Sun, 29 Nov 2009 10:33:14 -0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AroEAGdNEktFpYc//2dsb2JhbACBTdIShDEEihk X-IronPort-AV: E=Sophos;i="4.47,308,1257138000"; d="scan'208";a="50285527" Received: from 69-165-135-63.dsl.teksavvy.com (HELO ceviche.home) ([69.165.135.63]) by ironport2-out.pppoe.ca with ESMTP; 29 Nov 2009 13:33:06 -0500 Received: by ceviche.home (Postfix, from userid 20848) id 83C6CB40E6; Sun, 29 Nov 2009 13:33:06 -0500 (EST) From: Stefan Monnier To: Juri Linkov Cc: 5062@debbugs.gnu.org, Tassilo Horn , Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Message-ID: References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> Date: Sun, 29 Nov 2009 13:33:06 -0500 In-Reply-To: <87fx7x5np9.fsf@mail.jurta.org> (Juri Linkov's message of "Sun, 29 Nov 2009 18:03:50 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > Even though doc-view is a superset of image-mode, currently I see no way > to merge them cleanly. As mentioned, it may not be easy or even desirable to merge them completely. But we should strive to keep them as close as possible and to make doc-view use image-mode.el functions and data wherever possible. Maybe if one cannot be a derived mode of them other, we could make a "shared parent" mode (like an abstract class). > But using the same handling of major/minor modes > would be good. The patch below leaves the role for `image-minor-mode' > to only provide the `C-c C-c' binding, and also toggles between > `image-mode' and `image-mode-maybe' in `image-toggle-display' . I haven't looked in detail (partly because it doesn't apply to the current code because of some other change I installed in the mean time), but it looks good. > One open question is about using `image-mode-maybe'. With this > patch, it's essentially a combination of a non-image major mode > (`normal-mode' with image-mode entries removed from `auto-mode-alist') > and `image-minor-mode'. So when `image-mode-maybe' is present in > `auto-mode-alist' this means "to set a non-image major mode and > image-minor-mode". > It would be more nice to get rid of `image-mode-maybe', and to use > `image-minor-mode' in `auto-mode-alist'. But I don't know how to > specify both a non-image major mode and image-minor-mode > at the same time using `auto-mode-alist'. IIRC auto-mode-alist can point to minor-modes (the auto-mode-alist entry needs to look something like ("regexp" minor-mode t)), but I don't think it can be used here (the constraints on how it can be used are very strict since it needs to "consume" a suffix and be called before the major-mode). Maybe we could extend auto-mode-alist to allow things like ("regexp" (major-mode minor-mode-1 minor-mode-2 ...)). > The approach currently used in doc-view for PS files is more ugly than > using `image-mode-maybe'. It adds to ps-mode.el the line: > (declare-function doc-view-minor-mode "doc-view") To the extent that postscript would always use image-minor-mode anyway, I think the way it's done now is at least as clean if not cleaner than relying on image-mode-maybe (image-mode-maybe is fairly hackish). > I think this should be changed to use the solution described above > adding e.g. `doc-view-mode-maybe' (or a better name) as a combination > of a non-image major mode and image minor-mode. I don't think that would be an improvement. This is in contrast to XPM and SVG formats where they get combined with major-modes that are also used for non-image documents, so it wouldn't make sense for nxml-mode or c-mode to always enable image-minor-mode. Stefan From lennart.borgman@gmail.com Sun Nov 29 14:01:20 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 29 Nov 2009 22:01:20 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.3 required=4.0 tests=AWL,FOURLA,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from mail-gx0-f228.google.com (mail-gx0-f228.google.com [209.85.217.228]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nATM1IQC018124 for <5062@emacsbugs.donarmstrong.com>; Sun, 29 Nov 2009 14:01:19 -0800 Received: by gxk28 with SMTP id 28so765442gxk.9 for <5062@emacsbugs.donarmstrong.com>; Sun, 29 Nov 2009 14:01:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=yoKGOInHMpePfao8YScxRywz62U1o0rUkDWZhRpOrtg=; b=v6YKphX4Zx0XkN/zoBa90HUKm1mq9JHmFwM91Qk/C85vKHTVefHkycRp+X0Crs3tAh GcSlbVdU47/QULPz+FJq5kgdBs+RXmf8Mxf3sdsSIlO5L6maP+dcsOrbZ9AMXQiV4k8F s8ahfOI/2UndiPjm2CFxdIubnUeO/LUBTPi+w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=XdE+vfZSiBU6Pye65i1WQrc5Kooo6+TbFMJnM553WQESm3jgz9boywgOi9vKv8O5ir IFGeLZ4paAkeob4jXeAV8bJjDJdn8+04C9Vp0G5NYBUQzR/ZoKyccrYkWgavpYp/z1LF CxvC5t3rqre5dSmwx86AWA6vrYTIeT0qXVL5I= MIME-Version: 1.0 Received: by 10.101.196.34 with SMTP id y34mr1248268anp.191.1259532073072; Sun, 29 Nov 2009 14:01:13 -0800 (PST) In-Reply-To: References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> From: Lennart Borgman Date: Sun, 29 Nov 2009 23:00:53 +0100 Message-ID: Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map To: Stefan Monnier , 5062@debbugs.gnu.org Cc: Juri Linkov , Tassilo Horn , Brent Goodrick Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sun, Nov 29, 2009 at 7:33 PM, Stefan Monnier wrote: > > IIRC auto-mode-alist can point to minor-modes (the auto-mode-alist entry > needs to look something like ("regexp" minor-mode t)), but I don't think > it can be used here (the constraints on how it can be used are very > strict since it needs to "consume" a suffix and be called before the > major-mode). =C2=A0Maybe we could extend auto-mode-alist to allow things = like > ("regexp" (major-mode minor-mode-1 minor-mode-2 ...)). Or just define a derived mode that does major-mode + minor-mode and use that in auto-mode-alist? From juri@jurta.org Sun Nov 29 14:19:22 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 29 Nov 2009 22:19:22 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.6 required=4.0 tests=AWL,FOURLA,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from mx1.starman.ee (smtp-out3.starman.ee [85.253.0.5]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nATMJL5q020130 for <5062@emacsbugs.donarmstrong.com>; Sun, 29 Nov 2009 14:19:22 -0800 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Received: from mail.starman.ee (82.131.32.20.cable.starman.ee [82.131.32.20]) by mx1.starman.ee (Postfix) with ESMTP id 68F1C3F4113; Mon, 30 Nov 2009 00:19:13 +0200 (EET) From: Juri Linkov To: Lennart Borgman Cc: Stefan Monnier , 5062@debbugs.gnu.org, Tassilo Horn , Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Organization: JURTA References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> Date: Mon, 30 Nov 2009 00:08:59 +0200 In-Reply-To: (Lennart Borgman's message of "Sun, 29 Nov 2009 23:00:53 +0100") Message-ID: <87einh7zlw.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit >> IIRC auto-mode-alist can point to minor-modes (the auto-mode-alist entry >> needs to look something like ("regexp" minor-mode t)), but I don't think >> it can be used here (the constraints on how it can be used are very >> strict since it needs to "consume" a suffix and be called before the >> major-mode).  Maybe we could extend auto-mode-alist to allow things like >> ("regexp" (major-mode minor-mode-1 minor-mode-2 ...)). > > Or just define a derived mode that does major-mode + minor-mode and > use that in auto-mode-alist? That's what I did in the previous patch where `image-mode-maybe' is a combination of a non-image major mode (`normal-mode' with image-mode entries removed from `auto-mode-alist') and `image-minor-mode'. Or did you mean a joint mode like `c-mode-and-image-minor-mode', `nxml-mode-and-image-minor-mode', `ps-mode-and-doc-view-minor-mode'? Wouldn't this be too clumsy? -- Juri Linkov http://www.jurta.org/emacs/ From lennart.borgman@gmail.com Sun Nov 29 15:16:40 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 29 Nov 2009 23:16:40 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.3 required=4.0 tests=AWL,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from mail-yw0-f196.google.com (mail-yw0-f196.google.com [209.85.211.196]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nATNGcBp025787 for <5062@emacsbugs.donarmstrong.com>; Sun, 29 Nov 2009 15:16:40 -0800 Received: by ywh34 with SMTP id 34so2521984ywh.1 for <5062@emacsbugs.donarmstrong.com>; Sun, 29 Nov 2009 15:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type; bh=SFY6zRDbY1TNjXz21pmCogqm4oTY7Sg6YddF8Nl+98s=; b=udm1HYFuOjEbTO8HF6gPNHAtFR+DEsNGX+yAsPY+5/0IYtP/HMWzvfSjETJBPqzH1b Fc3AJ+wWl85v5SNthu8vfwzxJyCcrkTmzOKG1JElCLS7EP6YGiG21cWpVWQJg78zpNK8 ozrIzbkmgmmhX/8MXuZ2swNYTi1oh56vdAr6c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=Oh95bFjO+tfQ+4mO7xDp+Rv6N+jdJcBRmN5eSrEeB6dhPffpgTyiBx48Exjz+lqJKK f0D0tfuYM1LBy3RI88LHBciWj+zHw4fxHKviB9TPXNBpNG2lP3xogTh2MLyZBN8mSWBJ rHDnzXICgH/NmjLsETF2dTEr31gI8w344cnn8= MIME-Version: 1.0 Received: by 10.101.210.36 with SMTP id m36mr1234003anq.158.1259536593110; Sun, 29 Nov 2009 15:16:33 -0800 (PST) In-Reply-To: <87einh7zlw.fsf@mail.jurta.org> References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> <87einh7zlw.fsf@mail.jurta.org> From: Lennart Borgman Date: Mon, 30 Nov 2009 00:16:13 +0100 Message-ID: Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map To: Juri Linkov Cc: Stefan Monnier , 5062@debbugs.gnu.org, Tassilo Horn , Brent Goodrick Content-Type: text/plain; charset=UTF-8 On Sun, Nov 29, 2009 at 11:08 PM, Juri Linkov wrote: >> >> Or just define a derived mode that does major-mode + minor-mode and >> use that in auto-mode-alist? > > That's what I did in the previous patch where `image-mode-maybe' is > a combination of a non-image major mode (`normal-mode' with image-mode > entries removed from `auto-mode-alist') and `image-minor-mode'. > > Or did you mean a joint mode like `c-mode-and-image-minor-mode', > `nxml-mode-and-image-minor-mode', `ps-mode-and-doc-view-minor-mode'? > Wouldn't this be too clumsy? Yes, why would it be too clumsy? A more flexibel way might be to use define-globalized-minor-mode. The turn on function there could make any check. It could for example look in a list similar to auto-mode-alist, but for minor modes. But maybe that would take too long time? From juri@jurta.org Wed Dec 2 17:19:38 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 3 Dec 2009 01:19:39 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-1.8 required=4.0 tests=AWL,FVGT_m_MULTI_ODD, HAS_BUG_NUMBER,IMPRONONCABLE_2,MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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 nB31Jahs004202 for <5062@emacsbugs.donarmstrong.com>; Wed, 2 Dec 2009 17:19:38 -0800 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Received: from mail.starman.ee (62.65.209.27.cable.starman.ee [62.65.209.27]) by mx2.starman.ee (Postfix) with ESMTP id 0ABCD3F409D; Thu, 3 Dec 2009 03:19:28 +0200 (EET) From: Juri Linkov To: Stefan Monnier Cc: 5062@debbugs.gnu.org, Tassilo Horn , Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Organization: JURTA References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> Date: Thu, 03 Dec 2009 02:57:45 +0200 In-Reply-To: (Stefan Monnier's message of "Sun, 29 Nov 2009 13:33:06 -0500") Message-ID: <87hbs8zx0u.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii >> But using the same handling of major/minor modes >> would be good. The patch below leaves the role for `image-minor-mode' >> to only provide the `C-c C-c' binding, and also toggles between >> `image-mode' and `image-mode-maybe' in `image-toggle-display' . > > I haven't looked in detail (partly because it doesn't apply to the > current code because of some other change I installed in the mean time), > but it looks good. Since feature freeze is postponed waiting for Alan's code (or maybe bug#5062 counts as a bug fix, but anyway) below is a patch to push to savannah. It refactors image-mode.el to assign clean roles to the following modes and functions: image-mode - major mode that displays a file as an image. When there are an error during mode activation (either a display does not support images, an invalid image file, etc.), it switches to normal-mode + image-minor-mode and displays an error message. It uses your latest change to exit more gracefully when the image cannot be displayed. image-minor-mode - provides the `C-c C-c' key binding to toggle image display. image-mode-maybe - finds a non-image mode in `auto-mode-alist' and activates it, also activates `image-minor-mode'. (`image-mode-maybe' is not a good name, but it's kept for backward compatibility). image-toggle-display-text - cleans the current buffer from image properties. image-toggle-display-image - puts image properties to display the image. image-toggle-display - toggles between `image-mode' and `image-mode-maybe'. In `auto-mode-alist', `image-mode-maybe' is replaced with `image-mode' to restore the old 23.1 behavior of displaying the image initially. If this is ok, I'm ready to update docstrings and commit. # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: juri@jurta.org-20091203005706-u7yip52y4ylskpuc # target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk # testament_sha1: 30ead91e8155b5927110d672c076120376776503 # timestamp: 2009-12-03 02:57:15 +0200 # base_revision_id: handa@m17n.org-20091202080102-2jb3nd78wntfodbr # # Begin patch === modified file 'lisp/image-mode.el' --- lisp/image-mode.el 2009-11-28 20:45:19 +0000 +++ lisp/image-mode.el 2009-12-03 00:57:06 +0000 @@ -42,10 +42,10 @@ ;;;###autoload (push (cons (purecopy "\\.p[bpgn]m\\'") 'image-mode) auto-mode-alist) ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'c-mode) auto-mode-alist) -;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'image-mode-maybe) auto-mode-alist) +;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'image-mode) auto-mode-alist) ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'xml-mode) auto-mode-alist) -;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'image-mode-maybe) auto-mode-alist) +;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'image-mode) auto-mode-alist) ;;; Image mode window-info management. @@ -286,6 +286,9 @@ This variable is used to display the current image type in the mode line.") (make-variable-buffer-local 'image-type) +(defvar image-mode-previous-major-mode nil + "Internal variable to keep the previous non-image major mode.") + (defvar image-mode-map (let ((map (make-sparse-keymap))) (suppress-keymap map) @@ -306,7 +309,7 @@ map) "Major mode keymap for viewing images in Image mode.") -(defvar image-mode-text-map +(defvar image-minor-mode-map (let ((map (make-sparse-keymap))) (define-key map "\C-c\C-c" 'image-toggle-display) map) @@ -320,68 +323,58 @@ You can use \\\\[image-toggle-display] to toggle between display as an image and display as text." (interactive) - (kill-all-local-variables) - (setq major-mode 'image-mode) - ;; Use our own bookmarking function for images. - (set (make-local-variable 'bookmark-make-record-function) - 'image-bookmark-make-record) - - ;; Keep track of [vh]scroll when switching buffers - (image-mode-setup-winprops) - - (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) - (if (display-images-p) - (if (not (image-get-display-property)) - (image-toggle-display) - ;; Set next vars when image is already displayed but local - ;; variables were cleared by kill-all-local-variables + (condition-case err + (progn + (unless (display-images-p) + (error "Display does not support images")) + + (kill-all-local-variables) + (setq major-mode 'image-mode) + + (if (not (image-get-display-property)) + (progn + (image-toggle-display-image) + ;; If attempt to display image fails. + (if (not (image-get-display-property)) + (error "Invalid image file"))) + ;; Set next vars when image is already displayed but local + ;; variables were cleared by kill-all-local-variables + (setq cursor-type nil truncate-lines t + image-type (plist-get (cdr (image-get-display-property)) :type))) + + ;; Use our own bookmarking function for images. + (set (make-local-variable 'bookmark-make-record-function) + 'image-bookmark-make-record) + + ;; Keep track of [vh]scroll when switching buffers + (image-mode-setup-winprops) + (use-local-map image-mode-map) - (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)) - (setq mode-name (format "Image[%s]" image-type)) - (run-mode-hooks 'image-mode-hook) - (if (display-images-p) - (message "%s" (concat - (substitute-command-keys - "Type \\[image-toggle-display] to view as ") - (if (image-get-display-property) - "text" "an image") ".")))) + (setq mode-name (if image-type (format "Image[%s]" image-type) "Image")) + (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) + (run-mode-hooks 'image-mode-hook) + (message "%s" (concat + (substitute-command-keys + "Type \\[image-toggle-display] to view as ") + (if (image-get-display-property) + "text" "an image") "."))) + (error + (image-mode-maybe) + (funcall + (if (called-interactively-p 'any) 'error 'message) + "Cannot display image: %s" (cdr err))))) ;;;###autoload (define-minor-mode image-minor-mode "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 (if image-type (format " Image[%s]" image-type) " Image")) + image-minor-mode-map :group 'image :version "22.1" - (if (not image-minor-mode) - (image-toggle-display-text) - (image-mode-setup-winprops) - (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t) - (if (display-images-p) - (condition-case err - (progn - (if (not (image-get-display-property)) - (image-toggle-display) - (setq cursor-type nil truncate-lines t - image-type (plist-get (cdr (image-get-display-property)) - :type))) - (message "%s" - (concat - (substitute-command-keys - "Type \\[image-toggle-display] to view the image as ") - (if (image-get-display-property) - "text" "an image") "."))) - (error - (image-toggle-display-text) - (funcall - (if (called-interactively-p 'any) 'error 'message) - "Cannot display image: %s" (cdr err)))) - (setq image-type "text") - (use-local-map image-mode-text-map)))) + (if image-minor-mode + (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t))) ;;;###autoload (defun image-mode-maybe () @@ -394,94 +387,102 @@ See commands `image-mode' and `image-minor-mode' for more information on these modes." (interactive) - (let* ((mode-alist - (delq nil (mapcar - (lambda (elt) - (unless (memq (or (car-safe (cdr elt)) (cdr elt)) - '(image-mode image-mode-maybe)) - elt)) - auto-mode-alist)))) - (if (assoc-default buffer-file-name mode-alist 'string-match) - (let ((auto-mode-alist mode-alist) - (magic-mode-alist nil)) - (set-auto-mode) - (image-minor-mode t)) - (image-mode)))) + ;; image-mode-maybe = normal-mode + image-minor-mode + (let ((previous-image-type image-type)) ; preserve `image-type' + (if image-mode-previous-major-mode + ;; Restore previous major mode that was already found by this + ;; function and cached in `image-mode-previous-major-mode' + (funcall image-mode-previous-major-mode) + (let ((auto-mode-alist + (delq nil (mapcar + (lambda (elt) + (unless (memq (or (car-safe (cdr elt)) (cdr elt)) + '(image-mode image-mode-maybe)) + elt)) + auto-mode-alist))) + (magic-fallback-mode-alist + (delq nil (mapcar + (lambda (elt) + (unless (memq (or (car-safe (cdr elt)) (cdr elt)) + '(image-mode image-mode-maybe)) + elt)) + magic-fallback-mode-alist)))) + (normal-mode) + (set (make-local-variable 'image-mode-previous-major-mode) major-mode))) + (image-minor-mode 1) + (image-toggle-display-text) + ;; Restore `image-type' after `kill-all-local-variables' in `normal-mode'. + (setq image-type previous-image-type))) (defun image-toggle-display-text () "Showing the text of the image file." - (if (image-get-display-property) - (image-toggle-display))) + (let ((inhibit-read-only t) + (buffer-undo-list t) + (modified (buffer-modified-p))) + (remove-list-of-text-properties (point-min) (point-max) + '(display intangible read-nonsticky + read-only front-sticky)) + (set-buffer-modified-p modified) + (if (called-interactively-p 'any) + (message "Repeat this command to go back to displaying the image")))) (defvar archive-superior-buffer) (defvar tar-superior-buffer) (declare-function image-refresh "image.c" (spec &optional frame)) +(defun image-toggle-display-image () + "Showing the image of the image file." + ;; Turn the image data into a real image, but only if the whole file + ;; was inserted + (let* ((filename (buffer-file-name)) + (data-p (not (and filename + (file-readable-p filename) + (not (file-remote-p filename)) + (not (buffer-modified-p)) + (not (and (boundp 'archive-superior-buffer) + archive-superior-buffer)) + (not (and (boundp 'tar-superior-buffer) + tar-superior-buffer))))) + (file-or-data (if data-p + (string-make-unibyte + (buffer-substring-no-properties (point-min) (point-max))) + filename)) + (type (image-type file-or-data nil data-p)) + (image (create-image file-or-data type data-p)) + (props + `(display ,image + intangible ,image + rear-nonsticky (display intangible) + read-only t front-sticky (read-only))) + (inhibit-read-only t) + (buffer-undo-list t) + (modified (buffer-modified-p))) + (image-refresh image) + (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file + (add-text-properties (point-min) (point-max) props) + (restore-buffer-modified-p modified)) + ;; Inhibit the cursor when the buffer contains only an image, + ;; because cursors look very strange on top of images. + (setq cursor-type nil) + ;; This just makes the arrow displayed in the right fringe + ;; area look correct when the image is wider than the window. + (setq truncate-lines t) + ;; Allow navigation of large images + (set (make-local-variable 'auto-hscroll-mode) nil) + (setq image-type type) + (if (eq major-mode 'image-mode) + (setq mode-name (format "Image[%s]" type))) + (if (called-interactively-p 'any) + (message "Repeat this command to go back to displaying the file as text")))) + (defun image-toggle-display () "Start or stop displaying an image file as the actual image. This command toggles between showing the text of the image file and showing the image as an image." (interactive) (if (image-get-display-property) - (let ((inhibit-read-only t) - (buffer-undo-list t) - (modified (buffer-modified-p))) - (remove-list-of-text-properties (point-min) (point-max) - '(display intangible read-nonsticky - read-only front-sticky)) - (set-buffer-modified-p modified) - (kill-local-variable 'cursor-type) - (kill-local-variable 'truncate-lines) - (kill-local-variable 'auto-hscroll-mode) - (use-local-map image-mode-text-map) - (setq image-type "text") - (if (eq major-mode 'image-mode) - (setq mode-name "Image[text]")) - (if (called-interactively-p 'any) - (message "Repeat this command to go back to displaying the image"))) - ;; Turn the image data into a real image, but only if the whole file - ;; was inserted - (let* ((filename (buffer-file-name)) - (data-p (not (and filename - (file-readable-p filename) - (not (file-remote-p filename)) - (not (buffer-modified-p)) - (not (and (boundp 'archive-superior-buffer) - archive-superior-buffer)) - (not (and (boundp 'tar-superior-buffer) - tar-superior-buffer))))) - (file-or-data (if data-p - (string-make-unibyte - (buffer-substring-no-properties (point-min) (point-max))) - filename)) - (type (image-type file-or-data nil data-p)) - (image (create-image file-or-data type data-p)) - (props - `(display ,image - intangible ,image - rear-nonsticky (display intangible) - read-only t front-sticky (read-only))) - (inhibit-read-only t) - (buffer-undo-list t) - (modified (buffer-modified-p))) - (image-refresh image) - (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file - (add-text-properties (point-min) (point-max) props) - (restore-buffer-modified-p modified)) - ;; Inhibit the cursor when the buffer contains only an image, - ;; because cursors look very strange on top of images. - (setq cursor-type nil) - ;; This just makes the arrow displayed in the right fringe - ;; area look correct when the image is wider than the window. - (setq truncate-lines t) - ;; Allow navigation of large images - (set (make-local-variable 'auto-hscroll-mode) nil) - (use-local-map image-mode-map) - (setq image-type type) - (if (eq major-mode 'image-mode) - (setq mode-name (format "Image[%s]" type))) - (if (called-interactively-p 'any) - (message "Repeat this command to go back to displaying the file as text"))))) + (image-mode-maybe) + (image-mode))) ;;; Support for bookmark.el (declare-function bookmark-make-record-default "bookmark" -- Juri Linkov http://www.jurta.org/emacs/ From juri@jurta.org Wed Dec 2 17:19:40 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 3 Dec 2009 01:19:40 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.2 required=4.0 tests=AWL,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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 nB31JcR8004203 for <5062@emacsbugs.donarmstrong.com>; Wed, 2 Dec 2009 17:19:39 -0800 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Received: from mail.starman.ee (62.65.209.27.cable.starman.ee [62.65.209.27]) by mx2.starman.ee (Postfix) with ESMTP id 400C43F40B0; Thu, 3 Dec 2009 03:19:32 +0200 (EET) From: Juri Linkov To: Lennart Borgman Cc: Stefan Monnier , 5062@debbugs.gnu.org, Tassilo Horn , Brent Goodrick Subject: Re: bug#5062: image-toggle-display overwrites nxml-mode local key map In-Reply-To: (Lennart Borgman's message of "Mon, 30 Nov 2009 00:16:13 +0100") Organization: JURTA References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> <87einh7zlw.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) Date: Thu, 03 Dec 2009 02:59:16 +0200 Message-ID: <87ws15m3gb.fsf@mail.jurta.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii >> Or did you mean a joint mode like `c-mode-and-image-minor-mode', >> `nxml-mode-and-image-minor-mode', `ps-mode-and-doc-view-minor-mode'? >> Wouldn't this be too clumsy? > > Yes, why would it be too clumsy? > > A more flexibel way might be to use define-globalized-minor-mode. The > turn on function there could make any check. It could for example look > in a list similar to auto-mode-alist, but for minor modes. > > But maybe that would take too long time? I think Stefan's idea of allowing auto-mode-alist to have entries like ("regexp" (major-mode minor-mode-1 minor-mode-2 ...)) is more universal. Two basic ways to specify modes are: 1. With Local Variables you can put in the first line -*- mode: major-mode; mode: minor-mode-1; mode: minor-mode-2; ... -*- or the same to the Local Variables list, or to the Directory Local Variables. 2. With `auto-mode-alist' you can bind filename patterns to major modes, but not to minor modes. (major-mode minor-mode-1 minor-mode-2 ...) would allow to do the same that Local Variables already allows to do, e.g. ("\\.xpm\\'" (c-mode image-minor-mode)), ("\\.svg\\'" (nxml-mode image-minor-mode)), ("\\.ps\\'" (ps-mode doc-view-minor-mode)), etc. PS: this feature currently is not too necessary, because in the patch I sent `image-mode-maybe' was replaced with `image-mode' in `auto-mode-alist' to display a file as an image by default (the default behavior in 23.1). And only if someone wants to change this default to display a file as text initially, this requires either adding `image-mode-maybe' to `auto-mode-alist' or a combination of normal-mode + image-minor-mode that can be implemented as a new feature. -- Juri Linkov http://www.jurta.org/emacs/ From lennart.borgman@gmail.com Wed Dec 2 17:38:09 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 3 Dec 2009 01:38:09 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.3 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from mail-yw0-f196.google.com (mail-yw0-f196.google.com [209.85.211.196]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nB31c7kJ005720 for <5062@emacsbugs.donarmstrong.com>; Wed, 2 Dec 2009 17:38:08 -0800 Received: by ywh34 with SMTP id 34so799975ywh.1 for <5062@emacsbugs.donarmstrong.com>; Wed, 02 Dec 2009 17:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type; bh=BCJ7NyDOgTsjJiVyl24HX8LJ7F1MvwfULU30zhLHOVs=; b=UVSyMF64Wyc7KAVQYU1Zu73VyJMudDuptssLYGE846+KtSuXwuyXWXK5gyABreIv5H LpJ4T/9SKusntNvDdUnMu47d7xLzdsawFOTwmTeFwfDyds+ZKQe/t1DQDWD1TBmiX48v U1et3O17jM869GSZcXGGQ7Ct03tChWQc31NHo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=xZafsdEivTAf3uB9li7LWhogJBBGVEzsR+m9QTPeZIhs15We38zACSSXtTMgW80brM 4gLUUUQ5mu0WHr7AoLAqB0IurUCGkOJTWXuaYy+0hJMWsAkJETNM0vA+wHJXeHku+cRK XWh/qHniGOs3aYoJSvljGkIDYqXgcT63e5mCM= MIME-Version: 1.0 Received: by 10.100.29.33 with SMTP id c33mr1150159anc.175.1259804282079; Wed, 02 Dec 2009 17:38:02 -0800 (PST) In-Reply-To: <87ws15m3gb.fsf@mail.jurta.org> References: <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> <87einh7zlw.fsf@mail.jurta.org> <87ws15m3gb.fsf@mail.jurta.org> From: Lennart Borgman Date: Thu, 3 Dec 2009 02:37:42 +0100 Message-ID: Subject: Re: bug#5062: image-toggle-display overwrites nxml-mode local key map To: Juri Linkov Cc: Stefan Monnier , 5062@debbugs.gnu.org, Tassilo Horn , Brent Goodrick Content-Type: text/plain; charset=UTF-8 On Thu, Dec 3, 2009 at 1:59 AM, Juri Linkov wrote: >>> Or did you mean a joint mode like `c-mode-and-image-minor-mode', >>> `nxml-mode-and-image-minor-mode', `ps-mode-and-doc-view-minor-mode'? >>> Wouldn't this be too clumsy? >> >> Yes, why would it be too clumsy? >> >> A more flexibel way might be to use define-globalized-minor-mode. The >> turn on function there could make any check. It could for example look >> in a list similar to auto-mode-alist, but for minor modes. >> >> But maybe that would take too long time? > > I think Stefan's idea of allowing auto-mode-alist to have entries like > ("regexp" (major-mode minor-mode-1 minor-mode-2 ...)) is more universal. Why not allow a form there then: ("regexp" '(progn (major-mode) (mino-mode-1 1) (minor-mode-2 1) ...)) From geb-bug-gnu-emacs@m.gmane.org Wed Dec 2 19:10:59 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 3 Dec 2009 03:11:00 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.9 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nB33Av0k014267 for ; Wed, 2 Dec 2009 19:10:59 -0800 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NG25p-00085K-73 for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2009 22:10:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NG25k-0007vG-Ct for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2009 22:10:56 -0500 Received: from [199.232.76.173] (port=39566 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NG25k-0007v5-8z for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2009 22:10:52 -0500 Received: from lo.gmane.org ([80.91.229.12]:36110) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NG25j-000533-U9 for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2009 22:10:52 -0500 Received: from list by lo.gmane.org with local (Exim 4.50) id 1NG24g-0001kj-8y for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2009 04:09:46 +0100 Received: from c-71-237-24-138.hsd1.co.comcast.net ([71.237.24.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Dec 2009 04:09:46 +0100 Received: from kevin.d.rodgers by c-71-237-24-138.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Dec 2009 04:09:46 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: Kevin Rodgers Subject: Re: bug#5062: image-toggle-display overwrites nxml-mode local key map Date: Wed, 02 Dec 2009 20:08:53 -0700 Lines: 26 Message-ID: References: <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> <87einh7zlw.fsf@mail.jurta.org> <87ws15m3gb.fsf@mail.jurta.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-71-237-24-138.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) In-Reply-To: Sender: news X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Lennart Borgman wrote: > On Thu, Dec 3, 2009 at 1:59 AM, Juri Linkov wrote: >>>> Or did you mean a joint mode like `c-mode-and-image-minor-mode', >>>> `nxml-mode-and-image-minor-mode', `ps-mode-and-doc-view-minor-mode'? >>>> Wouldn't this be too clumsy? >>> Yes, why would it be too clumsy? >>> >>> A more flexibel way might be to use define-globalized-minor-mode. The >>> turn on function there could make any check. It could for example look >>> in a list similar to auto-mode-alist, but for minor modes. >>> >>> But maybe that would take too long time? >> I think Stefan's idea of allowing auto-mode-alist to have entries like >> ("regexp" (major-mode minor-mode-1 minor-mode-2 ...)) is more universal. > > > Why not allow a form there then: > > ("regexp" '(progn (major-mode) (mino-mode-1 1) (minor-mode-2 1) ...)) Because it's no longer a declarative data structure that can be queried and modified, rather an imperative program. -- Kevin Rodgers Denver, Colorado, USA From monnier@iro.umontreal.ca Wed Dec 2 19:28:23 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 3 Dec 2009 03:28:23 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.8 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from ironport2-out.pppoe.ca (ironport2-out.teksavvy.com [206.248.154.181]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nB33SLIR015503 for <5062@emacsbugs.donarmstrong.com>; Wed, 2 Dec 2009 19:28:23 -0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqEEAFS/FktFpZ1E/2dsb2JhbACBTtY8hDEEihk X-IronPort-AV: E=Sophos;i="4.47,332,1257138000"; d="scan'208";a="50563031" Received: from 69-165-157-68.dsl.teksavvy.com (HELO pastel.home) ([69.165.157.68]) by ironport2-out.pppoe.ca with ESMTP; 02 Dec 2009 22:28:15 -0500 Received: by pastel.home (Postfix, from userid 20848) id 6DC3186C4; Wed, 2 Dec 2009 22:28:15 -0500 (EST) From: Stefan Monnier To: Juri Linkov Cc: 5062@debbugs.gnu.org, Tassilo Horn , Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Message-ID: References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> <87hbs8zx0u.fsf@mail.jurta.org> Date: Wed, 02 Dec 2009 22:28:15 -0500 In-Reply-To: <87hbs8zx0u.fsf@mail.jurta.org> (Juri Linkov's message of "Thu, 03 Dec 2009 02:57:45 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > If this is ok, I'm ready to update docstrings and commit. Looks good, thank you, Stefan From monnier@iro.umontreal.ca Wed Dec 2 19:30:15 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 3 Dec 2009 03:30:16 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.8 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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 nB33UETI015674 for <5062@emacsbugs.donarmstrong.com>; Wed, 2 Dec 2009 19:30:15 -0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqEEAFS/FktFpZ1E/2dsb2JhbACBTtY8hDEEihk X-IronPort-AV: E=Sophos;i="4.47,332,1257138000"; d="scan'208";a="50563176" Received: from 69-165-157-68.dsl.teksavvy.com (HELO pastel.home) ([69.165.157.68]) by ironport2-out.pppoe.ca with ESMTP; 02 Dec 2009 22:30:08 -0500 Received: by pastel.home (Postfix, from userid 20848) id 9E11886C4; Wed, 2 Dec 2009 22:30:08 -0500 (EST) From: Stefan Monnier To: Lennart Borgman Cc: Juri Linkov , 5062@debbugs.gnu.org, Tassilo Horn , Brent Goodrick Subject: Re: bug#5062: image-toggle-display overwrites nxml-mode local key map Message-ID: References: <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> <87einh7zlw.fsf@mail.jurta.org> <87ws15m3gb.fsf@mail.jurta.org> Date: Wed, 02 Dec 2009 22:30:08 -0500 In-Reply-To: (Lennart Borgman's message of "Thu, 3 Dec 2009 02:37:42 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii >>>> Or did you mean a joint mode like `c-mode-and-image-minor-mode', >>>> `nxml-mode-and-image-minor-mode', `ps-mode-and-doc-view-minor-mode'? >>>> Wouldn't this be too clumsy? >>> >>> Yes, why would it be too clumsy? >>> >>> A more flexibel way might be to use define-globalized-minor-mode. The >>> turn on function there could make any check. It could for example look >>> in a list similar to auto-mode-alist, but for minor modes. >>> >>> But maybe that would take too long time? >> >> I think Stefan's idea of allowing auto-mode-alist to have entries like >> ("regexp" (major-mode minor-mode-1 minor-mode-2 ...)) is more universal. > Why not allow a form there then: > ("regexp" '(progn (major-mode) (mino-mode-1 1) (minor-mode-2 1) ...)) Because you can already do it just fine: (defun myfoo () (major-mode) (mino-mode-1 1) (minor-mode-2 1)) [...] ("regexp" . myfoo) -- Stefan From lennart.borgman@gmail.com Wed Dec 2 19:31:45 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 3 Dec 2009 03:31:45 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-1.8 required=4.0 tests=AWL,GMAIL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nB33VhgF015888 for ; Wed, 2 Dec 2009 19:31:44 -0800 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NG2Pv-0004MK-8R for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2009 22:31:43 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NG2Pp-0004CR-Ey for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2009 22:31:41 -0500 Received: from [199.232.76.173] (port=48004 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NG2Pp-0004Bx-8F for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2009 22:31:37 -0500 Received: from mail-yw0-f172.google.com ([209.85.211.172]:38904) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NG2Po-0006ig-SN for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2009 22:31:37 -0500 Received: by ywh2 with SMTP id 2so946890ywh.27 for ; Wed, 02 Dec 2009 19:31:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=mj7LZ9AYHVpkbyF5I9NorMdRy6Z6k3BJv5Yu/EZyzdw=; b=nUwiFvez4gmdkhegi3h5IgSV2fgQfcgdR3hE6d+VdgPVnTBaDPtGMS3tzHhmPCzADi iXtUU8Up4IjfCMBauQK+PsSc4Ww1yrda04+Ps0nCdzXJ1/eczep489NZktb8zzML9dJc xkQU2FT0xB4VkRtvVfMLNsVCAnHyls9FgPNPg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=nlyexPkYtShqXlR1pZyS0eYtlnIx+R++tze1zq9QMOUJ9VVZ3O9ViK9oakQLdeu35A 6WJAlnxsl7+MiaxT3+tjzlmgM+s5ZUNccQlC2QSovoFOsKl/A/LSD0IkIxdpEBAxnpiz 3m+SJ7isPv/8vRSB1kTpwk6PM7qSkO1Vo/1Lk= MIME-Version: 1.0 Received: by 10.100.233.35 with SMTP id f35mr1234609anh.41.1259811095135; Wed, 02 Dec 2009 19:31:35 -0800 (PST) In-Reply-To: References: <87fx7x5np9.fsf@mail.jurta.org> <87einh7zlw.fsf@mail.jurta.org> <87ws15m3gb.fsf@mail.jurta.org> From: Lennart Borgman Date: Thu, 3 Dec 2009 04:31:15 +0100 Message-ID: Subject: Re: bug#5062: image-toggle-display overwrites nxml-mode local key map To: Kevin Rodgers , 5062@debbugs.gnu.org Cc: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) On Thu, Dec 3, 2009 at 4:08 AM, Kevin Rodgers w= rote: > Lennart Borgman wrote: >> >> On Thu, Dec 3, 2009 at 1:59 AM, Juri Linkov wrote: >>>>> >>>>> Or did you mean a joint mode like `c-mode-and-image-minor-mode', >>>>> `nxml-mode-and-image-minor-mode', `ps-mode-and-doc-view-minor-mode'? >>>>> Wouldn't this be too clumsy? >>>> >>>> Yes, why would it be too clumsy? >>>> >>>> A more flexibel way might be to use define-globalized-minor-mode. The >>>> turn on function there could make any check. It could for example look >>>> in a list similar to auto-mode-alist, but for minor modes. >>>> >>>> But maybe that would take too long time? >>> >>> I think Stefan's idea of allowing auto-mode-alist to have entries like >>> ("regexp" (major-mode minor-mode-1 minor-mode-2 ...)) is more universal= . >> >> >> Why not allow a form there then: >> >> =C2=A0 ("regexp" '(progn (major-mode) (mino-mode-1 1) (minor-mode-2 1) .= ..)) > > Because it's no longer a declarative data structure that can be queried a= nd > modified, rather an imperative program. Hm, yes. I use to think it is bad to put a (lambda () ...) in a hook, because you may want to remove it later. And actually I do modify this list to in majmodpri.el so you are right. A simple format is better. From jasonrumney@gmail.com Wed Dec 2 21:01:38 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 3 Dec 2009 05:01:38 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-4.2 required=4.0 tests=AWL,FOURLA,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from mail-yx0-f190.google.com (mail-yx0-f190.google.com [209.85.210.190]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nB351arJ023704 for <5062@emacsbugs.donarmstrong.com>; Wed, 2 Dec 2009 21:01:38 -0800 Received: by yxe28 with SMTP id 28so910134yxe.19 for <5062@emacsbugs.donarmstrong.com>; Wed, 02 Dec 2009 21:01:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=SgN6KMa7vYryWs/KvLPQEkApHBgCOU2ErrFEDu3ld10=; b=K+lDPxl5DUzD9ISu1N8gbUtw22/iGDiB46ouF0cD8P3m7N5Y4rQpGdOaxQPRlJLhJm GGg9Werc6k6cR/QGQKg4dcwK8iHmY79k79TXo22iGmIs8NQt5+tBxEduQojkXHu8gotO b9Ws8O/ycufHDPCQH4CO9niGtykwfDG9WQ3Dc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=hiYyOXi9VqN1qiFX6lvv3/VAZ+/reLgai1kem09tnzfIIp4IA+cDMf+yJ3j7PfJDH5 leSDWmpIqteHr83A2BabnXbMOMa/rvqAHbbEflCfb849b96WcXBad1krC7SZuV6cgFNU c4v99CxNlVtnwmaWJiwXo5+2ofxB6Pu8ScKws= Received: by 10.150.174.8 with SMTP id w8mr1956151ybe.204.1259816485811; Wed, 02 Dec 2009 21:01:25 -0800 (PST) Received: from ?10.1.1.112? ([61.4.103.130]) by mx.google.com with ESMTPS id 4sm699629ywi.12.2009.12.02.21.01.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 02 Dec 2009 21:01:22 -0800 (PST) Sender: Jason Rumney Message-ID: <4B1745EE.5010401@f2s.com> Date: Thu, 03 Dec 2009 13:00:30 +0800 From: Jason Rumney User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Juri Linkov , 5062@debbugs.gnu.org CC: Stefan Monnier , Tassilo Horn , Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> <87hbs8zx0u.fsf@mail.jurta.org> In-Reply-To: <87hbs8zx0u.fsf@mail.jurta.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Juri Linkov wrote: > image-mode-maybe - finds a non-image mode in `auto-mode-alist' and > activates it, also activates `image-minor-mode'. (`image-mode-maybe' > is not a good name, but it's kept for backward compatibility). > It seems like you are changing the behavior incompatibly, so why keep the name? IIRC the original intention for image-mode-maybe was to use a non-image mode from auto-mode-alist if it existed, otherwise use image-mode. It originated when we were detecting images with magic-mode-alist, which was higher priority than auto-mode-alist. From juri@jurta.org Thu Dec 3 16:27:47 2009 Received: (at 5062) by emacsbugs.donarmstrong.com; 4 Dec 2009 00:27:47 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.6 required=4.0 tests=AWL,FOURLA,FVGT_m_MULTI_ODD, HAS_BUG_NUMBER,MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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 nB40RiBK008886 for <5062@emacsbugs.donarmstrong.com>; Thu, 3 Dec 2009 16:27:46 -0800 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Received: from mail.starman.ee (82.131.30.124.cable.starman.ee [82.131.30.124]) by mx2.starman.ee (Postfix) with ESMTP id 5E4CD3F40D3; Fri, 4 Dec 2009 02:27:37 +0200 (EET) From: Juri Linkov To: Jason Rumney Cc: 5062@debbugs.gnu.org, Stefan Monnier , Tassilo Horn , Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Organization: JURTA References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> <87hbs8zx0u.fsf@mail.jurta.org> <4B1745EE.5010401@f2s.com> Date: Fri, 04 Dec 2009 02:05:02 +0200 In-Reply-To: <4B1745EE.5010401@f2s.com> (Jason Rumney's message of "Thu, 03 Dec 2009 13:00:30 +0800") Message-ID: <871vjbaagx.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii >> image-mode-maybe - finds a non-image mode in `auto-mode-alist' and >> activates it, also activates `image-minor-mode'. (`image-mode-maybe' >> is not a good name, but it's kept for backward compatibility). > > It seems like you are changing the behavior incompatibly, so why keep the > name? IIRC the original intention for image-mode-maybe was to use > a non-image mode from auto-mode-alist if it existed, otherwise use > image-mode. Right, so the patch below makes `image-mode-maybe' obsolete as an alias of `image-mode'. This makes it 99% backward-compatible except for rare cases when somehow `auto-mode-alist' doesn't contain a non-image mode - in this case Fundamental Mode is used. And a new name for the function that is a combination of `normal-mode' + `image-minor-mode' is now `image-mode-as-text'. This name avoids using the suffix `-mode' because it's not a real mode. A CVS patch with these changes and updated docstrings: Index: lisp/image-mode.el =================================================================== RCS file: /sources/emacs/emacs/lisp/image-mode.el,v retrieving revision 1.59 diff -c -r1.59 image-mode.el *** lisp/image-mode.el 28 Nov 2009 20:45:22 -0000 1.59 --- lisp/image-mode.el 4 Dec 2009 00:04:52 -0000 *************** *** 42,51 **** ;;;###autoload (push (cons (purecopy "\\.p[bpgn]m\\'") 'image-mode) auto-mode-alist) ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'c-mode) auto-mode-alist) ! ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'image-mode-maybe) auto-mode-alist) ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'xml-mode) auto-mode-alist) ! ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'image-mode-maybe) auto-mode-alist) ;;; Image mode window-info management. --- 42,51 ---- ;;;###autoload (push (cons (purecopy "\\.p[bpgn]m\\'") 'image-mode) auto-mode-alist) ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'c-mode) auto-mode-alist) ! ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'image-mode) auto-mode-alist) ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'xml-mode) auto-mode-alist) ! ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'image-mode) auto-mode-alist) ;;; Image mode window-info management. *************** *** 286,291 **** --- 286,294 ---- This variable is used to display the current image type in the mode line.") (make-variable-buffer-local 'image-type) + (defvar image-mode-previous-major-mode nil + "Internal variable to keep the previous non-image major mode.") + (defvar image-mode-map (let ((map (make-sparse-keymap))) (suppress-keymap map) *************** *** 306,316 **** 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 bookmark-make-record-function) --- 309,319 ---- map) "Major mode keymap for viewing images in Image mode.") ! (defvar image-minor-mode-map (let ((map (make-sparse-keymap))) (define-key map "\C-c\C-c" 'image-toggle-display) map) ! "Minor mode keymap for viewing images as text in Image mode.") (defvar bookmark-make-record-function) *************** *** 320,487 **** You can use \\\\[image-toggle-display] to toggle between display as an image and display as text." (interactive) ! (kill-all-local-variables) ! (setq major-mode 'image-mode) ! ;; Use our own bookmarking function for images. ! (set (make-local-variable 'bookmark-make-record-function) ! 'image-bookmark-make-record) ! ! ;; Keep track of [vh]scroll when switching buffers ! (image-mode-setup-winprops) ! ! (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) ! (if (display-images-p) ! (if (not (image-get-display-property)) ! (image-toggle-display) ! ;; Set next vars when image is already displayed but local ! ;; variables were cleared by kill-all-local-variables (use-local-map image-mode-map) ! (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)) ! (setq mode-name (format "Image[%s]" image-type)) ! (run-mode-hooks 'image-mode-hook) ! (if (display-images-p) ! (message "%s" (concat ! (substitute-command-keys ! "Type \\[image-toggle-display] to view as ") ! (if (image-get-display-property) ! "text" "an image") ".")))) ;;;###autoload (define-minor-mode image-minor-mode "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 :group 'image :version "22.1" ! (if (not image-minor-mode) ! (image-toggle-display-text) ! (image-mode-setup-winprops) ! (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t) ! (if (display-images-p) ! (condition-case err ! (progn ! (if (not (image-get-display-property)) ! (image-toggle-display) ! (setq cursor-type nil truncate-lines t ! image-type (plist-get (cdr (image-get-display-property)) ! :type))) ! (message "%s" ! (concat ! (substitute-command-keys ! "Type \\[image-toggle-display] to view the image as ") ! (if (image-get-display-property) ! "text" "an image") "."))) ! (error ! (image-toggle-display-text) ! (funcall ! (if (called-interactively-p 'any) 'error 'message) ! "Cannot display image: %s" (cdr err)))) ! (setq image-type "text") ! (use-local-map image-mode-text-map)))) ;;;###autoload ! (defun image-mode-maybe () ! "Set major or minor mode for image files. ! Set Image major mode only when there are no other major modes ! associated with a filename in `auto-mode-alist'. When an image ! filename matches another major mode in `auto-mode-alist' then ! set that major mode and Image minor mode. ! See commands `image-mode' and `image-minor-mode' for more ! information on these modes." (interactive) ! (let* ((mode-alist ! (delq nil (mapcar ! (lambda (elt) ! (unless (memq (or (car-safe (cdr elt)) (cdr elt)) ! '(image-mode image-mode-maybe)) ! elt)) ! auto-mode-alist)))) ! (if (assoc-default buffer-file-name mode-alist 'string-match) ! (let ((auto-mode-alist mode-alist) ! (magic-mode-alist nil)) ! (set-auto-mode) ! (image-minor-mode t)) ! (image-mode)))) (defun image-toggle-display-text () ! "Showing the text of the image file." ! (if (image-get-display-property) ! (image-toggle-display))) (defvar archive-superior-buffer) (defvar tar-superior-buffer) (declare-function image-refresh "image.c" (spec &optional frame)) (defun image-toggle-display () "Start or stop displaying an image file as the actual image. ! This command toggles between showing the text of the image file ! and showing the image as an image." (interactive) (if (image-get-display-property) ! (let ((inhibit-read-only t) ! (buffer-undo-list t) ! (modified (buffer-modified-p))) ! (remove-list-of-text-properties (point-min) (point-max) ! '(display intangible read-nonsticky ! read-only front-sticky)) ! (set-buffer-modified-p modified) ! (kill-local-variable 'cursor-type) ! (kill-local-variable 'truncate-lines) ! (kill-local-variable 'auto-hscroll-mode) ! (use-local-map image-mode-text-map) ! (setq image-type "text") ! (if (eq major-mode 'image-mode) ! (setq mode-name "Image[text]")) ! (if (called-interactively-p 'any) ! (message "Repeat this command to go back to displaying the image"))) ! ;; Turn the image data into a real image, but only if the whole file ! ;; was inserted ! (let* ((filename (buffer-file-name)) ! (data-p (not (and filename ! (file-readable-p filename) ! (not (file-remote-p filename)) ! (not (buffer-modified-p)) ! (not (and (boundp 'archive-superior-buffer) ! archive-superior-buffer)) ! (not (and (boundp 'tar-superior-buffer) ! tar-superior-buffer))))) ! (file-or-data (if data-p ! (string-make-unibyte ! (buffer-substring-no-properties (point-min) (point-max))) ! filename)) ! (type (image-type file-or-data nil data-p)) ! (image (create-image file-or-data type data-p)) ! (props ! `(display ,image ! intangible ,image ! rear-nonsticky (display intangible) ! read-only t front-sticky (read-only))) ! (inhibit-read-only t) ! (buffer-undo-list t) ! (modified (buffer-modified-p))) ! (image-refresh image) ! (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file ! (add-text-properties (point-min) (point-max) props) ! (restore-buffer-modified-p modified)) ! ;; Inhibit the cursor when the buffer contains only an image, ! ;; because cursors look very strange on top of images. ! (setq cursor-type nil) ! ;; This just makes the arrow displayed in the right fringe ! ;; area look correct when the image is wider than the window. ! (setq truncate-lines t) ! ;; Allow navigation of large images ! (set (make-local-variable 'auto-hscroll-mode) nil) ! (use-local-map image-mode-map) ! (setq image-type type) ! (if (eq major-mode 'image-mode) ! (setq mode-name (format "Image[%s]" type))) ! (if (called-interactively-p 'any) ! (message "Repeat this command to go back to displaying the file as text"))))) ;;; Support for bookmark.el (declare-function bookmark-make-record-default "bookmark" --- 323,504 ---- You can use \\\\[image-toggle-display] to toggle between display as an image and display as text." (interactive) ! (condition-case err ! (progn ! (unless (display-images-p) ! (error "Display does not support images")) ! ! (kill-all-local-variables) ! (setq major-mode 'image-mode) ! ! (if (not (image-get-display-property)) ! (progn ! (image-toggle-display-image) ! ;; If attempt to display the image fails. ! (if (not (image-get-display-property)) ! (error "Invalid image"))) ! ;; Set next vars when image is already displayed but local ! ;; variables were cleared by kill-all-local-variables ! (setq cursor-type nil truncate-lines t ! image-type (plist-get (cdr (image-get-display-property)) :type))) ! ! (setq mode-name (if image-type (format "Image[%s]" image-type) "Image")) (use-local-map image-mode-map) ! ! ;; Use our own bookmarking function for images. ! (set (make-local-variable 'bookmark-make-record-function) ! 'image-bookmark-make-record) ! ! ;; Keep track of [vh]scroll when switching buffers ! (image-mode-setup-winprops) ! ! (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) ! (run-mode-hooks 'image-mode-hook) ! (message "%s" (concat ! (substitute-command-keys ! "Type \\[image-toggle-display] to view the image as ") ! (if (image-get-display-property) ! "text" "an image") "."))) ! (error ! (image-mode-as-text) ! (funcall ! (if (called-interactively-p 'any) 'error 'message) ! "Cannot display image: %s" (cdr err))))) ;;;###autoload (define-minor-mode image-minor-mode "Toggle Image minor mode. With arg, turn Image minor mode on if arg is positive, off otherwise. ! It provides the key \\\\[image-toggle-display] \ ! to switch back to `image-mode' ! to display an image file as the actual image." ! nil (:eval (if image-type (format " Image[%s]" image-type) " Image")) ! image-minor-mode-map :group 'image :version "22.1" ! (if image-minor-mode ! (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t))) ;;;###autoload ! (defun image-mode-as-text () ! "Set a non-image mode as major mode in combination with image minor mode. ! A non-image major mode found from `auto-mode-alist' or Fundamental mode ! displays an image file as text. `image-minor-mode' provides the key ! \\\\[image-toggle-display] to switch back to `image-mode' ! to display an image file as the actual image. ! ! You can use `image-mode-as-text' in `auto-mode-alist' when you want ! to display an image file as text inititally. ! See commands `image-mode' and `image-minor-mode' for more information ! on these modes." (interactive) ! ;; image-mode-as-text = normal-mode + image-minor-mode ! (let ((previous-image-type image-type)) ; preserve `image-type' ! (if image-mode-previous-major-mode ! ;; Restore previous major mode that was already found by this ! ;; function and cached in `image-mode-previous-major-mode' ! (funcall image-mode-previous-major-mode) ! (let ((auto-mode-alist ! (delq nil (mapcar ! (lambda (elt) ! (unless (memq (or (car-safe (cdr elt)) (cdr elt)) ! '(image-mode image-mode-maybe image-mode-as-text)) ! elt)) ! auto-mode-alist))) ! (magic-fallback-mode-alist ! (delq nil (mapcar ! (lambda (elt) ! (unless (memq (or (car-safe (cdr elt)) (cdr elt)) ! '(image-mode image-mode-maybe image-mode-as-text)) ! elt)) ! magic-fallback-mode-alist)))) ! (normal-mode) ! (set (make-local-variable 'image-mode-previous-major-mode) major-mode))) ! ;; Restore `image-type' after `kill-all-local-variables' in `normal-mode'. ! (setq image-type previous-image-type) ! ;; Enable image minor mode with `C-c C-c'. ! (image-minor-mode 1) ! ;; Show the image file as text. ! (image-toggle-display-text) ! (message "%s" (concat ! (substitute-command-keys ! "Type \\[image-toggle-display] to view the image as ") ! (if (image-get-display-property) ! "text" "an image") ".")))) ! ! (define-obsolete-function-alias 'image-mode-maybe 'image-mode "23.2") (defun image-toggle-display-text () ! "Show the image file as text. ! Remove text properties that display the image." ! (let ((inhibit-read-only t) ! (buffer-undo-list t) ! (modified (buffer-modified-p))) ! (remove-list-of-text-properties (point-min) (point-max) ! '(display intangible read-nonsticky ! read-only front-sticky)) ! (set-buffer-modified-p modified) ! (if (called-interactively-p 'any) ! (message "Repeat this command to go back to displaying the image")))) (defvar archive-superior-buffer) (defvar tar-superior-buffer) (declare-function image-refresh "image.c" (spec &optional frame)) + (defun image-toggle-display-image () + "Show the image of the image file. + Turn the image data into a real image, but only if the whole file + was inserted." + (let* ((filename (buffer-file-name)) + (data-p (not (and filename + (file-readable-p filename) + (not (file-remote-p filename)) + (not (buffer-modified-p)) + (not (and (boundp 'archive-superior-buffer) + archive-superior-buffer)) + (not (and (boundp 'tar-superior-buffer) + tar-superior-buffer))))) + (file-or-data (if data-p + (string-make-unibyte + (buffer-substring-no-properties (point-min) (point-max))) + filename)) + (type (image-type file-or-data nil data-p)) + (image (create-image file-or-data type data-p)) + (props + `(display ,image + intangible ,image + rear-nonsticky (display intangible) + read-only t front-sticky (read-only))) + (inhibit-read-only t) + (buffer-undo-list t) + (modified (buffer-modified-p))) + (image-refresh image) + (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file + (add-text-properties (point-min) (point-max) props) + (restore-buffer-modified-p modified)) + ;; Inhibit the cursor when the buffer contains only an image, + ;; because cursors look very strange on top of images. + (setq cursor-type nil) + ;; This just makes the arrow displayed in the right fringe + ;; area look correct when the image is wider than the window. + (setq truncate-lines t) + ;; Allow navigation of large images + (set (make-local-variable 'auto-hscroll-mode) nil) + (setq image-type type) + (if (eq major-mode 'image-mode) + (setq mode-name (format "Image[%s]" type))) + (if (called-interactively-p 'any) + (message "Repeat this command to go back to displaying the file as text")))) + (defun image-toggle-display () "Start or stop displaying an image file as the actual image. ! This command toggles between `image-mode-as-text' showing the text of ! the image file and `image-mode' showing the image as an image." (interactive) (if (image-get-display-property) ! (image-mode-as-text) ! (image-mode))) ;;; Support for bookmark.el (declare-function bookmark-make-record-default "bookmark" -- Juri Linkov http://www.jurta.org/emacs/ From juri@jurta.org Fri Dec 4 13:50:44 2009 Received: (at 5062-done) by emacsbugs.donarmstrong.com; 4 Dec 2009 21:50:44 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.7 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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 nB4LogSE030614 for <5062-done@emacsbugs.donarmstrong.com>; Fri, 4 Dec 2009 13:50:43 -0800 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Received: from mail.starman.ee (82.131.30.133.cable.starman.ee [82.131.30.133]) by mx2.starman.ee (Postfix) with ESMTP id AA0393F410B; Fri, 4 Dec 2009 23:50:35 +0200 (EET) From: Juri Linkov To: Stefan Monnier Cc: 5062-done@debbugs.gnu.org, Brent Goodrick Subject: Re: bug#5062: 23.1.50; image-toggle-display overwrites nxml-mode local key map Organization: JURTA References: <87einifskr.fsf@mail.jurta.org> <87bpim8d5b.fsf@mail.jurta.org> <87fx7x5np9.fsf@mail.jurta.org> <87hbs8zx0u.fsf@mail.jurta.org> Date: Fri, 04 Dec 2009 23:47:30 +0200 In-Reply-To: (Stefan Monnier's message of "Wed, 02 Dec 2009 22:28:15 -0500") Message-ID: <878wdixvgt.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii >> If this is ok, I'm ready to update docstrings and commit. > > Looks good, thank you, Done. -- Juri Linkov http://www.jurta.org/emacs/ From unknown Tue Jun 24 15:42:55 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 29 Jan 2010 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # A New Hope # A long time ago, in a galaxy far, far away # something happened. # # Magically this resulted in the following # action being taken, but this fake control # message doesn't tell you why it happened # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator