comparison lisp/image-file.el @ 32316:b930d561cd53

(auto-image-file-mode): Move to the end of the file, because `define-minor-mode' actually calls the mode-function if the associated variable is non-nil, which requires that all needed functions be already defined.
author Miles Bader <miles@gnu.org>
date Sun, 08 Oct 2000 23:23:55 +0000
parents 3c7e4ccb6fee
children 4e98e54082d2
comparison
equal deleted inserted replaced
32315:0da9507401c4 32316:b930d561cd53
90 "\\|") 90 "\\|")
91 exts-regexp))) 91 exts-regexp)))
92 92
93 93
94 ;;;###autoload 94 ;;;###autoload
95 (define-minor-mode auto-image-file-mode
96 "Toggle visiting of image files as images.
97 With prefix argument ARG, turn on if positive, otherwise off.
98 Returns non-nil if the new state is enabled.
99
100 Image files are those whose name has an extension in
101 `image-file-name-extensions', or matches a regexp in
102 `image-file-name-regexps'."
103 nil
104 nil
105 nil
106 :global t
107 :group 'image
108 ;; Remove existing handler
109 (let ((existing-entry
110 (rassq 'image-file-handler file-name-handler-alist)))
111 (when existing-entry
112 (setq file-name-handler-alist
113 (delq existing-entry file-name-handler-alist))))
114 ;; Add new handler, if enabled
115 (when auto-image-file-mode
116 (push (cons (image-file-name-regexp) 'image-file-handler)
117 file-name-handler-alist)))
118
119
120 ;;;###autoload
121 (defun insert-image-file (file &optional visit beg end replace) 95 (defun insert-image-file (file &optional visit beg end replace)
122 "Insert the image file FILE into the current buffer. 96 "Insert the image file FILE into the current buffer.
123 Optional arguments VISIT, BEG, END, and REPLACE are interpreted as for 97 Optional arguments VISIT, BEG, END, and REPLACE are interpreted as for
124 the command `insert-file-contents'." 98 the command `insert-file-contents'."
125 (let ((rval 99 (let ((rval
168 inhibit-file-name-handlers))) 142 inhibit-file-name-handlers)))
169 (inhibit-file-name-operation operation)) 143 (inhibit-file-name-operation operation))
170 (apply function args))) 144 (apply function args)))
171 145
172 146
147 ;;; Note this definition must be at the end of the file, because
148 ;;; `define-minor-mode' actually calls the mode-function if the
149 ;;; associated variable is non-nil, which requires that all needed
150 ;;; functions be already defined. [This is arguably a bug in d-m-m]
151 ;;;###autoload
152 (define-minor-mode auto-image-file-mode
153 "Toggle visiting of image files as images.
154 With prefix argument ARG, turn on if positive, otherwise off.
155 Returns non-nil if the new state is enabled.
156
157 Image files are those whose name has an extension in
158 `image-file-name-extensions', or matches a regexp in
159 `image-file-name-regexps'."
160 nil
161 nil
162 nil
163 :global t
164 :group 'image
165 ;; Remove existing handler
166 (let ((existing-entry
167 (rassq 'image-file-handler file-name-handler-alist)))
168 (when existing-entry
169 (setq file-name-handler-alist
170 (delq existing-entry file-name-handler-alist))))
171 ;; Add new handler, if enabled
172 (when auto-image-file-mode
173 (push (cons (image-file-name-regexp) 'image-file-handler)
174 file-name-handler-alist)))
175
176
173 (provide 'image-file) 177 (provide 'image-file)
174 178
175 ;;; image-file.el ends here 179 ;;; image-file.el ends here