emacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-commit] emacs/lisp/mh-e mh-utils.el mh-search.el ChangeLog


From: Bill Wohler
Subject: [Emacs-commit] emacs/lisp/mh-e mh-utils.el mh-search.el ChangeLog
Date: Sat, 14 Jan 2006 02:05:23 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Branch:         
Changes by:     Bill Wohler <address@hidden>    06/01/14 02:05:23

Modified files:
        lisp/mh-e      : mh-utils.el mh-search.el ChangeLog 

Log message:
        * mh-search.el (mh-index-next-result-function): Add format to
        docstring.
        (mh-mairix-next-result): Use nil instead of () which doesn't stand out
        as well.
        (mh-pick-execute-search): Operate across all folders if no folder
        given and recurse folder(s).
        (mh-pick-next-result): Handle new output.
        
        * mh-utils.el: (mh-collect-folder-names): Fix docstring.
        (mh-children-p, mh-folder-list): New functions.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/emacs/lisp/mh-e/mh-utils.el.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/emacs/emacs/lisp/mh-e/mh-search.el.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/emacs/emacs/lisp/mh-e/ChangeLog.diff?tr1=1.113&tr2=1.114&r1=text&r2=text

Patches:
Index: emacs/lisp/mh-e/ChangeLog
diff -u emacs/lisp/mh-e/ChangeLog:1.113 emacs/lisp/mh-e/ChangeLog:1.114
--- emacs/lisp/mh-e/ChangeLog:1.113     Fri Jan 13 06:40:14 2006
+++ emacs/lisp/mh-e/ChangeLog   Sat Jan 14 02:05:23 2006
@@ -1,3 +1,16 @@
+2006-01-13  Bill Wohler  <address@hidden>
+
+       * mh-search.el (mh-index-next-result-function): Add format to
+       docstring.
+       (mh-mairix-next-result): Use nil instead of () which doesn't stand
+       out as well.
+       (mh-pick-execute-search): Operate across all folders if no folder
+       given and recurse folder(s).
+       (mh-pick-next-result): Handle new output.
+
+       * mh-utils.el: (mh-collect-folder-names): Fix docstring.
+       (mh-children-p, mh-folder-list): New functions. 
+
 2006-01-12  Bill Wohler  <address@hidden>
 
        * mh-search.el: New file containing contents of mh-index.el and
Index: emacs/lisp/mh-e/mh-search.el
diff -u emacs/lisp/mh-e/mh-search.el:1.1 emacs/lisp/mh-e/mh-search.el:1.2
--- emacs/lisp/mh-e/mh-search.el:1.1    Fri Jan 13 06:40:13 2006
+++ emacs/lisp/mh-e/mh-search.el        Sat Jan 14 02:05:23 2006
@@ -58,7 +58,9 @@
   "Function which executes the search program.")
 
 (defvar mh-index-next-result-function nil
-  "Function to parse the next line of output.")
+  "Function to parse the next line of output.
+Expected to return a list of three strings: name of the folder,
+message number, and optionally the match.")
 
 (defvar mh-index-regexp-builder nil
   "Function used to construct search regexp.")
@@ -1180,7 +1182,7 @@
                                (point) (1- msg-start)))
                 (car (read-from-string
                       (buffer-substring-no-properties msg-start end)))
