Function: mailcap-viewer-passes-test

mailcap-viewer-passes-test is a byte-compiled function defined in mailcap.el.gz.

Signature

(mailcap-viewer-passes-test VIEWER-INFO TYPE-INFO)

Documentation

Return non-nil if viewer specified by VIEWER-INFO passes its test clause.

Also return non-nil if it has no test clause. TYPE-INFO is an argument to supply to the test.

Source Code

;; Defined in /usr/src/emacs/lisp/net/mailcap.el.gz
(defun mailcap-viewer-passes-test (viewer-info type-info)
  "Return non-nil if viewer specified by VIEWER-INFO passes its test clause.
Also return non-nil if it has no test clause.  TYPE-INFO is an argument
to supply to the test."
  (let* ((test-info (assq 'test viewer-info))
	 (test (cdr test-info))
	 (otest test)
	 (viewer (cdr (assq 'viewer viewer-info)))
	 (default-directory (expand-file-name "~/"))
	 status cache result)
    (cond ((not (or (stringp viewer) (fboundp viewer)))
	   nil)				; Non-existent Lisp function
	  ((setq cache (assoc test mailcap-viewer-test-cache))
	   (cadr cache))
	  ((not test-info) t)		; No test clause
	  (t
	   (setq
	    result
	    (cond
	     ((not test) nil)		; Already failed test
	     ((eq test t) t)		; Already passed test
	     ((functionp test)		; Lisp function as test
	      (funcall test type-info))
	     ((and (symbolp test)	; Lisp variable as test
		   (boundp test))
	      (symbol-value test))
	     ((and (listp test)		; List to be eval'd
		   (symbolp (car test)))
	      (eval test t))
	     (t
	      (setq test (mailcap-unescape-mime-test test type-info)
		    test (list shell-file-name nil nil nil
			       shell-command-switch test)
		    status (apply #'call-process test))
	      (eq 0 status))))
	   (push (list otest result) mailcap-viewer-test-cache)
	   result))))