annotate lisp/image-file.el @ 32005:01a7fea88dc1

(authors-print): Rephrase many-files string.
author Miles Bader <miles@gnu.org>
date Fri, 29 Sep 2000 13:55:23 +0000
parents ff2dfe1f1df9
children f7460e78c02a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; image-file.el --- Support for visiting image files
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
2 ;;
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 2000 Free Software Foundation, Inc.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
4 ;;
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
5 ;; Author: Miles Bader <miles@gnu.org>
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; Keywords: multimedia
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
7
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
9
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
13 ;; any later version.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
14
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
19
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
24
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
26
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
27 ;; Defines a file-name-handler hook that transforms visited (or
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
28 ;; inserted) image files so that they are by displayed as emacs as
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
29 ;; images. This is done by putting a `display' text-property on the
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
30 ;; image data, with the image-data still present underneath; if the
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
31 ;; resulting buffer file is saved to another name it will correctly save
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
32 ;; the image data to the new file.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
33
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
34 ;;; Code:
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
35
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
36 (require 'image)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
37
32003
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
38
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
39 (defcustom image-file-name-extensions
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
40 '("png" "jpeg" "jpg" "gif" "tiff" "xbm" "xpm")
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
41 "*A list of image-file filename extensions.
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
42 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
43 in addition to those matching `image-file-name-regexps'.
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
44
32003
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
45 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
46 setting this variable directly does not take effect unless
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
47 `auto-image-file-mode' is re-enabled; this happens automatically the
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
48 variable is set using \\[customize]."
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
49 :type '(repeat string)
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
50 :set (lambda (sym val)
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
51 (set-default sym val)
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
52 (when auto-image-file-mode
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
53 ;; Re-initialize the image-file handler
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
54 (auto-image-file-mode t)))
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
55 :initialize 'custom-initialize-default
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
56 :group 'image)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
57
32003
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
58 (defcustom image-file-name-regexps nil
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
59 "*A list of regexps matching image-file filenames.
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
60 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
61 in addition to those with an extension in `image-file-name-extensions'.
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
62
32003
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
63 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
64 setting this variable directly does not take effect unless
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
65 `auto-image-file-mode' is re-enabled; this happens automatically the
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
66 variable is set using \\[customize]."
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
67 :type '(repeat regexp)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
68 :set (lambda (sym val)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
69 (set-default sym val)
32003
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
70 (when auto-image-file-mode
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
71 ;; Re-initialize the image-file handler
32003
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
72 (auto-image-file-mode t)))
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
73 :initialize 'custom-initialize-default
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
74 :group 'image)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
75
32003
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
76
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
77 ;;;###autoload
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
78 (defun image-file-name-regexp ()
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
79 "Return a regular expression that matches image-file filenames."
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
80 (let ((exts-regexp
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
81 (and image-file-name-extensions
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
82 (concat "\\."
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
83 (regexp-opt image-file-name-extensions t)
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
84 "\\'"))))
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
85 (if image-file-name-regexps
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
86 (mapconcat 'identity
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
87 (if exts-regexp
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
88 (cons exts-regexp image-file-regexps)
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
89 image-file-regexps)
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 exts-regexp)))
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
92
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
93
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
94 ;;;###autoload
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
95 (define-minor-mode auto-image-file-mode
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
96 "Toggle visiting of image files as images.
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
97 With prefix argument ARG, turn on if positive, otherwise off.
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
98 Returns non-nil if the new state is enabled.
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 Image files are those whose name has an extension in
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
101 `image-file-name-extensions', or matches a regexp in
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
102 `image-file-name-regexps'."
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
103 nil
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
104 nil
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
105 nil
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
106 :global t
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
107 :group 'image
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
108 ;; Remove existing handler
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
109 (let ((existing-entry
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
110 (rassq 'image-file-handler file-name-handler-alist)))
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
111 (when existing-entry
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
112 (setq file-name-handler-alist
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
113 (delq existing-entry file-name-handler-alist))))
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
114 ;; Add new handler, if enabled
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
115 (when auto-image-file-mode
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
116 (push (cons (image-file-name-regexp) 'image-file-handler)
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
117 file-name-handler-alist)))
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
118
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
119
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
120 ;;;###autoload
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
121 (defun insert-image-file (file &optional visit beg end replace)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
122 "Insert the image file FILE into the current buffer.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
123 Optional arguments VISIT, BEG, END, and REPLACE are interpreted as for
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
124 the command `insert-file-contents'."
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
125 (let ((rval
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
126 (image-file-call-underlying #'insert-file-contents-literally
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
127 'insert-file-contents
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
128 file visit beg end replace)))
32003
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
129 ;; 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
130 ;; was inserted
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
131 (when (and (or (null beg) (zerop beg)) (null end))
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
132 (let* ((ibeg (point))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
133 (iend (+ (point) (cadr rval)))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
134 (data
32003
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
135 (string-make-unibyte
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
136 (buffer-substring-no-properties ibeg iend)))
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
137 (image
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
138 (create-image data nil t))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 (props
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
140 `(display ,image
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 intangible ,image
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
142 rear-nonsticky (display)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
143 ;; This a cheap attempt to make the whole buffer
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 ;; read-only when we're visiting the file.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
145 ,@(and visit
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
146 (= ibeg (point-min))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
147 (= iend (point-max))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
148 '(read-only t front-sticky (read-only))))))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
149 (add-text-properties ibeg iend props)))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
150 rval))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
151
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
152 (defun image-file-handler (operation &rest args)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
153 "File name handler for inserting image files.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
154 OPERATION is the operation to perform, on ARGS.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
155 See `file-name-handler-alist' for details."
32003
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
156 (if (and (eq operation 'insert-file-contents)
ff2dfe1f1df9 (image-file-name-extensions): New variable.
Miles Bader <miles@gnu.org>
parents: 31934
diff changeset
157 auto-image-file-mode)
31934
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
158 (apply #'insert-image-file args)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
159 ;; We don't handle OPERATION, use another handler or the default
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
160 (apply #'image-file-call-underlying operation operation args)))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
161
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
162 (defun image-file-call-underlying (function operation &rest args)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
163 "Call FUNCTION with `image-file-handler' and OPERATION inhibited.
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
164 Optional argument ARGS are the arguments to call FUNCTION with."
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
165 (let ((inhibit-file-name-handlers
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
166 (cons 'image-file-handler
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
167 (and (eq inhibit-file-name-operation operation)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
168 inhibit-file-name-handlers)))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
169 (inhibit-file-name-operation operation))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
170 (apply function args)))
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
171
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
172
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
173 (provide 'image-file)
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
174
27f239b438d2 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
175 ;;; image-file.el ends here