-                ())))
+                nil)))
     (forward-line)))
 
 (defun mh-mairix-regexp-builder (regexp-list)
@@ -1330,31 +1332,36 @@
 are simply treated as strings. Case is ignored when all lowercase
 is used, and regular expressions (a la \"ed\") are available.
 
-Unlike the other index search programs, you must specify a
-folder. In addition, this command does not descend into any
-sub-folders that may be present.
-
 In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP
 is used to search."
   (set-buffer (get-buffer-create mh-temp-index-buffer))
   (erase-buffer)
-  (setq mh-index-pick-folder
-        (concat "+" (substring folder-path (length mh-user-path))))
-  (apply #'call-process (expand-file-name "pick" mh-progs) nil '(t nil) nil
-         mh-index-pick-folder "-list" search-regexp)
+  (let ((folders
+         (mh-folder-list (substring folder-path (length mh-user-path)))))
+    (loop for folder in folders do
+          (setq folder (concat "+" folder))
+          (insert folder "\n")
+          (apply #'call-process (expand-file-name "pick" mh-progs)
+                 nil '(t nil) nil folder "-list" search-regexp)))
   (goto-char (point-min)))
 
 (defun mh-pick-next-result ()
   "Return the next pick search result."
-  (prog1 (block nil
-           (when (eobp) (return nil))
-           (unless (re-search-forward "^[1-9][0-9]*$" (line-end-position) t)
-             (return 'error))
-           (list mh-index-pick-folder
-                 (car (read-from-string (buffer-substring-no-properties
-                                         (line-beginning-position)
-                                         (line-end-position))))
-                 nil))
+  (prog1
+      (block nil
+        (when (eobp) (return nil))
+        (when (search-forward-regexp "^\+" (line-end-position) t)
+          (setq mh-index-pick-folder
+                (buffer-substring-no-properties (line-beginning-position)
+                                                (line-end-position)))
+          (return 'error))
+        (unless (search-forward-regexp "^[1-9][0-9]*$" (line-end-position) t)
+          (return 'error))
+        (list mh-index-pick-folder
+              (string-to-number
+               (buffer-substring-no-properties (line-beginning-position)
+                                               (line-end-position)))
+              nil))
     (forward-line)))
 
 ;; All implementations of pick have special options -cc, -date, -from and
Index: emacs/lisp/mh-e/mh-utils.el
diff -u emacs/lisp/mh-e/mh-utils.el:1.39 emacs/lisp/mh-e/mh-utils.el:1.40
--- emacs/lisp/mh-e/mh-utils.el:1.39    Fri Jan 13 06:40:13 2006
+++ emacs/lisp/mh-e/mh-utils.el Sat Jan 14 02:05:23 2006
@@ -2059,7 +2059,7 @@
 
 ;; Initialize mh-sub-folders-cache...
 (defun mh-collect-folder-names ()
-  "Collect folder names by running \"flists\"."
+  "Collect folder names by running \"folders\"."
   (unless mh-flists-process
     (setq mh-flists-process
           (mh-exec-cmd-daemon "folders" 'mh-collect-folder-names-filter
@@ -2158,6 +2158,44 @@
           ((not (equal (aref folder 0) ?+)) (setq folder (concat "+" 
folder)))))
   folder)
 
+(defmacro mh-children-p (folder)
+  "Return t if FOLDER from sub-folders cache has children.
+The car of folder is the name, and the cdr is either t or some
+sort of count that I do not understand. It's too small to be the
+number of messages in the sub-folders and too large to be the
+number of sub-folders. XXX"
+  `(if (cdr ,folder)
+       t
+     nil))
+
+(defun mh-folder-list (folder)
+  "Return FOLDER and its descendents.
+Returns a list of strings. For example,
+
+  '(\"inbox\" \"lists\" \"lists/mh-e\").
+
+If folder is nil, then all folders are considered. Respects the
+value of `mh-recursive-folders-flag'. If this flag is nil, and
+the sub-folders have not been explicitly viewed, then they will
+not be returned."
+  (let ((folder-list))
+    ;; Normalize folder. Strip leading +. Add trailing slash. If no
+    ;; folder is specified, ensure it is nil to ensure we get the
+    ;; top-level folders; otherwise mh-sub-folders returns all the
+    ;; files in / if given an empty string or +.
+    (when folder
+      (setq folder (replace-regexp-in-string "^\+" "" folder))
+      (setq folder (replace-regexp-in-string "/*$" "/" folder))
+      (if (equal folder "")
+        (setq folder nil)))
+    (loop for f in (mh-sub-folders folder) do
+          (setq folder-list (append folder-list (list (concat folder (car 
f)))))
+          (if (mh-children-p f)
+              (setq folder-list
+                    (append folder-list
+                            (mh-folder-list (concat folder (car f)))))))
+    folder-list))
+
 (defun mh-sub-folders (folder &optional add-trailing-slash-flag)
   "Find the subfolders of FOLDER.
 The function avoids running folders unnecessarily by caching the




reply via email to

[Prev in Thread] Current Thread [Next in Thread]