Mercurial > emacs
comparison lisp/mh-e/mh-search.el @ 68188:dcf226991252
* 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.
author | Bill Wohler <wohler@newt.com> |
---|---|
date | Sat, 14 Jan 2006 02:05:23 +0000 |
parents | 3b7532a82079 |
children | 2cfa649fa39d |
comparison
equal
deleted
inserted
replaced
68187:fc9311c473a3 | 68188:dcf226991252 |
---|---|
56 | 56 |
57 (defvar mh-index-execute-search-function nil | 57 (defvar mh-index-execute-search-function nil |
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.") |
65 | 67 |
66 (defvar mh-index-folder "+mhe-index" | 68 (defvar mh-index-folder "+mhe-index" |
1178 (return 'error)) | 1180 (return 'error)) |
1179 (list (format "+%s" (buffer-substring-no-properties | 1181 (list (format "+%s" (buffer-substring-no-properties |
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) |
1187 "Generate query for mairix. | 1189 "Generate query for mairix. |
1188 REGEXP-LIST is an alist of fields and values." | 1190 REGEXP-LIST is an alist of fields and values." |
1328 | 1330 |
1329 There are no semantics associated with the search criteria--they | 1331 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 |
1361 ;; -subject that allow to search for corresponding components. Any other | 1368 ;; -subject that allow to search for corresponding components. Any other |
1362 ;; component is searched using option --COMPNAME, for example: `pick | 1369 ;; component is searched using option --COMPNAME, for example: `pick |