Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix handling of test clauses in mailcap entries
@ 2014-06-12  8:38 Elias Oltmanns
  2015-01-28  5:25 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Elias Oltmanns @ 2014-06-12  8:38 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

Hi there,

may I suggest a change to the mailcap code? The most important problem
I'd like to address is that under certain circumstances all mailcap
entries without a test clause are unconditionally disregarded when gnus
tries to find a suitable handler for the associated mime type. Please
let me know if you need further information.

Thanks,

Elias



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix-handling-of-test-clauses-in-mailcap-entries.patch --]
[-- Type: text/x-patch, Size: 2767 bytes --]

From edc4b2173b1aa915a89a1a3983f9e1965244c054 Mon Sep 17 00:00:00 2001
From: Elias Oltmanns <eo@nebensachen.de>
Date: Thu, 12 Jun 2014 10:15:01 +0200
Subject: Fix handling of test clauses in mailcap entries

* mailcap.el (mailcap-mailcap-entry-passes-test):
- Consider mailcap entries with needsterminal or needsx11 attributes
  but no test clause.
- Test clauses checking for the DISPLAY environment variable may
  consist of additional follow-up checks; so, do not jump to
  conclusions.
(mailcap-viewer-passes-test): Check whether there is anything to test
before consulting and possibly updating the cache. Otherwise,
preevaluated, failed tests lead to an entry (nil nil) in the cache and
all mailcap entries without a test clause are disregarded from then
on.
---
 lisp/mailcap.el | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/lisp/mailcap.el b/lisp/mailcap.el
index 4f1bdf4..1040500 100644
--- a/lisp/mailcap.el
+++ b/lisp/mailcap.el
@@ -555,20 +555,26 @@ Also return non-nil if no test clause is present."
 		 (assoc "needsterminal" info)
 		 (assoc "needsx11" info))
 	     (not (getenv "DISPLAY")))
-	(setq status nil)
+	(if test
+	    (setq status nil)
+	  (nconc info (list (cons 'test 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)))
+	(if (not (getenv "DISPLAY"))
+	    (setq status nil)
+	  (unless (nth 3 status)
+	    (setq status t))))
        ((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)))
+	(if (getenv "DISPLAY")
+	    (setq status nil)
+	  (unless (nth 3 status)
+	    (setq status t))))))
     (and test (listp test) (setcdr test status))))
 
 ;;;
@@ -648,15 +654,15 @@ to supply to the test."
 	 (viewer (cdr (assoc 'viewer viewer-info)))
 	 (default-directory (expand-file-name "~/"))
 	 status parsed-test cache result)
-    (cond ((setq cache (assoc test mailcap-viewer-test-cache))
+    (cond ((not test-info) t)		; No test clause
+	  ((not test) nil)		; Already failed test
+	  ((eq test t) t)		; Already passed test
+	  ((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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix handling of test clauses in mailcap entries
  2014-06-12  8:38 [PATCH] Fix handling of test clauses in mailcap entries Elias Oltmanns
@ 2015-01-28  5:25 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2015-01-28  5:25 UTC (permalink / raw)
  To: Elias Oltmanns; +Cc: ding

Elias Oltmanns <eo@nebensachen.de> writes:

> may I suggest a change to the mailcap code? The most important problem
> I'd like to address is that under certain circumstances all mailcap
> entries without a test clause are unconditionally disregarded when gnus
> tries to find a suitable handler for the associated mime type. Please
> let me know if you need further information.

Under what circumstances does that happen?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-28  5:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12  8:38 [PATCH] Fix handling of test clauses in mailcap entries Elias Oltmanns
2015-01-28  5:25 ` Lars Ingebrigtsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).