diff options
| author | Bill Wohler | 2006-01-14 02:05:23 +0000 |
|---|---|---|
| committer | Bill Wohler | 2006-01-14 02:05:23 +0000 |
| commit | 11db987fa8210ea303924adf4c362586fa6163d2 (patch) | |
| tree | 3530d5fc3eb9b941749081e00a4d6c3de97cb824 | |
| parent | 9f7f49fbb6ba5e70c5396dd58b0a3dcaf5ab97c4 (diff) | |
| download | emacs-11db987fa8210ea303924adf4c362586fa6163d2.tar.gz emacs-11db987fa8210ea303924adf4c362586fa6163d2.zip | |
* 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.
| -rw-r--r-- | lisp/mh-e/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/mh-e/mh-search.el | 45 | ||||
| -rw-r--r-- | lisp/mh-e/mh-utils.el | 40 |
3 files changed, 78 insertions, 20 deletions
diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog index 3f8c09ea6fe..d7293a94546 100644 --- a/lisp/mh-e/ChangeLog +++ b/lisp/mh-e/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2006-01-13 Bill Wohler <wohler@newt.com> | ||
| 2 | |||
| 3 | * mh-search.el (mh-index-next-result-function): Add format to | ||
| 4 | docstring. | ||
| 5 | (mh-mairix-next-result): Use nil instead of () which doesn't stand | ||
| 6 | out as well. | ||
| 7 | (mh-pick-execute-search): Operate across all folders if no folder | ||
| 8 | given and recurse folder(s). | ||
| 9 | (mh-pick-next-result): Handle new output. | ||
| 10 | |||
| 11 | * mh-utils.el: (mh-collect-folder-names): Fix docstring. | ||
| 12 | (mh-children-p, mh-folder-list): New functions. | ||
| 13 | |||
| 1 | 2006-01-12 Bill Wohler <wohler@newt.com> | 14 | 2006-01-12 Bill Wohler <wohler@newt.com> |
| 2 | 15 | ||
| 3 | * mh-search.el: New file containing contents of mh-index.el and | 16 | * mh-search.el: New file containing contents of mh-index.el and |
diff --git a/lisp/mh-e/mh-search.el b/lisp/mh-e/mh-search.el index fc0ccc446d3..8eb2a370e3e 100644 --- a/lisp/mh-e/mh-search.el +++ b/lisp/mh-e/mh-search.el | |||
| @@ -58,7 +58,9 @@ | |||
| 58 | "Function which executes the search program.") | 58 | "Function which executes the search program.") |
| 59 | 59 | ||
| 60 | (defvar mh-index-next-result-function nil | 60 | (defvar mh-index-next-result-function nil |
| 61 | "Function to parse the next line of output.") | 61 | "Function to parse the next line of output. |
| 62 | Expected to return a list of three strings: name of the folder, | ||
| 63 | message number, and optionally the match.") | ||
| 62 | 64 | ||
| 63 | (defvar mh-index-regexp-builder nil | 65 | (defvar mh-index-regexp-builder nil |
| 64 | "Function used to construct search regexp.") | 66 | "Function used to construct search regexp.") |
| @@ -1180,7 +1182,7 @@ SEARCH-REGEXP-LIST is used to search." | |||
| 1180 | (point) (1- msg-start))) | 1182 | (point) (1- msg-start))) |
| 1181 | (car (read-from-string | 1183 | (car (read-from-string |
| 1182 | (buffer-substring-no-properties msg-start end))) | 1184 | (buffer-substring-no-properties msg-start end))) |
| 1183 | ()))) | 1185 | nil))) |
| 1184 | (forward-line))) | 1186 | (forward-line))) |
| 1185 | 1187 | ||
| 1186 | (defun mh-mairix-regexp-builder (regexp-list) | 1188 | (defun mh-mairix-regexp-builder (regexp-list) |
| @@ -1330,31 +1332,36 @@ There are no semantics associated with the search criteria--they | |||
| 1330 | are simply treated as strings. Case is ignored when all lowercase | 1332 | are simply treated as strings. Case is ignored when all lowercase |
| 1331 | is used, and regular expressions (a la \"ed\") are available. | 1333 | is used, and regular expressions (a la \"ed\") are available. |
| 1332 | 1334 | ||
| 1333 | Unlike the other index search programs, you must specify a | ||
| 1334 | folder. In addition, this command does not descend into any | ||
| 1335 | sub-folders that may be present. | ||
| 1336 | |||
| 1337 | In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP | 1335 | In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP |
| 1338 | is used to search." | 1336 | is used to search." |
| 1339 | (set-buffer (get-buffer-create mh-temp-index-buffer)) | 1337 | (set-buffer (get-buffer-create mh-temp-index-buffer)) |
| 1340 | (erase-buffer) | 1338 | (erase-buffer) |
| 1341 | (setq mh-index-pick-folder | 1339 | (let ((folders |
| 1342 | (concat "+" (substring folder-path (length mh-user-path)))) | 1340 | (mh-folder-list (substring folder-path (length mh-user-path))))) |
| 1343 | (apply #'call-process (expand-file-name "pick" mh-progs) nil '(t nil) nil | 1341 | (loop for folder in folders do |
| 1344 | mh-index-pick-folder "-list" search-regexp) | 1342 | (setq folder (concat "+" folder)) |
| 1343 | (insert folder "\n") | ||
| 1344 | (apply #'call-process (expand-file-name "pick" mh-progs) | ||
| 1345 | nil '(t nil) nil folder "-list" search-regexp))) | ||
| 1345 | (goto-char (point-min))) | 1346 | (goto-char (point-min))) |
| 1346 | 1347 | ||
| 1347 | (defun mh-pick-next-result () | 1348 | (defun mh-pick-next-result () |
| 1348 | "Return the next pick search result." | 1349 | "Return the next pick search result." |
| 1349 | (prog1 (block nil | 1350 | (prog1 |
| 1350 | (when (eobp) (return nil)) | 1351 | (block nil |
| 1351 | (unless (re-search-forward "^[1-9][0-9]*$" (line-end-position) t) | 1352 | (when (eobp) (return nil)) |
| 1352 | (return 'error)) | 1353 | (when (search-forward-regexp "^\+" (line-end-position) t) |
| 1353 | (list mh-index-pick-folder | 1354 | (setq mh-index-pick-folder |
| 1354 | (car (read-from-string (buffer-substring-no-properties | 1355 | (buffer-substring-no-properties (line-beginning-position) |
| 1355 | (line-beginning-position) | 1356 | (line-end-position))) |
| 1356 | (line-end-position)))) | 1357 | (return 'error)) |
| 1357 | nil)) | 1358 | (unless (search-forward-regexp "^[1-9][0-9]*$" (line-end-position) t) |
| 1359 | (return 'error)) | ||
| 1360 | (list mh-index-pick-folder | ||
| 1361 | (string-to-number | ||
| 1362 | (buffer-substring-no-properties (line-beginning-position) | ||
| 1363 | (line-end-position))) | ||
| 1364 | nil)) | ||
| 1358 | (forward-line))) | 1365 | (forward-line))) |
| 1359 | 1366 | ||
| 1360 | ;; All implementations of pick have special options -cc, -date, -from and | 1367 | ;; All implementations of pick have special options -cc, -date, -from and |
diff --git a/lisp/mh-e/mh-utils.el b/lisp/mh-e/mh-utils.el index 719baed228a..63ba0def8ff 100644 --- a/lisp/mh-e/mh-utils.el +++ b/lisp/mh-e/mh-utils.el | |||
| @@ -2059,7 +2059,7 @@ folder buffer are not updated." | |||
| 2059 | 2059 | ||
| 2060 | ;; Initialize mh-sub-folders-cache... | 2060 | ;; Initialize mh-sub-folders-cache... |
| 2061 | (defun mh-collect-folder-names () | 2061 | (defun mh-collect-folder-names () |
| 2062 | "Collect folder names by running \"flists\"." | 2062 | "Collect folder names by running \"folders\"." |
| 2063 | (unless mh-flists-process | 2063 | (unless mh-flists-process |
| 2064 | (setq mh-flists-process | 2064 | (setq mh-flists-process |
| 2065 | (mh-exec-cmd-daemon "folders" 'mh-collect-folder-names-filter | 2065 | (mh-exec-cmd-daemon "folders" 'mh-collect-folder-names-filter |
| @@ -2158,6 +2158,44 @@ removed." | |||
| 2158 | ((not (equal (aref folder 0) ?+)) (setq folder (concat "+" folder))))) | 2158 | ((not (equal (aref folder 0) ?+)) (setq folder (concat "+" folder))))) |
| 2159 | folder) | 2159 | folder) |
| 2160 | 2160 | ||
| 2161 | (defmacro mh-children-p (folder) | ||
| 2162 | "Return t if FOLDER from sub-folders cache has children. | ||
| 2163 | The car of folder is the name, and the cdr is either t or some | ||
| 2164 | sort of count that I do not understand. It's too small to be the | ||
| 2165 | number of messages in the sub-folders and too large to be the | ||
| 2166 | number of sub-folders. XXX" | ||
| 2167 | `(if (cdr ,folder) | ||
| 2168 | t | ||
| 2169 | nil)) | ||
| 2170 | |||
| 2171 | (defun mh-folder-list (folder) | ||
| 2172 | "Return FOLDER and its descendents. | ||
| 2173 | Returns a list of strings. For example, | ||
| 2174 | |||
| 2175 | '(\"inbox\" \"lists\" \"lists/mh-e\"). | ||
| 2176 | |||
| 2177 | If folder is nil, then all folders are considered. Respects the | ||
| 2178 | value of `mh-recursive-folders-flag'. If this flag is nil, and | ||
| 2179 | the sub-folders have not been explicitly viewed, then they will | ||
| 2180 | not be returned." | ||
| 2181 | (let ((folder-list)) | ||
| 2182 | ;; Normalize folder. Strip leading +. Add trailing slash. If no | ||
| 2183 | ;; folder is specified, ensure it is nil to ensure we get the | ||
| 2184 | ;; top-level folders; otherwise mh-sub-folders returns all the | ||
| 2185 | ;; files in / if given an empty string or +. | ||
| 2186 | (when folder | ||
| 2187 | (setq folder (replace-regexp-in-string "^\+" "" folder)) | ||
| 2188 | (setq folder (replace-regexp-in-string "/*$" "/" folder)) | ||
| 2189 | (if (equal folder "") | ||
| 2190 | (setq folder nil))) | ||
| 2191 | (loop for f in (mh-sub-folders folder) do | ||
| 2192 | (setq folder-list (append folder-list (list (concat folder (car f))))) | ||
| 2193 | (if (mh-children-p f) | ||
| 2194 | (setq folder-list | ||
| 2195 | (append folder-list | ||
| 2196 | (mh-folder-list (concat folder (car f))))))) | ||
| 2197 | folder-list)) | ||
| 2198 | |||
| 2161 | (defun mh-sub-folders (folder &optional add-trailing-slash-flag) | 2199 | (defun mh-sub-folders (folder &optional add-trailing-slash-flag) |
| 2162 | "Find the subfolders of FOLDER. | 2200 | "Find the subfolders of FOLDER. |
| 2163 | The function avoids running folders unnecessarily by caching the | 2201 | The function avoids running folders unnecessarily by caching the |