Gnus development mailing list
 help / color / mirror / Atom feed
From: Elias Oltmanns <eo@nebensachen.de>
To: ding@gnus.org
Subject: [PATCH] Fix handling of test clauses in mailcap entries
Date: Thu, 12 Jun 2014 10:38:55 +0200	[thread overview]
Message-ID: <874mzqsesg.fsf@denkblock.local> (raw)

[-- 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

             reply	other threads:[~2014-06-12  8:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-12  8:38 Elias Oltmanns [this message]
2015-01-28  5:25 ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874mzqsesg.fsf@denkblock.local \
    --to=eo@nebensachen.de \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).