From d24ad504fcc342725febc187e17d6b69cc527b6b Mon Sep 17 00:00:00 2001 From: Stephen Gildea Date: Thu, 25 Nov 2021 10:12:30 -0800 Subject: [PATCH] MH-E: support Mailutils "folders +/" * lisp/mh-e/mh-utils.el (mh-sub-folders-parse): Support Mailutils style of "folders +/" output. * test/lisp/mh-e/mh-utils.el: Test "folders +/" with GNU Mailutils 3.13.91 and later. --- lisp/mh-e/mh-utils.el | 7 +++++++ test/lisp/mh-e/mh-utils-tests.el | 11 +++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lisp/mh-e/mh-utils.el b/lisp/mh-e/mh-utils.el index ad23bd19118..b75025d6a4d 100644 --- a/lisp/mh-e/mh-utils.el +++ b/lisp/mh-e/mh-utils.el @@ -592,10 +592,14 @@ This function is a testable helper of `mh-sub-folders-actual'." (cl-incf start-pos)) (let* ((name (buffer-substring start-pos has-pos)) (first-char (aref name 0)) + (second-char (and (length> name 1) (aref name 1))) (last-char (aref name (1- (length name))))) (unless (member first-char '(?. ?# ?,)) (when (and (equal last-char ?+) (equal name current-folder)) (setq name (substring name 0 (1- (length name))))) + ;; nmh outputs double slash in root folder, e.g., "//tmp" + (when (and (equal first-char ?/) (equal second-char ?/)) + (setq name (substring name 1))) (push (cons name (search-forward "(others)" (line-end-position) t)) @@ -605,6 +609,9 @@ This function is a testable helper of `mh-sub-folders-actual'." (when (stringp folder) (setq results (cdr results)) (let ((folder-name-len (length (format "%s/" (substring folder 1))))) + (when (equal "+/" folder) + ;; folder "+/" includes a trailing slash + (cl-decf folder-name-len)) (setq results (mapcar (lambda (f) (cons (substring (car f) folder-name-len) (cdr f))) diff --git a/test/lisp/mh-e/mh-utils-tests.el b/test/lisp/mh-e/mh-utils-tests.el index 83949204a6e..f282a0b08f3 100644 --- a/test/lisp/mh-e/mh-utils-tests.el +++ b/test/lisp/mh-e/mh-utils-tests.el @@ -121,10 +121,12 @@ "Test `mh-sub-folders-parse' with root folder." (with-temp-buffer (insert "/+ has no messages.\n") + (insert "/ has no messages.\n") (insert "//nmh-style has no messages.\n") + (insert "/mu-style has no messages.\n") (should (equal (mh-sub-folders-parse "+/" "inbox+") - '(("nmh-style")))))) + '(("") ("nmh-style") ("mu-style")))))) ;; Folder names that are used by the following tests. @@ -259,8 +261,8 @@ The tests use this method if no configured MH variant is found." "/abso-folder/food has no messages.")) (("folders" "-noheader" "-norecurse" "-nototal" "+/") . ("/+ has no messages ; (others)." - "//abso-folder has no messages ; (others)." - "//tmp has no messages ; (others).")) + "/abso-folder has no messages ; (others)." + "/tmp has no messages ; (others).")) )) (arglist (cons (file-name-base program) args))) (let ((response-list-cons (assoc arglist argument-responses))) @@ -358,7 +360,8 @@ if `mh-test-utils-debug-mocks' is non-nil." Mailutils 3.5, 3.7, and 3.13 are known not to." (cond ((not (stringp variant))) ;our mock handles it ((string-search "GNU Mailutils" variant) - nil) + (let ((mu-version (string-remove-prefix "GNU Mailutils " variant))) + (version<= "3.13.91" mu-version))) (t))) ;no other known failures -- 2.39.2