From 6c004a0516ddc8d4323cfef6fbc2839e624ca811 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Thu, 4 Nov 2021 11:04:11 +0000 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 e40cf2a336..df6bdd1aba 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -423,14 +423,6 @@ mailcap-parse-mailcaps (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 @@ mailcap-parse-mailcaps (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.33.0