From e8b7530008feb232ead9c91dac2d23e7392b02e3 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Mon, 1 Nov 2021 01:22:51 +0000 Subject: [PATCH] Read mailcaps again only when necessary. * lisp/net/mailcap.el (mailcap-parse-mailcaps): Read mailcaps again only when at least one of the mailcap files has changed. Fixes bug#51523. --- lisp/net/mailcap.el | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index 83d0eeef9f..a147ee0ce3 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -447,19 +447,23 @@ mailcap-parse-mailcaps ("/etc/mailcap" system) ("/usr/etc/mailcap" system) ("/usr/local/etc/mailcap" system))))) - ;; The ~/.mailcap entries will end up first in the resulting data. - (dolist (spec (reverse - (if (stringp path) - (split-string path path-separator t) - path))) - (let ((source (and (consp spec) (cadr spec))) - (file-name (if (stringp spec) - spec - (car spec)))) - (when (and (file-readable-p file-name) - (file-regular-p file-name)) - (mailcap-parse-mailcap file-name source)))) - (setq mailcap-parsed-p t))) + (let ((file-has-changed nil)) + (dolist (file path) + (when-file-has-changed (car file) (setq file-has-changed t))) + (when file-has-changed + ;; The ~/.mailcap entries will end up first in the resulting data. + (dolist (spec (reverse + (if (stringp path) + (split-string path path-separator t) + path))) + (let ((source (and (consp spec) (cadr spec))) + (file-name (if (stringp spec) + spec + (car spec)))) + (when (and (file-readable-p file-name) + (file-regular-p file-name)) + (mailcap-parse-mailcap file-name source))))) + (setq mailcap-parsed-p t)))) (defun mailcap-parse-mailcap (fname &optional source) "Parse out the mailcap file specified by FNAME. -- 2.33.0