From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 01 17:38:02 2022 Received: (at submit) by debbugs.gnu.org; 1 Sep 2022 21:38:02 +0000 Received: from localhost ([127.0.0.1]:44305 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oTrsv-0001jd-E2 for submit@debbugs.gnu.org; Thu, 01 Sep 2022 17:38:02 -0400 Received: from lists.gnu.org ([209.51.188.17]:58060) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oTrss-0001jT-9s for submit@debbugs.gnu.org; Thu, 01 Sep 2022 17:37:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTrsr-0006PH-1G for bug-gnu-emacs@gnu.org; Thu, 01 Sep 2022 17:37:58 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:41771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTrso-0004i3-3b for bug-gnu-emacs@gnu.org; Thu, 01 Sep 2022 17:37:56 -0400 Received: from localhost ([78.54.95.255]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N6srB-1pSped3HWJ-018GD9 for ; Thu, 01 Sep 2022 23:37:48 +0200 From: Felix Dietrich To: bug-gnu-emacs Subject: Restructure mailcap-add-mailcap-entry to improve readability User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) X-Debbugs-CC: Lars Ingebrigtsen Date: Thu, 01 Sep 2022 23:37:41 +0200 Message-ID: <878rn2rd22.fsf@sperrhaken.name> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:fDVmRQvRx2KIAKdZlT30CBk+vG33vXdXF8b4R+7risgu+CL+Qvy 6LmBXQjq3gpPrmA+Vo9rJtCfW8ldIGMWEmMSlRWEZEiEyGGUiq9yV7NusH5E+DWdBiEoaBu 2DuVGhEzQu9lAawrvtGtCw7gEf3xW5t4WyNhMbsQT5KukKFM7FxnBiZH6HcFXYVuMPfOtOe zXkgweBSnF44APr+xGhjg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:syXoJw2Y3J8=:gBEYaY0ABfRlq/teHQegKv OSr6SI+421S6W1KSzscWRcMD4Uo/eQpaapmdYAHncl2RuqjWDqkrzxSO0f3FVC117ttxZVGhZ NzxUw8di0SsjnwZSQU8Y9Ko10DAq8gfABxowXWtYCXBQ6rN5BliYKo3ry8eYNjWESlY/mMXLx rsPLql5m0OWy7VGBgXm5yut2/zkTF+WyIPZMr04GTR9hVP85BZZu44G1oo57WuVCiD6Eb/h05 LI8TwZpmrmteslDdsV7WX8r8P13zYWQsjwGDVrNQVRcsn6x4DJkmtVBJeIXuBjLMcgMtQCE+a 8mdaWXz+2CLqg0ZGOl2Pmt4kWwRuCzPCnssYtcv7cF7HlxPqO8XG0gXeIy3OdMZduX2rIAu/u EIenBCa/erLtVII6mAO7z0QffFSHJXnkd1ICEbrI7w00w+wbx3snLBpNsrPHcNxCAKJfrfHWz usCTRGeCzdUq4SZ5n6iO4FbmkkOatUy4/VDzC3ehSOR2Y8huupI5vaJGz4CDu/G7HbYOIY9r+ W7K1Z9Q3mYigT/QPBpjlp5wwhLy7TCjEAN5Df0bgL3BPW1WklODq/MCMV0Md456l5rJwg2x4C GUw5gcPygo9x6AhbwFELe5eBf/RazoGBBcCsZmFgdDWKdnMyahpv7PIXgN8ntanN3eg4s5tOO NkDdaS7RCrYUGcfWoLK2GhkApDEonf+r4ib8gSZtJWCzxgk7xXEfy4aK1ZaXqjaY20nTMKdfb YUF2sxaiPr94/Ld7BcVIDiQkVfJgNo+kf9aEK/5hHuHWq3ck5yT8Gk3Ee3dKDhJ7GYByHB/CR jCL7YFOVlVQNn0qjpAv99s0EFnDWA== Received-SPF: none client-ip=217.72.192.73; envelope-from=felix.dietrich@sperrhaken.name; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Package: emacs Tags: patch Severity: wishlist Hello, =E2=80=98mailcap-add-mailcap-entry=E2=80=99 is written in a way that makes = it hard to follow. My patch aims to improve its readability. In order to show that my modification retains the original functionality, another Patch adds ERT test cases for this function. The new version also shows clearer an issue with the current implementation that causes some mailcap entries to be forgotten; this is mentioned in a comment. A docstring for the function is added as well. As was suggested by Lars in March on the emacs-devel mailing list [1], I am submitting my patches now to the bug tracker for them not to be forgotten (which I should have done then =E2=80=93 but life got in the way)= . By now, I have signed the copyright assignment papers, and they have been processed. Footnotes: [1] Message-ID: <878rt3nync.fsf@gnus.org> https://lists.gnu.org/archive/html/emacs-devel/2022-03/msg00593.html --=20 Felix Dietrich --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Add-tests-for-mailcap-add-mailcap-entry.patch Content-Transfer-Encoding: quoted-printable Content-Description: Patch to add tests for =?utf-8?Q?=E2=80=98mailcap-add-mailcap-entry?= =?utf-8?Q?=E2=80=99?= >From d698762f6e0bcb3176e0c2696dc2443aee0496e5 Mon Sep 17 00:00:00 2001 From: Felix Dietrich Date: Mon, 14 Mar 2022 14:01:26 +0100 Subject: [PATCH] =3D?UTF-8?q?Add=3D20tests=3D20for=3D20=3DE2=3D80=3D98mailc= ap-add-mailca?=3D =3D?UTF-8?q?p-entry=3DE2=3D80=3D99?=3D MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * test/lisp/net/mailcap-tests.el: Add tests for =E2=80=98mailcap-add-mailcap-entry=E2=80=99 --- test/lisp/net/mailcap-tests.el | 405 +++++++++++++++++++++++++++++++++ 1 file changed, 405 insertions(+) diff --git a/test/lisp/net/mailcap-tests.el b/test/lisp/net/mailcap-tests.el index 188706fc86..c4f011dd1a 100644 --- a/test/lisp/net/mailcap-tests.el +++ b/test/lisp/net/mailcap-tests.el @@ -133,4 +133,409 @@ (mailcap-view-file (ert-resource-file "test.test"))) (should mailcap--test-result)))) =20 + + +(ert-deftest mailcap-add-mailcap-entry-new-major () + "Add a major entry not yet in =E2=80=98mailcap-mime-data=E2=80=99." + (let ((mailcap-mime-data)) + + ;; Add a new major entry to a empty =E2=80=98mailcap-mime-data=E2=80= =99. + (mailcap-add-mailcap-entry "major1" "minor1" + (list (cons 'viewer "viewer1")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major1" + ("minor1" . ((viewer . "viewer1"))))))) + + ;; Add a new major entry to a non-empty =E2=80=98mailcap-mime-data=E2= =80=99. + (mailcap-add-mailcap-entry "major2" "minor2" + (list (cons 'viewer "viewer2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major2" + ("minor2" . ((viewer . "viewer2")))) + ("major1" + ("minor1" . ((viewer . "viewer1")))))))) + + ;; Same spiel but with extra entries in INFO. + (let ((mailcap-mime-data)) + ;; Add a new major entry to an empty =E2=80=98mailcap-mime-data=E2=80= =99. + (mailcap-add-mailcap-entry "major1" "minor1" + (list (cons 'viewer "viewer1") + (cons 'print "print1")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major1" + ("minor1" . ((viewer . "viewer1") + (print . "print1"))))))) + + ;; Add a new major entry to a non-empty =E2=80=98mailcap-mime-data=E2= =80=99. + (mailcap-add-mailcap-entry "major2" "minor2" + (list (cons 'viewer "viewer2") + (cons 'print "print2") + (cons 'compose "compose2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major2" + ("minor2" . ((viewer . "viewer2") + (print . "print2") + (compose . "compose2")))) + ("major1" + ("minor1" . ((viewer . "viewer1") + (print . "print1"))))))))) + + +(ert-deftest mailcap-add-mailcap-entry-new-minor-to-empty-major () + "Add a minor entry to a an empty major entry." + (let ((mailcap-mime-data (list (list "major")))) + (mailcap-add-mailcap-entry "major" "minor1" + (list (cons 'viewer "viewer1") + (cons 'print "print1")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor1" . ((viewer . "viewer1") + (print . "print1"))))))))) + +(ert-deftest mailcap-add-mailcap-entry-new-minor-to-non-empty-major () + "Add a minor to a major entry containing already minor entries." + (let ((mailcap-mime-data + (list + (list "major" + (list "minor1" + (cons 'viewer "viewer1") + (cons 'test "test1") + (cons 'print "print1")))))) + + (mailcap-add-mailcap-entry "major" "minor2" + (list (cons 'viewer "viewer2") + (cons 'test "test2") + (cons 'print "print2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor2" . ((viewer . "viewer2") + (test . "test2") + (print . "print2"))) + ("minor1" . ((viewer . "viewer1") + (test . "test1") + (print . "print1"))))))) + + (mailcap-add-mailcap-entry "major" "minor3" + (list (cons 'viewer "viewer3") + (cons 'test "test3") + (cons 'compose "compose3")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor3" . ((viewer . "viewer3") + (test . "test3") + (compose . "compose3"))) + ("minor2" . ((viewer . "viewer2") + (test . "test2") + (print . "print2"))) + ("minor1" . ((viewer . "viewer1") + (test . "test1") + (print . "print1"))))))))) + +(ert-deftest mailcap-add-mailcap-entry-new-minor-to-various-major-position= s () + "Add a new minor entry to major entries at various postions +in =E2=80=98mailcap-mime-data=E2=80=99." + (let ((mailcap-mime-data + (list + (list "major1" + (list "minor1.1" + (cons 'viewer "viewer1.1") + (cons 'print "print1.1"))) + (list "major2" + (list "minor2.1" + (cons 'viewer "viewer2.1") + (cons 'print "print2.1") + (cons 'compose "compose2.1"))) + (list "major3" + (list "minor3.1" + (cons 'viewer "viewer3.1") + (cons 'compose "compose3.1"))) + (list "major4" + (list "minor4.1" + (cons 'viewer "viewer4.1") + (cons 'edit "edit4.1")))))) + + ;; Add a minor entry to a major mode at the front of + ;; =E2=80=98mailcap-mime-data=E2=80=99. + (mailcap-add-mailcap-entry "major1" "minor1.2" + (list (cons 'viewer "viewer1.2") + (cons 'test "test1.2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major1" + ("minor1.2" . ((viewer . "viewer1.2") + (test . "test1.2"))) + ("minor1.1" . ((viewer . "viewer1.1") + (print . "print1.1")))) + ("major2" + ("minor2.1" . ((viewer . "viewer2.1") + (print . "print2.1") + (compose . "compose2.1")))) + ("major3" + ("minor3.1" . ((viewer . "viewer3.1") + (compose . "compose3.1")))) + ("major4" + ("minor4.1" . ((viewer . "viewer4.1") + (edit . "edit4.1"))))))) + + ;; Add a minor entry to a major mode in the middle of + ;; =E2=80=98mailcap-mime-data=E2=80=99. + (mailcap-add-mailcap-entry "major3" "minor3.2" + (list (cons 'viewer "viewer3.2") + (cons 'test "test3.2") + (cons 'compose "compose3.2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major1" + ("minor1.2" . ((viewer . "viewer1.2") + (test . "test1.2"))) + ("minor1.1" . ((viewer . "viewer1.1") + (print . "print1.1")))) + ("major2" + ("minor2.1" . ((viewer . "viewer2.1") + (print . "print2.1") + (compose . "compose2.1")))) + ("major3" + ("minor3.2" . ((viewer . "viewer3.2") + (test . "test3.2") + (compose . "compose3.2"))) + ("minor3.1" . ((viewer . "viewer3.1") + (compose . "compose3.1")))) + ("major4" + ("minor4.1" . ((viewer . "viewer4.1") + (edit . "edit4.1"))))))) + + ;; Add a minor entry to a major mode at the end of + ;; =E2=80=98mailcap-mime-data=E2=80=99. + (mailcap-add-mailcap-entry "major4" "minor4.2" + (list (cons 'viewer "viewer4.2") + (cons 'test "test4.2") + (cons 'print "print4.2") + (cons 'compose "compose4.2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major1" + ("minor1.2" . ((viewer . "viewer1.2") + (test . "test1.2"))) + ("minor1.1" . ((viewer . "viewer1.1") + (print . "print1.1")))) + ("major2" + ("minor2.1" . ((viewer . "viewer2.1") + (print . "print2.1") + (compose . "compose2.1")))) + ("major3" + ("minor3.2" . ((viewer . "viewer3.2") + (test . "test3.2") + (compose . "compose3.2"))) + ("minor3.1" . ((viewer . "viewer3.1") + (compose . "compose3.1")))) + ("major4" + ("minor4.2" . ((viewer . "viewer4.2") + (test . "test4.2") + (print . "print4.2") + (compose . "compose4.2"))) + ("minor4.1" . ((viewer . "viewer4.1") + (edit . "edit4.1"))))))))) + +(ert-deftest mailcap-add-mailcap-entry-existing-with-test-differing-viewer= () + "Add a new entry for an already existing major/minor entry." + + ;; The new and the existing entry have each a test info field. + (let ((mailcap-mime-data + (list + (list "major" + (list "minor" + (cons 'viewer "viewer1") + (cons 'test "test1") + (cons 'print "print1")))))) + (mailcap-add-mailcap-entry "major" "minor" + (list (cons 'viewer "viewer2") + (cons 'test "test2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor" . ((viewer . "viewer2") + (test . "test2"))) + ("minor" . ((viewer . "viewer1") + (test . "test1") + (print . "print1")))))))) + + ;; Only the new entry has a test info field. + (let ((mailcap-mime-data + (list + (list "major" + (list "minor" + (cons 'viewer "viewer1") + (cons 'print "print1")))))) + (mailcap-add-mailcap-entry "major" "minor" + (list (cons 'viewer "viewer2") + (cons 'test "test2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor" . ((viewer . "viewer2") + (test . "test2"))) + ("minor" . ((viewer . "viewer1") + (print . "print1")))))))) + + ;; Only the existing entry has a test info field. + (let ((mailcap-mime-data + (list + (list "major" + (list "minor" + (cons 'viewer "viewer1") + (cons 'test "test1") + (cons 'print "print1")))))) + (mailcap-add-mailcap-entry "major" "minor" + (list (cons 'viewer "viewer2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor" . ((viewer . "viewer2"))) + ("minor" . ((viewer . "viewer1") + (test . "test1") + (print . "print1"))))))))) + +(ert-deftest mailcap-add-mailcap-entry-existing-with-test-same-viewer () + "Add a new entry for an already existing major/minor entry." + ;; Both the new and the existing entry have each a test info field. + (let ((mailcap-mime-data + (list + (list "major" + (list "minor" + (cons 'viewer "viewer") + (cons 'test "test1") + (cons 'print "print1")))))) + (mailcap-add-mailcap-entry "major" "minor" + (list (cons 'viewer "viewer") + (cons 'test "test2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor" . ((viewer . "viewer") + (test . "test2"))) + ("minor" . ((viewer . "viewer") + (test . "test1") + (print . "print1")))))))) + + ;; Only the new entry has a test field. + (let ((mailcap-mime-data + (list + (list "major" + (list "minor" + (cons 'viewer "viewer") + (cons 'print "print1")))))) + (mailcap-add-mailcap-entry "major" "minor" + (list (cons 'viewer "viewer") + (cons 'test "test2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor" . ((viewer . "viewer") + (test . "test2"))) + ("minor" . ((viewer . "viewer") + (print . "print1")))))))) + + ;; Only the existing entry has a test info field. + (let ((mailcap-mime-data + (list + (list "major" + (list "minor" + (cons 'viewer "viewer") + (cons 'test "test1") + (cons 'print "print1")))))) + (mailcap-add-mailcap-entry "major" "minor" + (list (cons 'viewer "viewer")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor" . ((viewer . "viewer"))) + ("minor" . ((viewer . "viewer") + (test . "test1") + (print . "print1"))))))))) + +(ert-deftest mailcap-add-mailcap-entry-existing-without-test-differing-vie= wer () + "Add a new entry for an already existing major/minor entry." + ;; Both entries do not have test fields. + (let ((mailcap-mime-data + (list + (list "major" + (list "minor" + (cons 'viewer "viewer1") + (cons 'print "print1")))))) + (mailcap-add-mailcap-entry "major" "minor" + (list (cons 'viewer "viewer2") + (cons 'compose "print2")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor" . ((viewer . "viewer2") + (compose . "print2"))) + ("minor" . ((viewer . "viewer1") + (print . "print1"))))))))) + +(ert-deftest mailcap-add-mailcap-entry-simple-merge () + "Merge entries without tests (no extra info fields in the existing entry= )." + (let ((mailcap-mime-data + (list + (list "major" + (list "minor" + (cons 'viewer "viewer")))))) + (mailcap-add-mailcap-entry "major" "minor" + (list (cons 'viewer "viewer")) + 'mailcap-mime-data) + (should (equal mailcap-mime-data + '(("major" + ("minor" . ((viewer . "viewer")))))))) + + (let ((mailcap-mime-data + (list + (list "major" + (list "minor" + (cons 'viewer "viewer")))))) + (mailcap-add-mailcap-entry "major" "minor" + (list (cons 'viewer "viewer") + (cons 'print "print")) + 'mailcap-mime-data) + + (should (equal mailcap-mime-data + '(("major" + ("minor" . ((viewer . "viewer") + (print . "print"))))))))) + +(ert-deftest mailcap-add-mailcap-entry-erroneous-merge () + "Merge entries without tests (extra info fields in existing entry). + +In its current implementation =E2=80=98mailcap-add-mailcap-entry=E2=80=99 = loses +extra fields of an entry already existing in =E2=80=98mailcap-mime-data=E2= =80=99. +This test does not actually verify a correct result; it merely +checks whether =E2=80=98mailcap-add-mailcap-entry=E2=80=99 behaviour is st= ill the +incorrect one. As such, it can be satisfied by any other result +than the expected and known wrong one, and its success does not +help to verify the correct addition and merging of an entry." + :expected-result :failed + + (let ((mailcap-mime-data + (list + (list "major" + (list "minor" + (cons 'viewer "viewer") + (cons 'print "print")))))) + (mailcap-add-mailcap-entry "major" "minor" + (list (cons 'viewer "viewer") + (cons 'edit "edit")) + 'mailcap-mime-data) + ;; Has the print field been lost? + (should-not (equal mailcap-mime-data + '(("major" + ("minor" . ((viewer . "viewer") + (edit . "edit"))))))))) + + ;;; mailcap-tests.el ends here --=20 2.36.1 --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Restructure-mailcap-add-mailcap-entry.patch Content-Transfer-Encoding: quoted-printable Content-Description: Patch to restructure =?utf-8?Q?=E2=80=98mailcap-add-mailcap-entry=E2=80=99?= >From a370e5f9397fbf5abe1e624acbc19ee009c5c7db Mon Sep 17 00:00:00 2001 From: Felix Dietrich Date: Sun, 6 Mar 2022 20:41:41 +0100 Subject: [PATCH] =3D?UTF-8?q?Restructure=3D20=3DE2=3D80=3D98mailcap-add-mai= lcap-entr?=3D =3D?UTF-8?q?y=3DE2=3D80=3D99?=3D MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/net/mailcap.el (mailcap-add-mailcap-entry): Restructure mailcap-add-mailcap-entry to improve readability. --- lisp/net/mailcap.el | 56 +++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index 469643dbca..1fa4130339 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -716,27 +716,43 @@ to supply to the test." result)))) =20 (defun mailcap-add-mailcap-entry (major minor info &optional storage) + "Add handler INFO for mime type MAJOR/MINOR to STORAGE. + +MAJOR and MINOR should be strings. MINOR is treated as a regexp +in later lookups, and, therefore, you may need to escape it +appropriately. + +The format of INFO is described in =E2=80=98mailcap-mime-data=E2=80=99. + +STORAGE should be a symbol refering to a variable. The value of +this variable should have the same format as =E2=80=98mailcap-mime-data=E2= =80=99. +STORAGE defaults to =E2=80=98mailcap--computed-mime-data=E2=80=99. + +None of this is enforced." (let* ((storage (or storage 'mailcap--computed-mime-data)) - (old-major (assoc major (symbol-value storage)))) - (if (null old-major) ; New major area - (set storage - (cons (cons major (list (cons minor info))) - (symbol-value storage))) - (let ((cur-minor (assoc minor old-major))) - (cond - ((or (null cur-minor) ; New minor area, or - (assq 'test info)) ; Has a test, insert at beginning - (setcdr old-major - (cons (cons minor info) (cdr old-major)))) - ((and (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)) - (t - (setcdr old-major - (setcdr old-major - (cons (cons minor info) (cdr old-major)))))))))) + (major-entry (assoc major (symbol-value storage))) + (new-minor-entry (cons minor info)) + minor-entry) + (cond + ((null major-entry) + ;; Add a new major entry containing the new minor entry. + (setf major-entry (list major new-minor-entry)) + (push major-entry (symbol-value storage))) + ((and (setf minor-entry (assoc minor major-entry)) + (not (assq 'test info)) + (not (assq 'test minor-entry)) + (equal (assq 'viewer info) + (assq 'viewer minor-entry))) + ;; Replace a previous MINOR entry if it and the entry to be + ;; added both do *not* have a =E2=80=98test=E2=80=99 associated in t= heir info + ;; alist and both use the same =E2=80=98viewer=E2=80=99 command. Th= is ignores + ;; other fields in the previous entry=CA=BCs info alist: they will be + ;; lost when the info alist in the cdr of the previous entry is + ;; replaced with the new INFO alist. + (setf (cdr minor-entry) info)) + (t + ;; Add the new minor entry to the existing major entry. + (push new-minor-entry (cdr major-entry)))))) =20 (defun mailcap-add (type viewer &optional test) "Add VIEWER as a handler for TYPE. --=20 2.36.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 02 06:09:47 2022 Received: (at 57532) by debbugs.gnu.org; 2 Sep 2022 10:09:47 +0000 Received: from localhost ([127.0.0.1]:44913 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU3cQ-0004u9-OJ for submit@debbugs.gnu.org; Fri, 02 Sep 2022 06:09:46 -0400 Received: from quimby.gnus.org ([95.216.78.240]:33726) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU3cP-0004tr-0l for 57532@debbugs.gnu.org; Fri, 02 Sep 2022 06:09:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :Date:References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Y/WPfRznSyO4k6+TpN/0yL1/qORLHBunUuE489udWIE=; b=Fm7Gb7/Cog/d2CcT1yUN1skwlq J3NJHSxis6VcHseRSq8pUosMTLZ0s7sfDzwil88gs8OL3gE2TyposejFBdsoePVlbgzSeqy0raI9k ByGWEtL6Tm4INbz+pLF07tG2IOc1T4lRaC5PPMJq6sAYrTrDAjKC8WivYCP8kyOkLsQE=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oU3cF-0004QL-VX; Fri, 02 Sep 2022 12:09:38 +0200 From: Lars Ingebrigtsen To: Felix Dietrich Subject: Re: bug#57532: Restructure mailcap-add-mailcap-entry to improve readability In-Reply-To: <878rn2rd22.fsf@sperrhaken.name> (Felix Dietrich's message of "Thu, 01 Sep 2022 23:37:41 +0200") References: <878rn2rd22.fsf@sperrhaken.name> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACVBMVEWQoMNWapj///9v UaI7AAAAAWJLR0QCZgt8ZAAAAAlwSFlzAAAASAAAAEgARslrPgAAAAd0SU1FB+YJAgoJGRPubpoA AAEKSURBVCjPTVExrsUwCAOp7P1SuA8ZuhMJ7n+Vb0jbV5QhDsGxHSLUQZ/6Ahvfzhdw/vZnZsa9 n5FVxlefaAH6EycZ3p09TaGJno1VBzjW6nBQHg0wzLynN/cgnR+Qp2DbZEpBAM5bgBedsfstCBx8 POqkCPwVLp7LlN6bLmm3JUh4LQ4Gx0PBjmOTnRPH4TSvblyEedoG2UEGSUlGMy1yksDpyTYc10hm 0pZRD/Yq/uxosF1BFLc5yYOmbQDSnLkK/NHa6WzFydebLqjRkwYTQsuLQ28Z0qsihHZenfvqZ8TI 6uNCFnkgXmSbljHLUr/DFfxZ/rq8/efzJTygLXQDDX2upSo+aeWv/gEXYlaaEPm6RQAAAFplWElm TU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAEA AAITAAMAAAABAAEAAAAAAAAAAABIAAAAAQAAAEgAAAABlIHJLQAAACV0RVh0ZGF0ZTpjcmVhdGUA MjAyMi0wOS0wMlQxMDowOToyNCswMDowMKxf/h4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDkt MDJUMTA6MDk6MjQrMDA6MDDdAkaiAAAAF3RFWHRleGlmOllDYkNyUG9zaXRpb25pbmcAMawPgGMA AAAASUVORK5CYII= X-Now-Playing: Satomimagae's _KEM_: "Fumi (KEM Version)" Date: Fri, 02 Sep 2022 12:09:35 +0200 Message-ID: <87tu5qxf34.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Felix Dietrich writes: > ‘mailcap-add-mailcap-entry’ is written in a way that makes it hard to > follow. My patch aims to improve its readability. In order to show > that my modification retains the original functionali [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 57532 Cc: 57532@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Felix Dietrich writes: > =E2=80=98mailcap-add-mailcap-entry=E2=80=99 is written in a way that make= s it hard to > follow. My patch aims to improve its readability. In order to show > that my modification retains the original functionality, another Patch > adds ERT test cases for this function. The new version also shows > clearer an issue with the current implementation that causes some > mailcap entries to be forgotten; this is mentioned in a comment. A > docstring for the function is added as well. Thanks; pushed to Emacs 29. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 02 06:09:56 2022 Received: (at control) by debbugs.gnu.org; 2 Sep 2022 10:09:56 +0000 Received: from localhost ([127.0.0.1]:44916 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU3ca-0004uV-16 for submit@debbugs.gnu.org; Fri, 02 Sep 2022 06:09:56 -0400 Received: from quimby.gnus.org ([95.216.78.240]:33740) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU3cX-0004uI-Sd for control@debbugs.gnu.org; Fri, 02 Sep 2022 06:09:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CwoQPEj86bbsM2uJZ2ZB2RJEvwxsmnU8xxsbVCsT8jE=; b=Z9aQMG8pYsVuVvmDOmrkyPYiFt oGlAT33SAh+9ZDzCnZSsEmGVSyxWW1WbP5Gd542HhxDKf9oBAH4ZCMSe6lvBvyOyeNYBp6BOhpM3r FsafBtrD5M4eQ6abmsFwtgUs53HTJ3J7AcPYKiR49tO/Vl8Q7J9u5oFCGn5WLKvkQP7w=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oU3cP-0004QT-Vn for control@debbugs.gnu.org; Fri, 02 Sep 2022 12:09:48 +0200 Date: Fri, 02 Sep 2022 12:09:45 +0200 Message-Id: <87pmgexf2u.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #57532 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 57532 29.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 57532 29.1 quit From unknown Fri Aug 15 04:07:34 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 30 Sep 2022 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator