Function: mailcap-mailcap-entry-passes-test

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

Signature

(mailcap-mailcap-entry-passes-test INFO)

Documentation

Replace the test clause of INFO itself with a boolean for some cases.

This function supports only test -n $DISPLAY and test -z $DISPLAY, replaces them with t or nil. As for others or if INFO has an interactive spec (needsterm, needsterminal, or needsx11) but DISPLAY is not set, the test clause will be unchanged.

Source Code

;; Defined in /usr/src/emacs/lisp/net/mailcap.el.gz
(defun mailcap-mailcap-entry-passes-test (info)
  "Replace the test clause of INFO itself with a boolean for some cases.
This function supports only `test -n $DISPLAY' and `test -z $DISPLAY',
replaces them with t or nil.  As for others or if INFO has an interactive
spec (needsterm, needsterminal, or needsx11) but DISPLAY is not set,
the test clause will be unchanged."
  (let ((test (assq 'test info))	; The test clause
	status)
    (setq status (and test (split-string (cdr test) " ")))
    (if (and (or (assoc "needsterm" info)
		 (assoc "needsterminal" info)
		 (assoc "needsx11" info))
	     (not (getenv "DISPLAY")))
	(setq status nil)
      (cond
       ((and (equal (nth 0 status) "test")
	     (equal (nth 1 status) "-n")
	     (or (equal (nth 2 status) "$DISPLAY")
		 (equal (nth 2 status) "\"$DISPLAY\"")))
	(setq status (if (getenv "DISPLAY") t nil)))
       ((and (equal (nth 0 status) "test")
	     (equal (nth 1 status) "-z")
	     (or (equal (nth 2 status) "$DISPLAY")
		 (equal (nth 2 status) "\"$DISPLAY\"")))
	(setq status (if (getenv "DISPLAY") nil t)))
       (test nil)
       (t nil)))
    (and test (listp test) (setcdr test status))))