Mercurial > emacs
annotate lisp/image-mode.el @ 78158:8dcc6f809d32
Add more info about the vc-registered function.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Tue, 17 Jul 2007 04:48:56 +0000 |
parents | 6393038dae4d |
children | 9355f9b7bbff |
rev | line source |
---|---|
60694 | 1 ;;; image-mode.el --- support for visiting image files |
2 ;; | |
75347 | 3 ;; Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. |
60694 | 4 ;; |
5 ;; Author: Richard Stallman <rms@gnu.org> | |
6 ;; Keywords: multimedia | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64091 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
60694 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;; Defines a major mode for visiting image files | |
28 ;; that allows conversion between viewing the text of the file | |
29 ;; and viewing the file as an image. Viewing the image | |
30 ;; works by putting a `display' text-property on the | |
31 ;; image data, with the image-data still present underneath; if the | |
32 ;; resulting buffer file is saved to another name it will correctly save | |
33 ;; the image data to the new file. | |
34 | |
35 ;;; Code: | |
36 | |
37 (require 'image) | |
38 | |
60937
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
39 ;;;###autoload (push '("\\.jpe?g\\'" . image-mode) auto-mode-alist) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
40 ;;;###autoload (push '("\\.png\\'" . image-mode) auto-mode-alist) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
41 ;;;###autoload (push '("\\.gif\\'" . image-mode) auto-mode-alist) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
42 ;;;###autoload (push '("\\.tiff?\\'" . image-mode) auto-mode-alist) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
43 ;;;###autoload (push '("\\.p[bpgn]m\\'" . image-mode) auto-mode-alist) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
44 ;;;###autoload (push '("\\.x[bp]m\\'" . image-mode-maybe) auto-mode-alist) |
60694 | 45 |
77989
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
46 ;;; Image scrolling functions |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
47 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
48 (defun image-forward-hscroll (&optional n) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
49 "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
|
50 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
|
51 (interactive "p") |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
52 (cond ((= n 0) nil) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
53 ((< n 0) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
54 (set-window-hscroll nil (max 0 (+ (window-hscroll) n)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
55 (t |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
56 (let* ((image (get-text-property 1 'display)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
57 (img-width (ceiling (car (image-size image)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
58 (edges (window-inside-edges)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
59 (win-width (- (nth 2 edges) (nth 0 edges)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
60 (set-window-hscroll nil |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
61 (min (max 0 (- img-width win-width)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
62 (+ n (window-hscroll)))))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
63 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
64 (defun image-backward-hscroll (&optional n) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
65 "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
|
66 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
|
67 (interactive "p") |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
68 (image-forward-hscroll (- n))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
69 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
70 (defun image-next-line (&optional n) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
71 "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
|
72 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
|
73 (interactive "p") |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
74 (cond ((= n 0) nil) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
75 ((< n 0) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
76 (set-window-vscroll nil (max 0 (+ (window-vscroll) n)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
77 (t |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
78 (let* ((image (get-text-property 1 'display)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
79 (img-height (ceiling (cdr (image-size image)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
80 (edges (window-inside-edges)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
81 (win-height (- (nth 3 edges) (nth 1 edges)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
82 (set-window-vscroll nil |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
83 (min (max 0 (- img-height win-height)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
84 (+ n (window-vscroll)))))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
85 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
86 (defun image-previous-line (&optional n) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
87 "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
|
88 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
|
89 (interactive "p") |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
90 (image-next-line (- n))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
91 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
92 (defun image-scroll-up (&optional n) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
93 "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
|
94 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
|
95 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
|
96 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
|
97 Negative ARG means scroll downward. |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
98 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
|
99 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
|
100 (interactive "P") |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
101 (cond ((null n) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
102 (let* ((edges (window-inside-edges)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
103 (win-height (- (nth 3 edges) (nth 1 edges)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
104 (image-next-line |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
105 (max 0 (- win-height next-screen-context-lines))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
106 ((eq n '-) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
107 (let* ((edges (window-inside-edges)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
108 (win-height (- (nth 3 edges) (nth 1 edges)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
109 (image-next-line |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
110 (min 0 (- next-screen-context-lines win-height))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
111 (t (image-next-line (prefix-numeric-value n))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
112 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
113 (defun image-scroll-down (&optional n) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
114 "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
|
115 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
|
116 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
|
117 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
|
118 Negative ARG means scroll upward. |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
119 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
|
120 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
|
121 (interactive "P") |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
122 (cond ((null n) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
123 (let* ((edges (window-inside-edges)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
124 (win-height (- (nth 3 edges) (nth 1 edges)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
125 (image-next-line |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
126 (min 0 (- next-screen-context-lines win-height))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
127 ((eq n '-) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
128 (let* ((edges (window-inside-edges)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
129 (win-height (- (nth 3 edges) (nth 1 edges)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
130 (image-next-line |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
131 (max 0 (- win-height next-screen-context-lines))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
132 (t (image-next-line (- (prefix-numeric-value n)))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
133 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
134 (defun image-bol (arg) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
135 "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
|
136 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
|
137 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
|
138 (interactive "p") |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
139 (and arg |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
140 (/= (setq arg (prefix-numeric-value arg)) 1) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
141 (image-next-line (- arg 1))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
142 (set-window-hscroll (selected-window) 0)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
143 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
144 (defun image-eol (arg) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
145 "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
|
146 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
|
147 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
|
148 (interactive "p") |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
149 (and arg |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
150 (/= (setq arg (prefix-numeric-value arg)) 1) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
151 (image-next-line (- arg 1))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
152 (let* ((image (get-text-property 1 'display)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
153 (edges (window-inside-edges)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
154 (win-width (- (nth 2 edges) (nth 0 edges))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
155 (img-width (ceiling (car (image-size image))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
156 (set-window-hscroll (selected-window) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
157 (max 0 (- img-width win-width))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
158 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
159 (defun image-bob () |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
160 "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
|
161 (interactive) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
162 (set-window-hscroll (selected-window) 0) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
163 (set-window-vscroll (selected-window) 0)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
164 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
165 (defun image-eob () |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
166 "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
|
167 (interactive) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
168 (let* ((image (get-text-property 1 'display)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
169 (edges (window-inside-edges)) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
170 (win-width (- (nth 2 edges) (nth 0 edges))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
171 (img-width (ceiling (car (image-size image)))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
172 (win-height (- (nth 3 edges) (nth 1 edges))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
173 (img-height (ceiling (cdr (image-size image))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
174 (set-window-hscroll (selected-window) (max 0 (- img-width win-width))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
175 (set-window-vscroll (selected-window) (max 0 (- img-height win-height))))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
176 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
177 ;;; Image Mode setup |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
178 |
60694 | 179 (defvar image-mode-map |
180 (let ((map (make-sparse-keymap))) | |
181 (define-key map "\C-c\C-c" 'image-toggle-display) | |
77989
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
182 (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
|
183 (define-key map [remap backward-char] 'image-backward-hscroll) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
184 (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
|
185 (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
|
186 (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
|
187 (define-key map [remap scroll-down] 'image-scroll-down) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
188 (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
|
189 (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
|
190 (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
|
191 (define-key map [remap end-of-buffer] 'image-eob) |
60694 | 192 map) |
77989
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
193 "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
|
194 |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
195 (defvar image-mode-text-map |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
196 (let ((map (make-sparse-keymap))) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
197 (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
|
198 map) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
199 "Major mode keymap for viewing images as text in Image mode.") |
60694 | 200 |
201 ;;;###autoload | |
202 (defun image-mode () | |
203 "Major mode for image files. | |
204 You can use \\<image-mode-map>\\[image-toggle-display] | |
205 to toggle between display as an image and display as text." | |
206 (interactive) | |
207 (kill-all-local-variables) | |
208 (setq mode-name "Image") | |
209 (setq major-mode 'image-mode) | |
60937
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
210 (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) |
75745
19d4ee6e5621
(image-mode): Revert 2007-01-30 changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
75626
diff
changeset
|
211 (if (and (display-images-p) |
19d4ee6e5621
(image-mode): Revert 2007-01-30 changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
75626
diff
changeset
|
212 (not (get-text-property (point-min) 'display))) |
19d4ee6e5621
(image-mode): Revert 2007-01-30 changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
75626
diff
changeset
|
213 (image-toggle-display) |
19d4ee6e5621
(image-mode): Revert 2007-01-30 changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
75626
diff
changeset
|
214 ;; Set next vars when image is already displayed but local |
19d4ee6e5621
(image-mode): Revert 2007-01-30 changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
75626
diff
changeset
|
215 ;; variables were cleared by kill-all-local-variables |
77989
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
216 (use-local-map image-mode-map) |
75745
19d4ee6e5621
(image-mode): Revert 2007-01-30 changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
75626
diff
changeset
|
217 (setq cursor-type nil truncate-lines t)) |
72570
7011a586dd45
* image-mode.el (image-mode): Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
72568
diff
changeset
|
218 (run-mode-hooks 'image-mode-hook) |
7011a586dd45
* image-mode.el (image-mode): Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
72568
diff
changeset
|
219 (if (display-images-p) |
7011a586dd45
* image-mode.el (image-mode): Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
72568
diff
changeset
|
220 (message "%s" (concat |
7011a586dd45
* image-mode.el (image-mode): Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
72568
diff
changeset
|
221 (substitute-command-keys |
75545
4f14c21e4f44
(image-mode): Don't automatically view as image.
Chong Yidong <cyd@stupidchicken.com>
parents:
75347
diff
changeset
|
222 "Type \\[image-toggle-display] to view as ") |
72570
7011a586dd45
* image-mode.el (image-mode): Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
72568
diff
changeset
|
223 (if (get-text-property (point-min) 'display) |
7011a586dd45
* image-mode.el (image-mode): Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
72568
diff
changeset
|
224 "text" "an image") ".")))) |
60937
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
225 |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
226 ;;;###autoload |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
227 (define-minor-mode image-minor-mode |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
228 "Toggle Image minor mode. |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
229 With arg, turn Image minor mode on if arg is positive, off otherwise. |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
230 See the command `image-mode' for more information on this mode." |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
231 nil " Image" image-mode-map |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
232 :group 'image |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
233 :version "22.1" |
60943
258772850c9a
(image-minor-mode): Set `cursor-type' and `truncate-lines' if the
Juri Linkov <juri@jurta.org>
parents:
60937
diff
changeset
|
234 (if (not image-minor-mode) |
258772850c9a
(image-minor-mode): Set `cursor-type' and `truncate-lines' if the
Juri Linkov <juri@jurta.org>
parents:
60937
diff
changeset
|
235 (image-toggle-display-text) |
258772850c9a
(image-minor-mode): Set `cursor-type' and `truncate-lines' if the
Juri Linkov <juri@jurta.org>
parents:
60937
diff
changeset
|
236 (if (get-text-property (point-min) 'display) |
258772850c9a
(image-minor-mode): Set `cursor-type' and `truncate-lines' if the
Juri Linkov <juri@jurta.org>
parents:
60937
diff
changeset
|
237 (setq cursor-type nil truncate-lines t)) |
258772850c9a
(image-minor-mode): Set `cursor-type' and `truncate-lines' if the
Juri Linkov <juri@jurta.org>
parents:
60937
diff
changeset
|
238 (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t) |
65582
4d1085b02d64
Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents:
64091
diff
changeset
|
239 (message "%s" (concat (substitute-command-keys |
60943
258772850c9a
(image-minor-mode): Set `cursor-type' and `truncate-lines' if the
Juri Linkov <juri@jurta.org>
parents:
60937
diff
changeset
|
240 "Type \\[image-toggle-display] to view the image as ") |
258772850c9a
(image-minor-mode): Set `cursor-type' and `truncate-lines' if the
Juri Linkov <juri@jurta.org>
parents:
60937
diff
changeset
|
241 (if (get-text-property (point-min) 'display) |
258772850c9a
(image-minor-mode): Set `cursor-type' and `truncate-lines' if the
Juri Linkov <juri@jurta.org>
parents:
60937
diff
changeset
|
242 "text" "an image") ".")))) |
60937
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
243 |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
244 ;;;###autoload |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
245 (defun image-mode-maybe () |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
246 "Set major or minor mode for image files. |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
247 Set Image major mode only when there are no other major modes |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
248 associated with a filename in `auto-mode-alist'. When an image |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
249 filename matches another major mode in `auto-mode-alist' then |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
250 set that major mode and Image minor mode. |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
251 |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
252 See commands `image-mode' and `image-minor-mode' for more |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
253 information on these modes." |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
254 (interactive) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
255 (let* ((mode-alist |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
256 (delq nil (mapcar |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
257 (lambda (elt) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
258 (unless (memq (or (car-safe (cdr elt)) (cdr elt)) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
259 '(image-mode image-mode-maybe)) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
260 elt)) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
261 auto-mode-alist)))) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
262 (if (assoc-default buffer-file-name mode-alist 'string-match) |
75568
146ba0f8974c
(image-mode-maybe): Prevent magic-mode-alist from
Jason Rumney <jasonr@gnu.org>
parents:
75547
diff
changeset
|
263 (let ((auto-mode-alist mode-alist) |
146ba0f8974c
(image-mode-maybe): Prevent magic-mode-alist from
Jason Rumney <jasonr@gnu.org>
parents:
75547
diff
changeset
|
264 (magic-mode-alist nil)) |
60937
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
265 (set-auto-mode) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
266 (image-minor-mode t)) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
267 (image-mode)))) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
268 |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
269 (defun image-toggle-display-text () |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
270 "Showing the text of the image file." |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
271 (if (get-text-property (point-min) 'display) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
272 (image-toggle-display))) |
60694 | 273 |
71939
3c0fceee4b4a
(tar-superior-buffer, archive-superior-buffer):
Richard M. Stallman <rms@gnu.org>
parents:
70943
diff
changeset
|
274 (defvar archive-superior-buffer) |
3c0fceee4b4a
(tar-superior-buffer, archive-superior-buffer):
Richard M. Stallman <rms@gnu.org>
parents:
70943
diff
changeset
|
275 (defvar tar-superior-buffer) |
3c0fceee4b4a
(tar-superior-buffer, archive-superior-buffer):
Richard M. Stallman <rms@gnu.org>
parents:
70943
diff
changeset
|
276 |
60694 | 277 (defun image-toggle-display () |
278 "Start or stop displaying an image file as the actual image. | |
279 This command toggles between showing the text of the image file | |
280 and showing the image as an image." | |
281 (interactive) | |
282 (if (get-text-property (point-min) 'display) | |
283 (let ((inhibit-read-only t) | |
60780 | 284 (buffer-undo-list t) |
285 (modified (buffer-modified-p))) | |
60694 | 286 (remove-list-of-text-properties (point-min) (point-max) |
287 '(display intangible read-nonsticky | |
288 read-only front-sticky)) | |
60780 | 289 (set-buffer-modified-p modified) |
60694 | 290 (kill-local-variable 'cursor-type) |
291 (kill-local-variable 'truncate-lines) | |
77989
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
292 (kill-local-variable 'auto-hscroll-mode) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
293 (use-local-map image-mode-text-map) |
60937
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
294 (if (called-interactively-p) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
295 (message "Repeat this command to go back to displaying the image"))) |
60694 | 296 ;; Turn the image data into a real image, but only if the whole file |
297 ;; was inserted | |
68495
1239e70c4e3c
* image-mode.el (image-toggle-display): Use file name if possible,
Chong Yidong <cyd@stupidchicken.com>
parents:
65582
diff
changeset
|
298 (let* ((image |
1239e70c4e3c
* image-mode.el (image-toggle-display): Use file name if possible,
Chong Yidong <cyd@stupidchicken.com>
parents:
65582
diff
changeset
|
299 (if (and (buffer-file-name) |
70943
488f02720eed
* image-mode.el (image-toggle-display): Use buffer contents to
Chong Yidong <cyd@stupidchicken.com>
parents:
70097
diff
changeset
|
300 (not (file-remote-p (buffer-file-name))) |
70097
3e313b3afda5
(image-toggle-display): Handle tar and arc subfiles.
Richard M. Stallman <rms@gnu.org>
parents:
68749
diff
changeset
|
301 (not (buffer-modified-p)) |
3e313b3afda5
(image-toggle-display): Handle tar and arc subfiles.
Richard M. Stallman <rms@gnu.org>
parents:
68749
diff
changeset
|
302 (not (and (boundp 'archive-superior-buffer) |
3e313b3afda5
(image-toggle-display): Handle tar and arc subfiles.
Richard M. Stallman <rms@gnu.org>
parents:
68749
diff
changeset
|
303 archive-superior-buffer)) |
3e313b3afda5
(image-toggle-display): Handle tar and arc subfiles.
Richard M. Stallman <rms@gnu.org>
parents:
68749
diff
changeset
|
304 (not (and (boundp 'tar-superior-buffer) |
3e313b3afda5
(image-toggle-display): Handle tar and arc subfiles.
Richard M. Stallman <rms@gnu.org>
parents:
68749
diff
changeset
|
305 tar-superior-buffer))) |
68749
c0b14a7a6a49
* image-mode.el (image-toggle-display): Clear image cache if using
Chong Yidong <cyd@stupidchicken.com>
parents:
68651
diff
changeset
|
306 (progn (clear-image-cache) |
c0b14a7a6a49
* image-mode.el (image-toggle-display): Clear image cache if using
Chong Yidong <cyd@stupidchicken.com>
parents:
68651
diff
changeset
|
307 (create-image (buffer-file-name))) |
68495
1239e70c4e3c
* image-mode.el (image-toggle-display): Use file name if possible,
Chong Yidong <cyd@stupidchicken.com>
parents:
65582
diff
changeset
|
308 (create-image |
1239e70c4e3c
* image-mode.el (image-toggle-display): Use file name if possible,
Chong Yidong <cyd@stupidchicken.com>
parents:
65582
diff
changeset
|
309 (string-make-unibyte |
1239e70c4e3c
* image-mode.el (image-toggle-display): Use file name if possible,
Chong Yidong <cyd@stupidchicken.com>
parents:
65582
diff
changeset
|
310 (buffer-substring-no-properties (point-min) (point-max))) |
1239e70c4e3c
* image-mode.el (image-toggle-display): Use file name if possible,
Chong Yidong <cyd@stupidchicken.com>
parents:
65582
diff
changeset
|
311 nil t))) |
60694 | 312 (props |
313 `(display ,image | |
314 intangible ,image | |
315 rear-nonsticky (display intangible) | |
316 ;; This a cheap attempt to make the whole buffer | |
317 ;; read-only when we're visiting the file (as | |
318 ;; opposed to just inserting it). | |
319 read-only t front-sticky (read-only))) | |
60937
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
320 (inhibit-read-only t) |
60780 | 321 (buffer-undo-list t) |
322 (modified (buffer-modified-p))) | |
60694 | 323 (add-text-properties (point-min) (point-max) props) |
60780 | 324 (set-buffer-modified-p modified) |
60694 | 325 ;; Inhibit the cursor when the buffer contains only an image, |
326 ;; because cursors look very strange on top of images. | |
327 (setq cursor-type nil) | |
328 ;; This just makes the arrow displayed in the right fringe | |
329 ;; area look correct when the image is wider than the window. | |
330 (setq truncate-lines t) | |
77989
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
331 ;; Allow navigation of large images |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
332 (set (make-local-variable 'auto-hscroll-mode) nil) |
6393038dae4d
(image-forward-hscroll, image-backward-hscroll)
Chong Yidong <cyd@stupidchicken.com>
parents:
75745
diff
changeset
|
333 (use-local-map image-mode-map) |
60937
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
334 (if (called-interactively-p) |
ddcbccff39ce
Optimize image filename extension regexps in
Juri Linkov <juri@jurta.org>
parents:
60780
diff
changeset
|
335 (message "Repeat this command to go back to displaying the file as text"))))) |
60694 | 336 |
337 (provide 'image-mode) | |
338 | |
60697
d9c9ad74e719
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
60694
diff
changeset
|
339 ;; arch-tag: b5b2b7e6-26a7-4b79-96e3-1546b5c4c6cb |
60694 | 340 ;;; image-mode.el ends here |