annotate lisp/image-mode.el @ 110410:f2e111723c3a

Merge changes made in Gnus trunk. Reimplement nnimap, and do tweaks to the rest of the code to support that. * gnus-int.el (gnus-finish-retrieve-group-infos) (gnus-retrieve-group-data-early): New functions. * gnus-range.el (gnus-range-nconcat): New function. * gnus-start.el (gnus-get-unread-articles): Support early retrieval of data. (gnus-read-active-for-groups): Support finishing the early retrieval of data. * gnus-sum.el (gnus-summary-move-article): Pass the move-to group name if the move is internal, so that nnimap can do fast internal moves. * gnus.el (gnus-article-special-mark-lists): Add uid/active tuples, for nnimap usage. * nnimap.el: Rewritten. * nnmail.el (nnmail-inhibit-default-split-group): New internal variable to allow the mail splitting to not return a default group. This is useful for nnimap, which will leave unmatched mail in the inbox. * utf7.el (utf7-encode): Autoload. Implement shell connection. * nnimap.el (nnimap-open-shell-stream): New function. (nnimap-open-connection): Use it. Get the number of lines by using BODYSTRUCTURE. (nnimap-transform-headers): Get the number of lines in each message. (nnimap-retrieve-headers): Query for BODYSTRUCTURE so that we get the number of lines. Not all servers return UIDNEXT. Work past this problem. Remove junk from end of file. Fix typo in "bogus" section. Make capabilties be case-insensitive. Require cl when compiling. Don't bug out if the LIST command doesn't have any parameters. 2010-09-17 Knut Anders Hatlen <kahatlen@gmail.com> (tiny change) * nnimap.el (nnimap-get-groups): Don't bug out if the LIST command doesn't have any parameters. (mm-text-html-renderer): Document gnus-article-html. 2010-09-17 Julien Danjou <julien@danjou.info> (tiny fix) * mm-decode.el (mm-text-html-renderer): Document gnus-article-html. * dgnushack.el: Define netrc-credentials. If the user doesn't have a /etc/services, supply some sensible port defaults. Have `unseen-or-unread' select an unread unseen article first. (nntp-open-server): Return whether the open was successful or not. Throughout all files, replace (save-excursion (set-buffer ...)) with (with-current-buffer ... ). Save result so that it doesn't say "failed" all the time. Add ~/.authinfo to the default, since that's probably most useful for users. Don't use the "finish" method when we're reading from the agent. Add some more nnimap-relevant agent stuff to nnagent.el. * nnimap.el (nnimap-with-process-buffer): Removed. Revert one line that was changed by mistake in the last checkin. (nnimap-open-connection): Don't error out when we can't make a connection nnimap-related changes to avoid bugging out if we can't contact a server. * gnus-start.el (gnus-get-unread-articles): Don't try to scan groups from methods that are denied. * nnimap.el (nnimap-possibly-change-group): Return nil if we can't log in. (nnimap-finish-retrieve-group-infos): Make sure we're not waiting for nothing. * gnus-sum.el (gnus-select-newsgroup): Indent.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sat, 18 Sep 2010 10:02:19 +0000
parents 280c8ae2476d
children 77c2be84591c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; image-mode.el --- support for visiting image files
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;;
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106409
diff changeset
3 ;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;;
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Richard Stallman <rms@gnu.org>
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: multimedia
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 109871
diff changeset
7 ;; Package: emacs
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93562
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93562
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93562
diff changeset
14 ;; (at your option) any later version.
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93562
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; Defines a major mode for visiting image files
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; that allows conversion between viewing the text of the file
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; and viewing the file as an image. Viewing the image
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; works by putting a `display' text-property on the
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; image data, with the image-data still present underneath; if the
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; resulting buffer file is saved to another name it will correctly save
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; the image data to the new file.
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;; Code:
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (require 'image)
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
37 (eval-when-compile (require 'cl))
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
105939
a0f778f4a995 * term/x-win.el (x-gtk-stock-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105371
diff changeset
39 ;;;###autoload (push (cons (purecopy "\\.jpe?g\\'") 'image-mode) auto-mode-alist)
a0f778f4a995 * term/x-win.el (x-gtk-stock-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105371
diff changeset
40 ;;;###autoload (push (cons (purecopy "\\.png\\'") 'image-mode) auto-mode-alist)
a0f778f4a995 * term/x-win.el (x-gtk-stock-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105371
diff changeset
41 ;;;###autoload (push (cons (purecopy "\\.gif\\'") 'image-mode) auto-mode-alist)
a0f778f4a995 * term/x-win.el (x-gtk-stock-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105371
diff changeset
42 ;;;###autoload (push (cons (purecopy "\\.tiff?\\'") 'image-mode) auto-mode-alist)
a0f778f4a995 * term/x-win.el (x-gtk-stock-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105371
diff changeset
43 ;;;###autoload (push (cons (purecopy "\\.p[bpgn]m\\'") 'image-mode) auto-mode-alist)
82836
4526cbe33367 Add autoloads to put associations in auto-mode-alist:
Juri Linkov <juri@jurta.org>
parents: 82770
diff changeset
44
105939
a0f778f4a995 * term/x-win.el (x-gtk-stock-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105371
diff changeset
45 ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'c-mode) auto-mode-alist)
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
46 ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'image-mode) auto-mode-alist)
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
105939
a0f778f4a995 * term/x-win.el (x-gtk-stock-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105371
diff changeset
48 ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'xml-mode) auto-mode-alist)
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
49 ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'image-mode) auto-mode-alist)
82836
4526cbe33367 Add autoloads to put associations in auto-mode-alist:
Juri Linkov <juri@jurta.org>
parents: 82770
diff changeset
50
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
51 ;;; Image mode window-info management.
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
52
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
53 (defvar image-mode-winprops-alist t)
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
54 (make-variable-buffer-local 'image-mode-winprops-alist)
88062
4ff20f6b1ec8 * image-mode.el (image-mode-current-vscroll)
Tassilo Horn <tassilo@member.fsf.org>
parents: 88057
diff changeset
55
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
56 (defvar image-mode-new-window-functions nil
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
57 "Special hook run when image data is requested in a new window.
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
58 It is called with one argument, the initial WINPROPS.")
88057
1341d54b08e2 2008-01-29 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 87557
diff changeset
59
95224
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
60 (defun image-mode-winprops (&optional window cleanup)
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
61 "Return winprops of WINDOW.
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
62 A winprops object has the shape (WINDOW . ALIST)."
95224
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
63 (cond ((null window)
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
64 (setq window (selected-window)))
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
65 ((not (windowp window))
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
66 (error "Not a window: %s" window)))
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
67 (when cleanup
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
68 (setq image-mode-winprops-alist
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
69 (delq nil (mapcar (lambda (winprop)
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
70 (if (window-live-p (car-safe winprop))
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
71 winprop))
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
72 image-mode-winprops-alist))))
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
73 (let ((winprops (assq window image-mode-winprops-alist)))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
74 ;; For new windows, set defaults from the latest.
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
75 (unless winprops
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
76 (setq winprops (cons window
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
77 (copy-alist (cdar image-mode-winprops-alist))))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
78 (run-hook-with-args 'image-mode-new-window-functions winprops))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
79 ;; Move window to front.
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
80 (setq image-mode-winprops-alist
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
81 (cons winprops (delq winprops image-mode-winprops-alist)))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
82 winprops))
88057
1341d54b08e2 2008-01-29 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 87557
diff changeset
83
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
84 (defun image-mode-window-get (prop &optional winprops)
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
85 (unless (consp winprops) (setq winprops (image-mode-winprops winprops)))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
86 (cdr (assq prop (cdr winprops))))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
87
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
88 (defsetf image-mode-window-get (prop &optional winprops) (val)
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
89 `(image-mode-window-put ,prop ,val ,winprops))
88057
1341d54b08e2 2008-01-29 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 87557
diff changeset
90
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
91 (defun image-mode-window-put (prop val &optional winprops)
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
92 (unless (consp winprops) (setq winprops (image-mode-winprops winprops)))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
93 (setcdr winprops (cons (cons prop val)
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
94 (delq (assq prop (cdr winprops)) (cdr winprops)))))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
95
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
96 (defun image-set-window-vscroll (vscroll)
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
97 (setf (image-mode-window-get 'vscroll) vscroll)
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
98 (set-window-vscroll (selected-window) vscroll))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
99
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
100 (defun image-set-window-hscroll (ncol)
92010
a7a0e6010c46 (image-set-window-hscroll): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91999
diff changeset
101 (setf (image-mode-window-get 'hscroll) ncol)
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
102 (set-window-hscroll (selected-window) ncol))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
103
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
104 (defun image-mode-reapply-winprops ()
93252
d5bb646771f8 (image-mode-reapply-winprops): Simplify now that
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92564
diff changeset
105 ;; When set-window-buffer, set hscroll and vscroll to what they were
d5bb646771f8 (image-mode-reapply-winprops): Simplify now that
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92564
diff changeset
106 ;; last time the image was displayed in this window.
95224
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
107 (when (and (image-get-display-property)
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
108 (listp image-mode-winprops-alist))
889084703e3f (image-mode-winprops): Add argument CLEANUP to prune
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
109 (let* ((winprops (image-mode-winprops nil t))
93252
d5bb646771f8 (image-mode-reapply-winprops): Simplify now that
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92564
diff changeset
110 (hscroll (image-mode-window-get 'hscroll winprops))
d5bb646771f8 (image-mode-reapply-winprops): Simplify now that
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92564
diff changeset
111 (vscroll (image-mode-window-get 'vscroll winprops)))
93315
cb3570d14a66 (image-mode-reapply-winprops): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93252
diff changeset
112 (if hscroll (set-window-hscroll (selected-window) hscroll))
cb3570d14a66 (image-mode-reapply-winprops): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93252
diff changeset
113 (if vscroll (set-window-vscroll (selected-window) vscroll)))))
88057
1341d54b08e2 2008-01-29 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 87557
diff changeset
114
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
115 (defun image-mode-setup-winprops ()
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
116 ;; Record current scroll settings.
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
117 (unless (listp image-mode-winprops-alist)
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
118 (setq image-mode-winprops-alist nil))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
119 (add-hook 'window-configuration-change-hook
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
120 'image-mode-reapply-winprops nil t))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
121
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
122 ;;; Image scrolling functions
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
123
91928
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
124 (defun image-get-display-property ()
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
125 (get-char-property (point-min) 'display
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
126 ;; There might be different images for different displays.
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
127 (if (eq (window-buffer) (current-buffer))
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
128 (selected-window))))
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
129
95841
b4e36ff621b3 Add some compiler declarations, for builds without X.
Glenn Morris <rgm@gnu.org>
parents: 95528
diff changeset
130 (declare-function image-size "image.c" (spec &optional pixels frame))
b4e36ff621b3 Add some compiler declarations, for builds without X.
Glenn Morris <rgm@gnu.org>
parents: 95528
diff changeset
131
109334
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
132 (defun image-display-size (spec &optional pixels frame)
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
133 "Wrapper around `image-size', to handle slice display properties.
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
134 If SPEC is an image display property, call `image-size' with the
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
135 given arguments.
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
136 If SPEC is a list of properties containing `image' and `slice'
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
137 properties, calculate the display size from the slice property.
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
138 If SPEC contains `image' but not `slice', call `image-size' with
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
139 the specified image."
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
140 (if (eq (car spec) 'image)
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
141 (image-size spec pixels frame)
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
142 (let ((image (assoc 'image spec))
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
143 (slice (assoc 'slice spec)))
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
144 (cond ((and image slice)
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
145 (if pixels
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
146 (cons (nth 3 slice) (nth 4 slice))
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
147 (cons (/ (float (nth 3 slice)) (frame-char-width frame))
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
148 (/ (float (nth 4 slice)) (frame-char-height frame)))))
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
149 (image
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
150 (image-size image pixels frame))
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
151 (t
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
152 (error "Invalid image specification: %s" spec))))))
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
153
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
154 (defun image-forward-hscroll (&optional n)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
155 "Scroll image in current window to the left by N character widths.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
156 Stop if the right edge of the image is reached."
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
157 (interactive "p")
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
158 (cond ((= n 0) nil)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
159 ((< n 0)
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
160 (image-set-window-hscroll (max 0 (+ (window-hscroll) n))))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
161 (t
91928
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
162 (let* ((image (image-get-display-property))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
163 (edges (window-inside-edges))
81063
b3fc5c4daa5f (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 81019
diff changeset
164 (win-width (- (nth 2 edges) (nth 0 edges)))
109334
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
165 (img-width (ceiling (car (image-display-size image)))))
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
166 (image-set-window-hscroll (min (max 0 (- img-width win-width))
88057
1341d54b08e2 2008-01-29 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 87557
diff changeset
167 (+ n (window-hscroll))))))))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
168
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
169 (defun image-backward-hscroll (&optional n)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
170 "Scroll image in current window to the right by N character widths.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
171 Stop if the left edge of the image is reached."
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
172 (interactive "p")
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
173 (image-forward-hscroll (- n)))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
174
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
175 (defun image-next-line (&optional n)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
176 "Scroll image in current window upward by N lines.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
177 Stop if the bottom edge of the image is reached."
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
178 (interactive "p")
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
179 (cond ((= n 0) nil)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
180 ((< n 0)
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
181 (image-set-window-vscroll (max 0 (+ (window-vscroll) n))))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
182 (t
91928
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
183 (let* ((image (image-get-display-property))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
184 (edges (window-inside-edges))
81063
b3fc5c4daa5f (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 81019
diff changeset
185 (win-height (- (nth 3 edges) (nth 1 edges)))
109334
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
186 (img-height (ceiling (cdr (image-display-size image)))))
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
187 (image-set-window-vscroll (min (max 0 (- img-height win-height))
88057
1341d54b08e2 2008-01-29 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 87557
diff changeset
188 (+ n (window-vscroll))))))))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
189
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
190 (defun image-previous-line (&optional n)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
191 "Scroll image in current window downward by N lines.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
192 Stop if the top edge of the image is reached."
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
193 (interactive "p")
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
194 (image-next-line (- n)))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
195
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
196 (defun image-scroll-up (&optional n)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
197 "Scroll image in current window upward by N lines.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
198 Stop if the bottom edge of the image is reached.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
199 If ARG is omitted or nil, scroll upward by a near full screen.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
200 A near full screen is `next-screen-context-lines' less than a full screen.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
201 Negative ARG means scroll downward.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
202 If ARG is the atom `-', scroll downward by nearly full screen.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
203 When calling from a program, supply as argument a number, nil, or `-'."
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
204 (interactive "P")
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
205 (cond ((null n)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
206 (let* ((edges (window-inside-edges))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
207 (win-height (- (nth 3 edges) (nth 1 edges))))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
208 (image-next-line
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
209 (max 0 (- win-height next-screen-context-lines)))))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
210 ((eq n '-)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
211 (let* ((edges (window-inside-edges))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
212 (win-height (- (nth 3 edges) (nth 1 edges))))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
213 (image-next-line
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
214 (min 0 (- next-screen-context-lines win-height)))))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
215 (t (image-next-line (prefix-numeric-value n)))))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
216
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
217 (defun image-scroll-down (&optional n)
88103
d6247c939edc (image-mode-current-vscroll, image-mode-current-hscroll): Make buffer-local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88062
diff changeset
218 "Scroll image in current window downward by N lines.
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
219 Stop if the top edge of the image is reached.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
220 If ARG is omitted or nil, scroll downward by a near full screen.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
221 A near full screen is `next-screen-context-lines' less than a full screen.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
222 Negative ARG means scroll upward.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
223 If ARG is the atom `-', scroll upward by nearly full screen.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
224 When calling from a program, supply as argument a number, nil, or `-'."
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
225 (interactive "P")
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
226 (cond ((null n)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
227 (let* ((edges (window-inside-edges))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
228 (win-height (- (nth 3 edges) (nth 1 edges))))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
229 (image-next-line
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
230 (min 0 (- next-screen-context-lines win-height)))))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
231 ((eq n '-)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
232 (let* ((edges (window-inside-edges))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
233 (win-height (- (nth 3 edges) (nth 1 edges))))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
234 (image-next-line
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
235 (max 0 (- win-height next-screen-context-lines)))))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
236 (t (image-next-line (- (prefix-numeric-value n))))))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
237
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
238 (defun image-bol (arg)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
239 "Scroll horizontally to the left edge of the image in the current window.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
240 With argument ARG not nil or 1, move forward ARG - 1 lines first,
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
241 stopping if the top or bottom edge of the image is reached."
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
242 (interactive "p")
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
243 (and arg
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
244 (/= (setq arg (prefix-numeric-value arg)) 1)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
245 (image-next-line (- arg 1)))
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
246 (image-set-window-hscroll 0))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
247
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
248 (defun image-eol (arg)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
249 "Scroll horizontally to the right edge of the image in the current window.
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
250 With argument ARG not nil or 1, move forward ARG - 1 lines first,
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
251 stopping if the top or bottom edge of the image is reached."
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
252 (interactive "p")
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
253 (and arg
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
254 (/= (setq arg (prefix-numeric-value arg)) 1)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
255 (image-next-line (- arg 1)))
91928
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
256 (let* ((image (image-get-display-property))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
257 (edges (window-inside-edges))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
258 (win-width (- (nth 2 edges) (nth 0 edges)))
109334
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
259 (img-width (ceiling (car (image-display-size image)))))
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
260 (image-set-window-hscroll (max 0 (- img-width win-width)))))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
261
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
262 (defun image-bob ()
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
263 "Scroll to the top-left corner of the image in the current window."
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
264 (interactive)
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
265 (image-set-window-hscroll 0)
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
266 (image-set-window-vscroll 0))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
267
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
268 (defun image-eob ()
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
269 "Scroll to the bottom-right corner of the image in the current window."
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
270 (interactive)
91928
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
271 (let* ((image (image-get-display-property))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
272 (edges (window-inside-edges))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
273 (win-width (- (nth 2 edges) (nth 0 edges)))
109334
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
274 (img-width (ceiling (car (image-display-size image))))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
275 (win-height (- (nth 3 edges) (nth 1 edges)))
109334
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
276 (img-height (ceiling (cdr (image-display-size image)))))
91999
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
277 (image-set-window-hscroll (max 0 (- img-width win-width)))
a58e06f6236c Extend [hv]scroll support to per-window properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91928
diff changeset
278 (image-set-window-vscroll (max 0 (- img-height win-height)))))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
279
93562
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
280 ;; Adjust frame and image size.
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
281
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
282 (defun image-mode-fit-frame ()
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
283 "Fit the frame to the current image.
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
284 This function assumes the current frame has only one window."
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
285 ;; FIXME: This does not take into account decorations like mode-line,
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
286 ;; minibuffer, header-line, ...
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
287 (interactive)
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
288 (let* ((saved (frame-parameter nil 'image-mode-saved-size))
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
289 (display (image-get-display-property))
109334
603e7bce46eb Fix size calculation for sliced images in image-mode (Bug#6639).
Chong Yidong <cyd@stupidchicken.com>
parents: 108350
diff changeset
290 (size (image-display-size display)))
93562
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
291 (if (and saved
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
292 (eq (caar saved) (frame-width))
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
293 (eq (cdar saved) (frame-height)))
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
294 (progn ;; Toggle back to previous non-fitted size.
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
295 (set-frame-parameter nil 'image-mode-saved-size nil)
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
296 (setq size (cdr saved)))
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
297 ;; Round up size, and save current size so we can toggle back to it.
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
298 (setcar size (ceiling (car size)))
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
299 (setcdr size (ceiling (cdr size)))
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
300 (set-frame-parameter nil 'image-mode-saved-size
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
301 (cons size (cons (frame-width) (frame-height)))))
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
302 (set-frame-width (selected-frame) (car size))
01f16f0a9645 (image-mode-fit-frame): New command.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93315
diff changeset
303 (set-frame-height (selected-frame) (cdr size))))
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
304
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
305 ;;; Image Mode setup
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
306
82944
827101d5eacc (image-type): New variable.
Juri Linkov <juri@jurta.org>
parents: 82836
diff changeset
307 (defvar image-type nil
827101d5eacc (image-type): New variable.
Juri Linkov <juri@jurta.org>
parents: 82836
diff changeset
308 "Current image type.
827101d5eacc (image-type): New variable.
Juri Linkov <juri@jurta.org>
parents: 82836
diff changeset
309 This variable is used to display the current image type in the mode line.")
827101d5eacc (image-type): New variable.
Juri Linkov <juri@jurta.org>
parents: 82836
diff changeset
310 (make-variable-buffer-local 'image-type)
827101d5eacc (image-type): New variable.
Juri Linkov <juri@jurta.org>
parents: 82836
diff changeset
311
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
312 (defvar image-mode-previous-major-mode nil
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
313 "Internal variable to keep the previous non-image major mode.")
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
314
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (defvar image-mode-map
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (let ((map (make-sparse-keymap)))
95508
88781ac6a1be * image-mode.el (image-mode-map): Suppress key map and bind `q'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95224
diff changeset
317 (suppress-keymap map)
88781ac6a1be * image-mode.el (image-mode-map): Suppress key map and bind `q'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95224
diff changeset
318 (define-key map "q" 'quit-window)
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (define-key map "\C-c\C-c" 'image-toggle-display)
95528
40ef1e044cad (image-mode-map): Add doc-view-inspired bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95508
diff changeset
320 (define-key map (kbd "SPC") 'image-scroll-up)
40ef1e044cad (image-mode-map): Add doc-view-inspired bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95508
diff changeset
321 (define-key map (kbd "DEL") 'image-scroll-down)
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
322 (define-key map [remap forward-char] 'image-forward-hscroll)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
323 (define-key map [remap backward-char] 'image-backward-hscroll)
108988
65de28008783 * lisp/image-mode.el (image-mode-map): Remap left-char and right-char.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108779
diff changeset
324 (define-key map [remap right-char] 'image-forward-hscroll)
65de28008783 * lisp/image-mode.el (image-mode-map): Remap left-char and right-char.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108779
diff changeset
325 (define-key map [remap left-char] 'image-backward-hscroll)
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
326 (define-key map [remap previous-line] 'image-previous-line)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
327 (define-key map [remap next-line] 'image-next-line)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
328 (define-key map [remap scroll-up] 'image-scroll-up)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
329 (define-key map [remap scroll-down] 'image-scroll-down)
107853
de5ba6f3514c Bind `C-v' to `scroll-up-command' and `M-v' to `scroll-down-command'.
Juri Linkov <juri@jurta.org>
parents: 107362
diff changeset
330 (define-key map [remap scroll-up-command] 'image-scroll-up)
de5ba6f3514c Bind `C-v' to `scroll-up-command' and `M-v' to `scroll-down-command'.
Juri Linkov <juri@jurta.org>
parents: 107362
diff changeset
331 (define-key map [remap scroll-down-command] 'image-scroll-down)
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
332 (define-key map [remap move-beginning-of-line] 'image-bol)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
333 (define-key map [remap move-end-of-line] 'image-eol)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
334 (define-key map [remap beginning-of-buffer] 'image-bob)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
335 (define-key map [remap end-of-buffer] 'image-eob)
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 map)
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
337 "Major mode keymap for viewing images in Image mode.")
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
338
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
339 (defvar image-minor-mode-map
77989
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
340 (let ((map (make-sparse-keymap)))
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
341 (define-key map "\C-c\C-c" 'image-toggle-display)
6393038dae4d (image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents: 75745
diff changeset
342 map)
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
343 "Minor mode keymap for viewing images as text in Image mode.")
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344
92556
5944be8c8211 Change a return type, for greater extensibility. See
Karl Fogel <kfogel@red-bean.com>
parents: 92010
diff changeset
345 (defvar bookmark-make-record-function)
87557
9ada3b121e1f (bookmark-make-cell-function)
Glenn Morris <rgm@gnu.org>
parents: 87521
diff changeset
346
107096
31db1aaeac2d * doc-view.el (doc-view-mode):
Juri Linkov <juri@jurta.org>
parents: 106815
diff changeset
347 (put 'image-mode 'mode-class 'special)
31db1aaeac2d * doc-view.el (doc-view-mode):
Juri Linkov <juri@jurta.org>
parents: 106815
diff changeset
348
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 ;;;###autoload
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (defun image-mode ()
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 "Major mode for image files.
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 You can use \\<image-mode-map>\\[image-toggle-display]
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 to toggle between display as an image and display as text."
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (interactive)
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
355 (condition-case err
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
356 (progn
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
357 (unless (display-images-p)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
358 (error "Display does not support images"))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
359
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
360 (kill-all-local-variables)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
361 (setq major-mode 'image-mode)
88057
1341d54b08e2 2008-01-29 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 87557
diff changeset
362
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
363 (if (not (image-get-display-property))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
364 (progn
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
365 (image-toggle-display-image)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
366 ;; If attempt to display the image fails.
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
367 (if (not (image-get-display-property))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
368 (error "Invalid image")))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
369 ;; Set next vars when image is already displayed but local
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
370 ;; variables were cleared by kill-all-local-variables
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
371 (setq cursor-type nil truncate-lines t
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
372 image-type (plist-get (cdr (image-get-display-property)) :type)))
88057
1341d54b08e2 2008-01-29 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 87557
diff changeset
373
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
374 (setq mode-name (if image-type (format "Image[%s]" image-type) "Image"))
80655
bfcd3905d0e4 (image-mode): Set image-mode-text-map when image cannot be displayed.
Chong Yidong <cyd@stupidchicken.com>
parents: 79721
diff changeset
375 (use-local-map image-mode-map)
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
376
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
377 ;; Use our own bookmarking function for images.
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
378 (set (make-local-variable 'bookmark-make-record-function)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
379 'image-bookmark-make-record)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
380
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
381 ;; Keep track of [vh]scroll when switching buffers
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
382 (image-mode-setup-winprops)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
383
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
384 (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
108779
f2b6722a5113 * image-mode.el (image-mode): Add image-after-revert-hook to after-revert-hook.
Juri Linkov <juri@jurta.org>
parents: 108746
diff changeset
385 (add-hook 'after-revert-hook 'image-after-revert-hook nil t)
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
386 (run-mode-hooks 'image-mode-hook)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
387 (message "%s" (concat
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
388 (substitute-command-keys
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
389 "Type \\[image-toggle-display] to view the image as ")
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
390 (if (image-get-display-property)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
391 "text" "an image") ".")))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
392 (error
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
393 (image-mode-as-text)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
394 (funcall
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
395 (if (called-interactively-p 'any) 'error 'message)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
396 "Cannot display image: %s" (cdr err)))))
60937
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
397
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
398 ;;;###autoload
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
399 (define-minor-mode image-minor-mode
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
400 "Toggle Image minor mode.
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
401 With arg, turn Image minor mode on if arg is positive, off otherwise.
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
402 It provides the key \\<image-mode-map>\\[image-toggle-display] \
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
403 to switch back to `image-mode'
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
404 to display an image file as the actual image."
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
405 nil (:eval (if image-type (format " Image[%s]" image-type) " Image"))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
406 image-minor-mode-map
60937
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
407 :group 'image
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
408 :version "22.1"
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
409 (if image-minor-mode
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
410 (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t)))
60937
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
411
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
412 ;;;###autoload
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
413 (defun image-mode-as-text ()
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
414 "Set a non-image mode as major mode in combination with image minor mode.
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
415 A non-image major mode found from `auto-mode-alist' or Fundamental mode
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
416 displays an image file as text. `image-minor-mode' provides the key
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
417 \\<image-mode-map>\\[image-toggle-display] to switch back to `image-mode'
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
418 to display an image file as the actual image.
60937
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
419
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
420 You can use `image-mode-as-text' in `auto-mode-alist' when you want
108350
224e769e00a2 Fix typo in docstring.
Juri Linkov <juri@jurta.org>
parents: 107096
diff changeset
421 to display an image file as text initially.
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
422
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
423 See commands `image-mode' and `image-minor-mode' for more information
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
424 on these modes."
60937
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
425 (interactive)
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
426 ;; image-mode-as-text = normal-mode + image-minor-mode
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
427 (let ((previous-image-type image-type)) ; preserve `image-type'
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
428 (if image-mode-previous-major-mode
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
429 ;; Restore previous major mode that was already found by this
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
430 ;; function and cached in `image-mode-previous-major-mode'
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
431 (funcall image-mode-previous-major-mode)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
432 (let ((auto-mode-alist
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
433 (delq nil (mapcar
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
434 (lambda (elt)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
435 (unless (memq (or (car-safe (cdr elt)) (cdr elt))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
436 '(image-mode image-mode-maybe image-mode-as-text))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
437 elt))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
438 auto-mode-alist)))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
439 (magic-fallback-mode-alist
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
440 (delq nil (mapcar
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
441 (lambda (elt)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
442 (unless (memq (or (car-safe (cdr elt)) (cdr elt))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
443 '(image-mode image-mode-maybe image-mode-as-text))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
444 elt))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
445 magic-fallback-mode-alist))))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
446 (normal-mode)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
447 (set (make-local-variable 'image-mode-previous-major-mode) major-mode)))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
448 ;; Restore `image-type' after `kill-all-local-variables' in `normal-mode'.
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
449 (setq image-type previous-image-type)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
450 ;; Enable image minor mode with `C-c C-c'.
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
451 (image-minor-mode 1)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
452 ;; Show the image file as text.
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
453 (image-toggle-display-text)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
454 (message "%s" (concat
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
455 (substitute-command-keys
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
456 "Type \\[image-toggle-display] to view the image as ")
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
457 (if (image-get-display-property)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
458 "text" "an image") "."))))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
459
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
460 (define-obsolete-function-alias 'image-mode-maybe 'image-mode "23.2")
60937
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
461
ddcbccff39ce Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents: 60780
diff changeset
462 (defun image-toggle-display-text ()
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
463 "Show the image file as text.
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
464 Remove text properties that display the image."
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
465 (let ((inhibit-read-only t)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
466 (buffer-undo-list t)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
467 (modified (buffer-modified-p)))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
468 (remove-list-of-text-properties (point-min) (point-max)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
469 '(display intangible read-nonsticky
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
470 read-only front-sticky))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
471 (set-buffer-modified-p modified)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
472 (if (called-interactively-p 'any)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
473 (message "Repeat this command to go back to displaying the image"))))
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474
71939
3c0fceee4b4a (tar-superior-buffer, archive-superior-buffer):
Richard M. Stallman <rms@gnu.org>
parents: 70943
diff changeset
475 (defvar archive-superior-buffer)
3c0fceee4b4a (tar-superior-buffer, archive-superior-buffer):
Richard M. Stallman <rms@gnu.org>
parents: 70943
diff changeset
476 (defvar tar-superior-buffer)
108746
24d486687f54 Rename image-refresh to image-flush.
Chong Yidong <cyd@stupidchicken.com>
parents: 108375
diff changeset
477 (declare-function image-flush "image.c" (spec &optional frame))
71939
3c0fceee4b4a (tar-superior-buffer, archive-superior-buffer):
Richard M. Stallman <rms@gnu.org>
parents: 70943
diff changeset
478
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
479 (defun image-toggle-display-image ()
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
480 "Show the image of the image file.
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
481 Turn the image data into a real image, but only if the whole file
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
482 was inserted."
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
483 (let* ((filename (buffer-file-name))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
484 (data-p (not (and filename
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
485 (file-readable-p filename)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
486 (not (file-remote-p filename))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
487 (not (buffer-modified-p))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
488 (not (and (boundp 'archive-superior-buffer)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
489 archive-superior-buffer))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
490 (not (and (boundp 'tar-superior-buffer)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
491 tar-superior-buffer)))))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
492 (file-or-data (if data-p
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
493 (string-make-unibyte
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
494 (buffer-substring-no-properties (point-min) (point-max)))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
495 filename))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
496 (type (image-type file-or-data nil data-p))
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
497 (image0 (create-animated-image file-or-data type data-p))
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
498 (image (append image0
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
499 (image-transform-properties image0)
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
500 ))
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
501 (props
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
502 `(display ,image
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
503 intangible ,image
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
504 rear-nonsticky (display intangible)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
505 read-only t front-sticky (read-only)))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
506 (inhibit-read-only t)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
507 (buffer-undo-list t)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
508 (modified (buffer-modified-p)))
108746
24d486687f54 Rename image-refresh to image-flush.
Chong Yidong <cyd@stupidchicken.com>
parents: 108375
diff changeset
509 (image-flush image)
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
510 (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
511 (add-text-properties (point-min) (point-max) props)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
512 (restore-buffer-modified-p modified))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
513 ;; Inhibit the cursor when the buffer contains only an image,
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
514 ;; because cursors look very strange on top of images.
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
515 (setq cursor-type nil)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
516 ;; This just makes the arrow displayed in the right fringe
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
517 ;; area look correct when the image is wider than the window.
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
518 (setq truncate-lines t)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
519 ;; Allow navigation of large images
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
520 (set (make-local-variable 'auto-hscroll-mode) nil)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
521 (setq image-type type)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
522 (if (eq major-mode 'image-mode)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
523 (setq mode-name (format "Image[%s]" type)))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
524 (if (called-interactively-p 'any)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
525 (message "Repeat this command to go back to displaying the file as text"))))
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
526
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 (defun image-toggle-display ()
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 "Start or stop displaying an image file as the actual image.
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
529 This command toggles between `image-mode-as-text' showing the text of
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
530 the image file and `image-mode' showing the image as an image."
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (interactive)
91928
e788f311729d (image-get-display-property): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 88103
diff changeset
532 (if (image-get-display-property)
106409
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
533 (image-mode-as-text)
87bc434475d4 Change roles of modes and functions in image-mode.el (Bug#5062).
Juri Linkov <juri@jurta.org>
parents: 106304
diff changeset
534 (image-mode)))
108779
f2b6722a5113 * image-mode.el (image-mode): Add image-after-revert-hook to after-revert-hook.
Juri Linkov <juri@jurta.org>
parents: 108746
diff changeset
535
f2b6722a5113 * image-mode.el (image-mode): Add image-after-revert-hook to after-revert-hook.
Juri Linkov <juri@jurta.org>
parents: 108746
diff changeset
536 (defun image-after-revert-hook ()
f2b6722a5113 * image-mode.el (image-mode): Add image-after-revert-hook to after-revert-hook.
Juri Linkov <juri@jurta.org>
parents: 108746
diff changeset
537 (when (image-get-display-property)
f2b6722a5113 * image-mode.el (image-mode): Add image-after-revert-hook to after-revert-hook.
Juri Linkov <juri@jurta.org>
parents: 108746
diff changeset
538 (image-toggle-display-text)
f2b6722a5113 * image-mode.el (image-mode): Add image-after-revert-hook to after-revert-hook.
Juri Linkov <juri@jurta.org>
parents: 108746
diff changeset
539 ;; Update image display.
f2b6722a5113 * image-mode.el (image-mode): Add image-after-revert-hook to after-revert-hook.
Juri Linkov <juri@jurta.org>
parents: 108746
diff changeset
540 (redraw-frame (selected-frame))
f2b6722a5113 * image-mode.el (image-mode): Add image-after-revert-hook to after-revert-hook.
Juri Linkov <juri@jurta.org>
parents: 108746
diff changeset
541 (image-toggle-display-image)))
f2b6722a5113 * image-mode.el (image-mode): Add image-after-revert-hook to after-revert-hook.
Juri Linkov <juri@jurta.org>
parents: 108746
diff changeset
542
101824
f8f2a2994cd5 (image-mode): Use `image-get-display-property' instead of `get-text-property'.
Juri Linkov <juri@jurta.org>
parents: 100908
diff changeset
543
87412
f6ce12419345 2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 85800
diff changeset
544 ;;; Support for bookmark.el
109395
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 108988
diff changeset
545 (declare-function bookmark-make-record-default
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 108988
diff changeset
546 "bookmark" (&optional no-file no-context posn))
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95841
diff changeset
547 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95841
diff changeset
548 (declare-function bookmark-default-handler "bookmark" (bmk))
87412
f6ce12419345 2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 85800
diff changeset
549
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95841
diff changeset
550 (defun image-bookmark-make-record ()
109457
c581eca79ab5 Do not set bookmark context for images (Bug#6650).
Chong Yidong <cyd@stupidchicken.com>
parents: 109395
diff changeset
551 `(,@(bookmark-make-record-default nil 'no-context 0)
c581eca79ab5 Do not set bookmark context for images (Bug#6650).
Chong Yidong <cyd@stupidchicken.com>
parents: 109395
diff changeset
552 (image-type . ,image-type)
c581eca79ab5 Do not set bookmark context for images (Bug#6650).
Chong Yidong <cyd@stupidchicken.com>
parents: 109395
diff changeset
553 (handler . image-bookmark-jump)))
87412
f6ce12419345 2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 85800
diff changeset
554
f6ce12419345 2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 85800
diff changeset
555 ;;;###autoload
f6ce12419345 2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 85800
diff changeset
556 (defun image-bookmark-jump (bmk)
87521
0140d3ebb262 Change a return type, for greater extensibility. See
Karl Fogel <kfogel@red-bean.com>
parents: 87412
diff changeset
557 ;; This implements the `handler' function interface for record type
92556
5944be8c8211 Change a return type, for greater extensibility. See
Karl Fogel <kfogel@red-bean.com>
parents: 92010
diff changeset
558 ;; returned by `bookmark-make-record-function', which see.
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95841
diff changeset
559 (prog1 (bookmark-default-handler bmk)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95841
diff changeset
560 (when (not (string= image-type (bookmark-prop-get bmk 'image-type)))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95841
diff changeset
561 (image-toggle-display))))
101824
f8f2a2994cd5 (image-mode): Use `image-get-display-property' instead of `get-text-property'.
Juri Linkov <juri@jurta.org>
parents: 100908
diff changeset
562
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
563
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
564 (defvar image-transform-minor-mode-map
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
565 (let ((map (make-sparse-keymap)))
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
566 ; (define-key map [(control ?+)] 'image-scale-in)
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
567 ; (define-key map [(control ?-)] 'image-scale-out)
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
568 ; (define-key map [(control ?=)] 'image-scale-none)
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
569 ;; (define-key map "c f h" 'image-scale-fit-height)
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
570 ;; (define-key map "c ]" 'image-rotate-right)
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
571 map)
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
572 "Minor mode keymap for transforming the view of images Image mode.")
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
573
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
574 (define-minor-mode image-transform-mode
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
575 "minor mode for scaleing and rotation"
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
576 nil "image-transform"
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
577 image-transform-minor-mode-map)
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
578
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
579 (defvar image-transform-resize nil
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
580 "The image resize operation. See the command
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
581 `image-transform-set-scale' for more information." )
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
582
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
583 (defvar image-transform-rotation 0.0)
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
584
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
585
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
586 (defun image-transform-properties (display)
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
587 "Calculate the display properties for transformations; scaling
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
588 and rotation. "
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
589 (let*
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
590 ((size (image-size display t))
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
591 (height
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
592 (cond
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
593 ((and (numberp image-transform-resize) (eq 100 image-transform-resize))
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
594 nil)
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
595 ((numberp image-transform-resize)
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
596 (* image-transform-resize (cdr size)))
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
597 ((eq image-transform-resize 'fit-height)
109867
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
598 (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges))))
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
599 (t nil)))
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
600 (width (if (eq image-transform-resize 'fit-width)
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
601 (- (nth 2 (window-inside-pixel-edges)) (nth 0 (window-inside-pixel-edges))))))
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
602
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
603 `(,@(if height (list :height height))
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
604 ,@(if width (list :width width))
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
605 ,@(if (not (equal 0.0 image-transform-rotation))
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
606 (list :rotation image-transform-rotation))
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
607 ;;TODO fit-to-* should consider the rotation angle
109867
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
608 )))
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
609
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
610 (defun image-transform-set-scale (scale)
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
611 "SCALE sets the scaling for images. "
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
612 (interactive "nscale:")
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
613 (image-transform-set-resize (float scale)))
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
614
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
615 (defun image-transform-fit-to-height ()
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
616 "Fit image height to window height. "
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
617 (interactive)
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
618 (image-transform-set-resize 'fit-height))
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
619
109867
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
620 (defun image-transform-fit-to-width ()
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
621 "Fit image width to window width. "
109867
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
622 (interactive)
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
623 (image-transform-set-resize 'fit-width))
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
624
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
625 (defun image-transform-set-resize (resize)
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
626 "Set the resize mode for images. The RESIZE value can be the
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
627 symbol fit-height which fits the image to the window height. The
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
628 symbol fit-width fits the image to the window width. A number
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
629 indicates a scaling factor. nil indicates scale to 100%. "
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
630 (setq image-transform-resize resize)
109867
7b3550d93e3a support for fit-width
Joakim <joakim@localhost.localdomain>
parents: 109866
diff changeset
631 (if (eq 'image-mode major-mode) (image-toggle-display-image)))
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
632
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
633 (defun image-transform-set-rotation (rotation)
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
634 "Set the image ROTATION angle. "
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
635 (interactive "nrotation:")
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
636 ;;TODO 0 90 180 270 degrees are the only reasonable angles here
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
637 ;;otherwise combining with rescaling will get very awkward
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
638 (setq image-transform-rotation (float rotation))
109870
2ea89e2c498f some more docs and polish
Joakim <joakim@localhost.localdomain>
parents: 109867
diff changeset
639 (if (eq major-mode 'image-mode) (image-toggle-display-image)))
109866
73512e4aa257 image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
Joakim <joakim@localhost.localdomain>
parents: 108988
diff changeset
640
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 (provide 'image-mode)
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642
60697
d9c9ad74e719 Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 60694
diff changeset
643 ;; arch-tag: b5b2b7e6-26a7-4b79-96e3-1546b5c4c6cb
60694
9e7ee067df09 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 ;;; image-mode.el ends here