From 293a324649e23a93cfaf6f277fd835340ebdefa9 Mon Sep 17 00:00:00 2001 From: Felix Dietrich Date: Thu, 10 Mar 2022 04:36:52 +0100 Subject: [PATCH 08/10] =?UTF-8?q?Use=20macros=20with=20=E2=80=9CGeneralize?= =?UTF-8?q?d=20Variables=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For the last one (push new-minor-entry (cdr old-major)) it helped me to remember that old-major has the form: ("major" ("minor" . info) ("minor" . info)) So, to push a new entry to the front of the list of minor entries, you push it after "major", that is at the cdr. --- lisp/net/mailcap.el | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index e7575e8097..72d292c3e4 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -726,17 +726,15 @@ to supply to the test." (cond ((null old-major) ; New major area (setq new-major (list major new-minor-entry)) - (set storage - (cons new-major (symbol-value storage)))) + (push new-major (symbol-value storage))) ((and cur-minor (not (assq 'test info)) ; No test info, replace completely (not (assq 'test cur-minor)) (equal (assq 'viewer info) ; Keep alternative viewer (assq 'viewer cur-minor))) - (setcdr cur-minor info)) + (setf (cdr cur-minor) info)) (t - (setcdr old-major - (cons new-minor-entry (cdr old-major))))))) + (push new-minor-entry (cdr old-major)))))) (defun mailcap-add (type viewer &optional test) "Add VIEWER as a handler for TYPE. -- 2.35.1