# HG changeset patch # User Stefan Monnier # Date 1259441119 0 # Node ID 94b85d4a3456b2f95ec7cad09ece74c6f54af017 # Parent d3af107622c78bbff340c643d3089f8e0398fad2 (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). diff -r d3af107622c7 -r 94b85d4a3456 lisp/ChangeLog --- a/lisp/ChangeLog Sat Nov 28 20:36:05 2009 +0000 +++ b/lisp/ChangeLog Sat Nov 28 20:45:19 2009 +0000 @@ -1,5 +1,8 @@ 2009-11-28 Stefan Monnier + * image-mode.el (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). + * man.el (Man-completion-table): Make it easier to enter " ". * eshell/em-prompt.el (eshell-prompt-function): Abbreviate pwd, since diff -r d3af107622c7 -r 94b85d4a3456 lisp/image-mode.el --- a/lisp/image-mode.el Sat Nov 28 20:36:05 2009 +0000 +++ b/lisp/image-mode.el Sat Nov 28 20:45:19 2009 +0000 @@ -362,18 +362,26 @@ (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 ()