summaryrefslogtreecommitdiff
path: root/lisp/image-mode.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2009-11-28 20:45:19 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2009-11-28 20:45:19 +0000
commit26224fafa0c504defeff50909e887ea48b06353b (patch)
tree8d4538bdb483ee7c065a2d82d077e8f699beeb81 /lisp/image-mode.el
parentc6d47315357bc8a1e2345d6d941d136debe58b36 (diff)
downloademacs-26224fafa0c504defeff50909e887ea48b06353b.tar.gz
(image-minor-mode): Exit more gracefully when the image
cannot be displayed (e.g. when doing C-x C-f some-new-file.svg RET).
Diffstat (limited to 'lisp/image-mode.el')
-rw-r--r--lisp/image-mode.el30
1 files changed, 19 insertions, 11 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index bb97eb8e0b5..2351edc934c 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -362,18 +362,26 @@ See the command `image-mode' for more information on this mode."
(image-mode-setup-winprops)
(add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t)
(if (display-images-p)
- (if (not (image-get-display-property))
- (image-toggle-display)
- (setq cursor-type nil truncate-lines t
- image-type (plist-get (cdr (image-get-display-property)) :type)))
+ (condition-case err
+ (progn
+ (if (not (image-get-display-property))
+ (image-toggle-display)
+ (setq cursor-type nil truncate-lines t
+ image-type (plist-get (cdr (image-get-display-property))
+ :type)))
+ (message "%s"
+ (concat
+ (substitute-command-keys
+ "Type \\[image-toggle-display] to view the image as ")
+ (if (image-get-display-property)
+ "text" "an image") ".")))
+ (error
+ (image-toggle-display-text)
+ (funcall
+ (if (called-interactively-p 'any) 'error 'message)
+ "Cannot display image: %s" (cdr err))))
(setq image-type "text")
- (use-local-map image-mode-text-map))
- (if (display-images-p)
- (message "%s" (concat
- (substitute-command-keys
- "Type \\[image-toggle-display] to view the image as ")
- (if (image-get-display-property)
- "text" "an image") ".")))))
+ (use-local-map image-mode-text-map))))
;;;###autoload
(defun image-mode-maybe ()