Mercurial > emacs
annotate lisp/image-file.el @ 76827:aa7f7988d3bb
Mention the VCVARS32.BAT batch file for VS.NET users.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 31 Mar 2007 10:40:19 +0000 |
parents | e3694f1cb928 |
children | 9355f9b7bbff 95d0cdf160ea |
rev | line source |
---|---|
42558 | 1 ;;; image-file.el --- support for visiting image files |
31934 | 2 ;; |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64594
diff
changeset
|
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, |
75347 | 4 ;; 2005, 2006, 2007 Free Software Foundation, Inc. |
31934 | 5 ;; |
6 ;; Author: Miles Bader <miles@gnu.org> | |
7 ;; Keywords: multimedia | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64091 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
31934 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; Defines a file-name-handler hook that transforms visited (or | |
42558 | 29 ;; inserted) image files so that they are displayed by Emacs as |
31934 | 30 ;; images. This is done 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 | |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
39 |
32440
4e98e54082d2
(image-file-name-extensions, image-file-name-regexps): Add autoload cookies.
Miles Bader <miles@gnu.org>
parents:
32316
diff
changeset
|
40 ;;;###autoload |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
41 (defcustom image-file-name-extensions |
60942 | 42 '("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm" "xpm" "pbm" "pgm" "ppm" "pnm") |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
43 "*A list of image-file filename extensions. |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
44 Filenames having one of these extensions are considered image files, |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
45 in addition to those matching `image-file-name-regexps'. |
31934 | 46 |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
47 See `auto-image-file-mode'; if `auto-image-file-mode' is enabled, |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
48 setting this variable directly does not take effect unless |
42141
55c0ac959234
(image-file-name-extensions): Add pnm. Doc fix.
Dave Love <fx@gnu.org>
parents:
36213
diff
changeset
|
49 `auto-image-file-mode' is re-enabled; this happens automatically when |
55c0ac959234
(image-file-name-extensions): Add pnm. Doc fix.
Dave Love <fx@gnu.org>
parents:
36213
diff
changeset
|
50 the variable is set using \\[customize]." |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
51 :type '(repeat string) |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
52 :set (lambda (sym val) |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
53 (set-default sym val) |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
54 (when auto-image-file-mode |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
55 ;; Re-initialize the image-file handler |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
56 (auto-image-file-mode t))) |
31934 | 57 :initialize 'custom-initialize-default |
58 :group 'image) | |
59 | |
32440
4e98e54082d2
(image-file-name-extensions, image-file-name-regexps): Add autoload cookies.
Miles Bader <miles@gnu.org>
parents:
32316
diff
changeset
|
60 ;;;###autoload |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
61 (defcustom image-file-name-regexps nil |
32185
f7460e78c02a
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32003
diff
changeset
|
62 "*List of regexps matching image-file filenames. |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
63 Filenames matching one of these regexps are considered image files, |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
64 in addition to those with an extension in `image-file-name-extensions'. |
31934 | 65 |
32220
3c7e4ccb6fee
(image-file-name-extensions): Add pbm.
Dave Love <fx@gnu.org>
parents:
32218
diff
changeset
|
66 See function `auto-image-file-mode'; if `auto-image-file-mode' is |
3c7e4ccb6fee
(image-file-name-extensions): Add pbm.
Dave Love <fx@gnu.org>
parents:
32218
diff
changeset
|
67 enabled, setting this variable directly does not take effect unless |
42141
55c0ac959234
(image-file-name-extensions): Add pnm. Doc fix.
Dave Love <fx@gnu.org>
parents:
36213
diff
changeset
|
68 `auto-image-file-mode' is re-enabled; this happens automatically when |
55c0ac959234
(image-file-name-extensions): Add pnm. Doc fix.
Dave Love <fx@gnu.org>
parents:
36213
diff
changeset
|
69 the variable is set using \\[customize]." |
31934 | 70 :type '(repeat regexp) |
71 :set (lambda (sym val) | |
72 (set-default sym val) | |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
73 (when auto-image-file-mode |
31934 | 74 ;; Re-initialize the image-file handler |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
75 (auto-image-file-mode t))) |
31934 | 76 :initialize 'custom-initialize-default |
77 :group 'image) | |
78 | |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
79 |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
80 ;;;###autoload |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
81 (defun image-file-name-regexp () |
32185
f7460e78c02a
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32003
diff
changeset
|
82 "Return a regular expression matching image-file filenames." |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
83 (let ((exts-regexp |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
84 (and image-file-name-extensions |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
85 (concat "\\." |
34074
89fcace178df
(image-file-name-regexp): Automatically add upper-case variants of each
Miles Bader <miles@gnu.org>
parents:
33727
diff
changeset
|
86 (regexp-opt (nconc (mapcar #'upcase |
89fcace178df
(image-file-name-regexp): Automatically add upper-case variants of each
Miles Bader <miles@gnu.org>
parents:
33727
diff
changeset
|
87 image-file-name-extensions) |
89fcace178df
(image-file-name-regexp): Automatically add upper-case variants of each
Miles Bader <miles@gnu.org>
parents:
33727
diff
changeset
|
88 image-file-name-extensions) |
89fcace178df
(image-file-name-regexp): Automatically add upper-case variants of each
Miles Bader <miles@gnu.org>
parents:
33727
diff
changeset
|
89 t) |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
90 "\\'")))) |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
91 (if image-file-name-regexps |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
92 (mapconcat 'identity |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
93 (if exts-regexp |
32218
65d06b88701d
(image-file-name-regexp): image-file-regexps -> image-file-name-regexps.
Dave Love <fx@gnu.org>
parents:
32185
diff
changeset
|
94 (cons exts-regexp image-file-name-regexps) |
65d06b88701d
(image-file-name-regexp): image-file-regexps -> image-file-name-regexps.
Dave Love <fx@gnu.org>
parents:
32185
diff
changeset
|
95 image-file-name-regexps) |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
96 "\\|") |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
97 exts-regexp))) |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
98 |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
99 |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
100 ;;;###autoload |
31934 | 101 (defun insert-image-file (file &optional visit beg end replace) |
102 "Insert the image file FILE into the current buffer. | |
103 Optional arguments VISIT, BEG, END, and REPLACE are interpreted as for | |
104 the command `insert-file-contents'." | |
105 (let ((rval | |
106 (image-file-call-underlying #'insert-file-contents-literally | |
107 'insert-file-contents | |
108 file visit beg end replace))) | |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
109 ;; Turn the image data into a real image, but only if the whole file |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
110 ;; was inserted |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
111 (when (and (or (null beg) (zerop beg)) (null end)) |
31934 | 112 (let* ((ibeg (point)) |
113 (iend (+ (point) (cadr rval))) | |
35854
a8fd9112792b
(insert-image-file): When visiting an image, suppress the cursor in the
Miles Bader <miles@gnu.org>
parents:
34650
diff
changeset
|
114 (visitingp (and visit (= ibeg (point-min)) (= iend (point-max)))) |
31934 | 115 (data |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
116 (string-make-unibyte |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
117 (buffer-substring-no-properties ibeg iend))) |
31934 | 118 (image |
119 (create-image data nil t)) | |
120 (props | |
121 `(display ,image | |
64594
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
122 yank-handler |
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
123 (image-file-yank-handler nil t) |
31934 | 124 intangible ,image |
33727
242c7cbf0a6b
(insert-image-file): Don't make `read-only' property rear-nonsticky.
Miles Bader <miles@gnu.org>
parents:
33608
diff
changeset
|
125 rear-nonsticky (display intangible) |
31934 | 126 ;; This a cheap attempt to make the whole buffer |
33727
242c7cbf0a6b
(insert-image-file): Don't make `read-only' property rear-nonsticky.
Miles Bader <miles@gnu.org>
parents:
33608
diff
changeset
|
127 ;; read-only when we're visiting the file (as |
242c7cbf0a6b
(insert-image-file): Don't make `read-only' property rear-nonsticky.
Miles Bader <miles@gnu.org>
parents:
33608
diff
changeset
|
128 ;; opposed to just inserting it). |
35854
a8fd9112792b
(insert-image-file): When visiting an image, suppress the cursor in the
Miles Bader <miles@gnu.org>
parents:
34650
diff
changeset
|
129 ,@(and visitingp |
31934 | 130 '(read-only t front-sticky (read-only)))))) |
35854
a8fd9112792b
(insert-image-file): When visiting an image, suppress the cursor in the
Miles Bader <miles@gnu.org>
parents:
34650
diff
changeset
|
131 (add-text-properties ibeg iend props) |
a8fd9112792b
(insert-image-file): When visiting an image, suppress the cursor in the
Miles Bader <miles@gnu.org>
parents:
34650
diff
changeset
|
132 (when visitingp |
a8fd9112792b
(insert-image-file): When visiting an image, suppress the cursor in the
Miles Bader <miles@gnu.org>
parents:
34650
diff
changeset
|
133 ;; Inhibit the cursor when the buffer contains only an image, |
a8fd9112792b
(insert-image-file): When visiting an image, suppress the cursor in the
Miles Bader <miles@gnu.org>
parents:
34650
diff
changeset
|
134 ;; because cursors look very strange on top of images. |
35884
3d9c9fe711c4
(insert-image-file): When visiting an image, set `truncate-lines' to t
Miles Bader <miles@gnu.org>
parents:
35854
diff
changeset
|
135 (setq cursor-type nil) |
3d9c9fe711c4
(insert-image-file): When visiting an image, set `truncate-lines' to t
Miles Bader <miles@gnu.org>
parents:
35854
diff
changeset
|
136 ;; This just makes the arrow displayed in the right fringe |
3d9c9fe711c4
(insert-image-file): When visiting an image, set `truncate-lines' to t
Miles Bader <miles@gnu.org>
parents:
35854
diff
changeset
|
137 ;; area look correct when the image is wider than the window. |
3d9c9fe711c4
(insert-image-file): When visiting an image, set `truncate-lines' to t
Miles Bader <miles@gnu.org>
parents:
35854
diff
changeset
|
138 (setq truncate-lines t)))) |
31934 | 139 rval)) |
140 | |
64556
a0c4a6096f55
(insert-image-file): Add yank-handler.
Kim F. Storm <storm@cua.dk>
parents:
64091
diff
changeset
|
141 ;; We use a yank-handler to make yanked images unique, so that |
a0c4a6096f55
(insert-image-file): Add yank-handler.
Kim F. Storm <storm@cua.dk>
parents:
64091
diff
changeset
|
142 ;; yanking two copies of the same image next to each other are |
a0c4a6096f55
(insert-image-file): Add yank-handler.
Kim F. Storm <storm@cua.dk>
parents:
64091
diff
changeset
|
143 ;; recognized as two different images. |
a0c4a6096f55
(insert-image-file): Add yank-handler.
Kim F. Storm <storm@cua.dk>
parents:
64091
diff
changeset
|
144 (defun image-file-yank-handler (string) |
a0c4a6096f55
(insert-image-file): Add yank-handler.
Kim F. Storm <storm@cua.dk>
parents:
64091
diff
changeset
|
145 "Yank handler for inserting an image into a buffer." |
64594
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
146 (let ((len (length string)) |
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
147 (image (get-text-property 0 'display string))) |
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
148 (remove-text-properties 0 len yank-excluded-properties string) |
64556
a0c4a6096f55
(insert-image-file): Add yank-handler.
Kim F. Storm <storm@cua.dk>
parents:
64091
diff
changeset
|
149 (if (consp image) |
64594
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
150 (add-text-properties 0 |
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
151 (or (next-single-property-change 0 'image-counter string) |
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
152 (length string)) |
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
153 `(display |
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
154 ,(cons (car image) (cdr image)) |
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
155 yank-handler |
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
156 ,(cons 'image-file-yank-handler '(nil t))) |
7a0be66e1adb
(insert-image-file, image-file-yank-handler): Fix
Kim F. Storm <storm@cua.dk>
parents:
64556
diff
changeset
|
157 string)) |
64556
a0c4a6096f55
(insert-image-file): Add yank-handler.
Kim F. Storm <storm@cua.dk>
parents:
64091
diff
changeset
|
158 (insert string))) |
a0c4a6096f55
(insert-image-file): Add yank-handler.
Kim F. Storm <storm@cua.dk>
parents:
64091
diff
changeset
|
159 |
60523
2fa021a3a2fb
(image-file-handler): Put `safe-magic' property to
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
160 (put 'image-file-handler 'safe-magic t) |
31934 | 161 (defun image-file-handler (operation &rest args) |
32185
f7460e78c02a
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32003
diff
changeset
|
162 "Filename handler for inserting image files. |
31934 | 163 OPERATION is the operation to perform, on ARGS. |
164 See `file-name-handler-alist' for details." | |
32003
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
165 (if (and (eq operation 'insert-file-contents) |
ff2dfe1f1df9
(image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents:
31934
diff
changeset
|
166 auto-image-file-mode) |
31934 | 167 (apply #'insert-image-file args) |
168 ;; We don't handle OPERATION, use another handler or the default | |
169 (apply #'image-file-call-underlying operation operation args))) | |
170 | |
171 (defun image-file-call-underlying (function operation &rest args) | |
172 "Call FUNCTION with `image-file-handler' and OPERATION inhibited. | |
173 Optional argument ARGS are the arguments to call FUNCTION with." | |
174 (let ((inhibit-file-name-handlers | |
175 (cons 'image-file-handler | |
176 (and (eq inhibit-file-name-operation operation) | |
177 inhibit-file-name-handlers))) | |
178 (inhibit-file-name-operation operation)) | |
179 (apply function args))) | |
180 | |
181 | |
32316
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
182 ;;;###autoload |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
183 (define-minor-mode auto-image-file-mode |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
184 "Toggle visiting of image files as images. |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
185 With prefix argument ARG, turn on if positive, otherwise off. |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
186 Returns non-nil if the new state is enabled. |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
187 |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
188 Image files are those whose name has an extension in |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
189 `image-file-name-extensions', or matches a regexp in |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
190 `image-file-name-regexps'." |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
191 :global t |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
192 :group 'image |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
193 ;; Remove existing handler |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
194 (let ((existing-entry |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
195 (rassq 'image-file-handler file-name-handler-alist))) |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
196 (when existing-entry |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
197 (setq file-name-handler-alist |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
198 (delq existing-entry file-name-handler-alist)))) |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
199 ;; Add new handler, if enabled |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
200 (when auto-image-file-mode |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
201 (push (cons (image-file-name-regexp) 'image-file-handler) |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
202 file-name-handler-alist))) |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
203 |
b930d561cd53
(auto-image-file-mode): Move to the end of the file, because
Miles Bader <miles@gnu.org>
parents:
32220
diff
changeset
|
204 |
31934 | 205 (provide 'image-file) |
206 | |
52401 | 207 ;;; arch-tag: 04cafe36-f7ba-4c80-9f47-4cb656520ce1 |
31934 | 208 ;;; image-file.el ends here |