Function: mh-sub-folders

mh-sub-folders is an autoloaded and byte-compiled function defined in mh-utils.el.gz.

Signature

(mh-sub-folders FOLDER &optional ADD-TRAILING-SLASH-FLAG)

Documentation

Find the subfolders of FOLDER.

The function avoids running folders unnecessarily by caching the results of the actual folders call.

If optional argument ADD-TRAILING-SLASH-FLAG is non-nil then a slash is added to each of the sub-folder names that may have nested folders within them.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-utils.el.gz
;;;###mh-autoload
(defun mh-sub-folders (folder &optional add-trailing-slash-flag)
  "Find the subfolders of FOLDER.
The function avoids running folders unnecessarily by caching the
results of the actual folders call.

If optional argument ADD-TRAILING-SLASH-FLAG is non-nil then a
slash is added to each of the sub-folder names that may have
nested folders within them."
  ;; In most cases we want to remove a trailing slash.  We keep the
  ;; slash for "+/", because it refers to folders in the system root
  ;; directory, whereas "+" refers to the user's top-level folders.
  (let* ((folder (mh-normalize-folder-name folder nil
                                           (string= folder "+/")
                                           t))
         (match (gethash folder mh-sub-folders-cache 'no-result))
         (sub-folders (cond ((eq match 'no-result)
                             (setf (gethash folder mh-sub-folders-cache)
                                   (mh-sub-folders-actual folder)))
                            (t match))))
    (if add-trailing-slash-flag
        (mapcar (lambda (x)
                  (if (cdr x) (cons (concat (car x) "/") (cdr x)) x))
                sub-folders)
      sub-folders)))