Commits

Anonymous committed 1117170

Applied Stephen Turnbull's patch from
<14503.53669.684857.723924@turnbull.sk.tsukuba.ac.jp>
with subject "Make image-mode.el less APEL-ing.".

Comments (0)

Files changed (2)

+2000-02-14  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* image-mode.el (image-external-viewer): Remove variable.
+	(image-external-viewer-list): New variable.
+	(image-start-external-viewer): Search `image-external-viewer-list'
+        at run-time, rather than set `image-external-viewer' at load-time.
+
 2000-01-15  Andreas Jaeger <aj@xemacs.org>
 
 	* flyspell.el (global-flyspell-mode): Reverted last patch for now
-;;; image-mode.el --- Major mode for navigate images
+;;; image-mode.el --- Major mode for navigating images
 
 ;; Copyright (C) 1997 MORIOKA Tomohiko
 
 (define-key image-mode-map "e" 'image-enter-xpm-mode)
 (define-key image-mode-map "q" 'image-mode-quit)
 
-(defvar image-external-viewer
-  (cond ((exec-installed-p "display")	 "display")	; ImageMagic
-	((exec-installed-p "xv")	 "xv")		; xv
-	)
-  "*External viewer for image-mode.")
+;; ### There must be a general way of doing this, using mimecap....
+(defvar image-external-viewer-list
+  '("display"				; ImageMagic
+    "xv"				; xv
+    )
+  "*List of external viewers for image-mode.
+
+Each viewer is a string, to be called via `start-process'.  If null,
+no external viewer will be used.")
 
 (defun image-start-external-viewer ()
   "Start external image viewer for current-buffer.
-It uses `image-external-viewer' as external image viewer."
+
+It tries each program name in `image-external-viewer-list' in order.
+If `image-external-viewer-list' is empty, or none of the viewers can
+be found, signals an error."
+
   (interactive)
-  (start-process "external image viewer" nil
-		 image-external-viewer buffer-file-name)
-  )
+  (let ((vl image-external-viewer-list))
+    (if vl
+	(catch 'done
+	  (while vl
+	    (condition-case nil
+		(progn
+		  (start-process "external image viewer" nil
+				 (car vl) buffer-file-name)
+		  (throw 'done nil))	; exit loop
+	      (file-error (setq vl (cdr vl)))))
+	  (error "image-start-external-viewer:  couldn't start any viewer in `image-external-viewer-list'"))
+      (error "image-start-external-viewer:  `image-external-viewer-list' is empty."))))
 
 (defun image-toggle-decoding ()
   "Toggle image display mode in current buffer."