From f565e581664e26679d726e317bae36d90e562784 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Thu, 4 Nov 2021 18:48:35 +0100 Subject: [PATCH] Reset mailcap entries only when mailcap files are read again * lisp/net/mailcap.el (mailcap-parse-mailcaps): Move the clear and load defaults operations at their appropriate place. Fixes bug#51600. --- lisp/net/mailcap.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index e40cf2a336d..df6bdd1aba5 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -423,14 +423,6 @@ MAILCAPS if set; otherwise (on Unix) use the path from RFC 1524, plus (interactive (list nil t)) (when (or (not mailcap-parsed-p) force) - ;; Clear out all old data. - (setq mailcap--computed-mime-data nil) - ;; Add the Emacs-distributed defaults (which will be used as - ;; fallbacks). Do it this way instead of just copying the list, - ;; since entries are destructively modified. - (cl-loop for (major . minors) in mailcap-mime-data - do (cl-loop for (minor . entry) in minors - do (mailcap-add-mailcap-entry major minor entry))) (cond (path nil) ((getenv "MAILCAPS") @@ -450,6 +442,14 @@ MAILCAPS if set; otherwise (on Unix) use the path from RFC 1524, plus (when (seq-some (lambda (f) (file-has-changed-p (car f) 'mail-parse-mailcaps)) path) + ;; Clear out all old data. + (setq mailcap--computed-mime-data nil) + ;; Add the Emacs-distributed defaults (which will be used as + ;; fallbacks). Do it this way instead of just copying the list, + ;; since entries are destructively modified. + (cl-loop for (major . minors) in mailcap-mime-data + do (cl-loop for (minor . entry) in minors + do (mailcap-add-mailcap-entry major minor entry))) ;; The ~/.mailcap entries will end up first in the resulting data. (dolist (spec (reverse (if (stringp path) -- 2.39.2