annotate lisp/mh-e/mh-search.el @ 68163:3b7532a82079

* mh-search.el: New file containing contents of mh-index.el and mh-pick.el. C-c C-c launches your mh-index-program; C-c C-p runs pick. Pick no longer sets the "search" sequence. Instead, it brings up a folder view that we're accustomed to. (closes SF #829207). (mh-index-search): Rename to mh-search. (mh-pick-menu): Rename menu from Pick to Search. Rename Execute the Search to Perform Search and call mh-do-search. Add Search with Pick menu item. (mh-do-search): Delete. (mh-search-mode): Rename from mh-pick-mode. (MH-Search): Rename mode from MH-Pick. (mh-search-mode-map): Rename from mh-pick-mode-map. (mh-search-mode-help-messages): Rename from mh-pick-mode-help-messages. (mh-index-choose): Don't reuse the last value of mh-indexer; when mh-pick-do-search sets it to 'pick, we don't necessarily want to stay with that choice! * mh-index.el: mh-pick.el: Merge into mh-search.el and delete. * mh-customize.el (mh-index-program): Change mh-index-search to mh-search in docstring. (mh-tool-bar-search-function): Change default from mh-search-folder to mh-search. Remove mh-search-folder as choice and rename mh-index-search choice to mh-search. Fix docstring. (mh-pick-mode-hook): Rename to mh-search-mode-hook and change mh-search-folder to mh-search in docstring. * mh-e.el (mh-folder-folder-menu): Delete Search a Folder. Change Indexed Search to Search. Use mh-search instead of mh-index-search. (mh-folder-map): Delete i (mh-index-search) keybinding. Change s from mh-show-search-folder to mh-search. * mh-seq.el (mh-put-msg-in-seq): Fix docstring now that mh-search-folder no longer creates the search sequence. * mh-utils.el (mh-show-search-folder): Delete. (mh-show-folder-map): Delete i (mh-index-search) keybinding. Change s from mh-show-search-folder to mh-search. (mh-show-folder-menu): Delete Search a Folder. Change Indexed Search to Search. Use mh-search instead of mh-index-search. (mh-index-max-cmdline-args, mh-xargs, mh-quote-for-shell): Move here from deleted mh-index.el.
author Bill Wohler <wohler@newt.com>
date Fri, 13 Jan 2006 06:40:14 +0000
parents
children dcf226991252
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68163
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1 ;;; mh-search -- MH-E search
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
2
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
3 ;; Copyright (C) 1993, 1995,
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
4 ;; 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
5
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
6 ;; Author: Indexed search by Satyaki Das <satyaki@theforce.stanford.edu>
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
7 ;; Maintainer: Bill Wohler <wohler@newt.com>
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
8 ;; Keywords: mail
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
9 ;; See: mh-e.el
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
10
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
12
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
16 ;; any later version.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
17
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
21 ;; GNU General Public License for more details.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
22
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
26 ;; Boston, MA 02110-1301, USA.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
27
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
28 ;;; Commentary:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
29
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
30 ;; (1) The following search engines are supported:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
31 ;; swish++
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
32 ;; swish-e
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
33 ;; mairix
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
34 ;; namazu
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
35 ;; pick
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
36 ;; grep
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
37 ;;
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
38 ;; (2) To use this package, you first have to build an index. Please
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
39 ;; read the documentation for `mh-search' to get started. That
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
40 ;; documentation will direct you to the specific instructions for
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
41 ;; your particular indexer.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
42
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
43 ;;; Change Log:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
44
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
45 ;;; Code:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
46
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
47 (eval-when-compile (require 'mh-acros))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
48 (mh-require-cl)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
49
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
50 (require 'gnus-util)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
51 (require 'mh-buffers)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
52 (require 'mh-e)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
53
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
54 (defvar mh-indexer nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
55 "Cached value of chosen index program.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
56
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
57 (defvar mh-index-execute-search-function nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
58 "Function which executes the search program.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
59
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
60 (defvar mh-index-next-result-function nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
61 "Function to parse the next line of output.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
62
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
63 (defvar mh-index-regexp-builder nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
64 "Function used to construct search regexp.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
65
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
66 (defvar mh-index-folder "+mhe-index"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
67 "Folder that contains the folders resulting from the index searches.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
68
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
69 (defvar mh-flists-results-folder "sequence"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
70 "Subfolder for `mh-index-folder' where flists output is placed.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
71
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
72 (defvar mh-flists-sequence)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
73
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
74 (defvar mh-flists-called-flag nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
75
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
76
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
77
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
78 ;;; MH-Search mode
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
79
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
80 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
81 (defun* mh-search (redo-search-flag folder search-regexp
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
82 &optional window-config)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
83 "Search your MH mail.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
84
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
85 With this command, you can search for messages to or from a
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
86 particular person or about a particular subject. In fact, you can
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
87 also search for messages containing selected strings in any
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
88 arbitrary header field or any string found within the messages.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
89
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
90 Use a prefix argument REDO-SEARCH-FLAG to repeat the last search.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
91
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
92 You are prompted for the FOLDER to search. This can be \"all\" to
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
93 search all folders. For most search methods, the search works
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
94 recursively on the listed folder.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
95
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
96 Next, an MH-Search buffer appears where you can enter search
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
97 criteria.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
98
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
99 From:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
100 To:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
101 Cc:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
102 Date:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
103 Subject:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
104 --------
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
105
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
106 Edit this template by entering your search criteria in an
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
107 appropriate header field that is already there, or create a new
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
108 field yourself. If the string you're looking for could be
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
109 anywhere in a message, then place the string underneath the row
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
110 of dashes.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
111
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
112 It is all right to specify several search criteria. What happens
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
113 then is that a logical _and_ of the various fields is performed.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
114 If you prefer a logical _or_ operation, run \\[mh-search]
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
115 multiple times.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
116
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
117 As an example, let's say that we want to find messages from
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
118 Ginnean about horseback riding in the Kosciusko National
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
119 Park (Australia) during January, 1994. Normally we would start
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
120 with a broad search and narrow it down if necessary to produce a
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
121 manageable amount of data, but we'll cut to the chase and create
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
122 a fairly restrictive set of criteria as follows:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
123
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
124 From: ginnean
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
125 To:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
126 Cc:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
127 Date: Jan 1994
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
128 Subject:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
129 --------
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
130 horse
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
131 kosciusko
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
132
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
133 As with MH-Letter mode, MH-Search provides commands like
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
134 \\<mh-search-mode-map>\\[mh-to-field] to help you fill in the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
135 blanks.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
136
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
137 If you find that you do the same thing over and over when editing
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
138 the search template, you may wish to bind some shortcuts to keys.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
139 This can be done with the variable `mh-search-mode-hook', which is
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
140 called when \\[mh-search] is run on a new pattern.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
141
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
142 To perform the search, type \\[mh-index-do-search].
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
143
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
144 Sometimes you're searching for text that is either not indexed,
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
145 or hasn't been indexed yet. In this case you can override the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
146 default method with the pick method by running the command
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
147 \\[mh-pick-do-search].
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
148
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
149 The messages that are found are put in a temporary sub-folder of
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
150 \"+mhe-index\" and are displayed in an MH-Folder buffer. This
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
151 buffer is special because it displays messages from multiple
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
152 folders; each set of messages from a given folder has a heading
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
153 with the folder name.\\<mh-folder-mode-map>
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
154
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
155 The appearance of the heading can be modified by customizing the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
156 face `mh-index-folder'. You can jump back and forth between the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
157 headings using the commands \\[mh-index-next-folder] and
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
158 \\[mh-index-previous-folder].
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
159
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
160 In addition, the command \\[mh-index-visit-folder] can be used to
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
161 visit the folder of the message at point. Initially, only the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
162 messages that matched the search criteria are displayed in the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
163 folder. While the temporary buffer has its own set of message
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
164 numbers, the actual messages numbers are shown in the visited
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
165 folder. Thus, the command \\[mh-index-visit-folder] is useful to
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
166 find the actual message number of an interesting message, or to
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
167 view surrounding messages with the command \\[mh-rescan-folder].
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
168
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
169 Because this folder is temporary, you'll probably get in the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
170 habit of killing it when you're done with
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
171 \\[mh-kill-folder].
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
172
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
173 SEARCH METHODS
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
174
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
175 The command \\[mh-search] runs the command defined by the option
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
176 `mh-index-program'. The default value is \"Auto-detect\" which
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
177 means that MH-E will automatically choose one of \"swish++\",
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
178 \"swish-e\", \"mairix\", \"namazu\", \"pick\" and \"grep\" in
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
179 that order. If, for example, you have both \"swish++\" and
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
180 \"mairix\" installed and you want to use \"mairix\", then you can
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
181 set this option to \"mairix\".
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
182
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
183 *NOTE*
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
184
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
185 The \"pick\" and \"grep\" commands do not perform a
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
186 recursive search on the given folder.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
187
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
188 This command uses an \"X-MHE-Checksum:\" header field to cache
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
189 the MD5 checksum of a message. This means that if an incoming
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
190 message already contains an \"X-MHE-Checksum:\" field, that
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
191 message might not be found by this command. The following
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
192 \"procmail\" recipe avoids this problem by renaming the existing
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
193 header field:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
194
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
195 :0 wf
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
196 | formail -R \"X-MHE-Checksum\" \"X-Old-MHE-Checksum\"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
197
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
198 The documentation for the following commands describe how to set
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
199 up the various indexing programs to use with MH-E. The \"pick\"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
200 and \"grep\" commands do not require additional configuration.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
201
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
202 - `mh-swish++-execute-search'
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
203 - `mh-swish-execute-search'
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
204 - `mh-mairix-execute-search'
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
205 - `mh-namazu-execute-search'
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
206 - `mh-pick-execute-search'
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
207 - `mh-grep-execute-search'
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
208
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
209 In a program, the folder is searched with SEARCH-REGEXP. If
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
210 FOLDER is \"+\" then mail in all folders are searched. Optional
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
211 argument WINDOW-CONFIG stores the window configuration that will
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
212 be restored after the user quits the folder containing the index
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
213 search results."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
214 (interactive
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
215 (list current-prefix-arg
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
216 (progn
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
217 (mh-find-path)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
218 ;; Yes, we do want to call mh-index-choose every time in case the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
219 ;; user has switched the indexer manually.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
220 (unless (mh-index-choose (and current-prefix-arg
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
221 mh-index-previous-search
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
222 (cadr mh-index-previous-search)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
223 (error "No indexing program found"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
224 (or (and current-prefix-arg mh-index-sequence-search-flag)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
225 (and current-prefix-arg (car mh-index-previous-search))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
226 (mh-prompt-for-folder "Search" "+" nil "all" t)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
227 (or (and current-prefix-arg (caddr mh-index-previous-search))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
228 mh-index-regexp-builder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
229 (read-string (format "%s regexp: "
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
230 (upcase-initials (symbol-name mh-indexer)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
231 (if (and (not (and current-prefix-arg
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
232 (caddr mh-index-previous-search)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
233 mh-index-regexp-builder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
234 (current-window-configuration)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
235 nil)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
236 ;; Redoing a sequence search?
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
237 (when (and redo-search-flag mh-index-data mh-index-sequence-search-flag
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
238 (not mh-flists-called-flag))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
239 (let ((mh-flists-called-flag t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
240 (apply #'mh-index-sequenced-messages mh-index-previous-search))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
241 (return-from mh-search))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
242 ;; We have fancy query parsing.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
243 (when (symbolp search-regexp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
244 (mh-search-folder folder window-config)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
245 (return-from mh-search))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
246 ;; Begin search proper.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
247 (mh-checksum-choose)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
248 (let ((result-count 0)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
249 (old-window-config (or window-config mh-previous-window-config))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
250 (previous-search mh-index-previous-search)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
251 (index-folder (format "%s/%s" mh-index-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
252 (mh-index-generate-pretty-name search-regexp))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
253 ;; Create a new folder for the search results or recreate the old one...
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
254 (if (and redo-search-flag mh-index-previous-search)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
255 (let ((buffer-name (buffer-name (current-buffer))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
256 (mh-process-or-undo-commands buffer-name)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
257 (save-excursion (mh-exec-cmd-quiet nil "rmf" buffer-name))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
258 (mh-exec-cmd-quiet nil "folder" "-create" "-fast" buffer-name)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
259 (setq index-folder buffer-name))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
260 (setq index-folder (mh-index-new-folder index-folder search-regexp)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
261
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
262 (let ((folder-path (format "%s%s" mh-user-path (substring folder 1)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
263 (folder-results-map (make-hash-table :test #'equal))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
264 (origin-map (make-hash-table :test #'equal)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
265 ;; Run search program...
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
266 (message "Executing %s... " mh-indexer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
267 (funcall mh-index-execute-search-function folder-path search-regexp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
268
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
269 ;; Parse indexer output.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
270 (message "Processing %s output... " mh-indexer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
271 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
272 (loop for next-result = (funcall mh-index-next-result-function)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
273 while next-result
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
274 do (unless (eq next-result 'error)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
275 (unless (gethash (car next-result) folder-results-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
276 (setf (gethash (car next-result) folder-results-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
277 (make-hash-table :test #'equal)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
278 (setf (gethash (cadr next-result)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
279 (gethash (car next-result) folder-results-map))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
280 t)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
281
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
282 ;; Copy the search results over.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
283 (maphash #'(lambda (folder msgs)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
284 (let ((cur (car (mh-translate-range folder "cur")))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
285 (msgs (sort (loop for msg being the hash-keys of msgs
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
286 collect msg)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
287 #'<)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
288 (mh-exec-cmd "refile" msgs "-src" folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
289 "-link" index-folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
290 ;; Restore cur to old value, that refile changed
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
291 (when cur
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
292 (mh-exec-cmd-quiet nil "mark" folder "-add" "-zero"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
293 "-sequence" "cur" (format "%s" cur)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
294 (loop for msg in msgs
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
295 do (incf result-count)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
296 (setf (gethash result-count origin-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
297 (cons folder msg)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
298 folder-results-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
299
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
300 ;; Vist the results folder.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
301 (mh-visit-folder index-folder () (list folder-results-map origin-map))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
302
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
303 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
304 (forward-line)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
305 (mh-update-sequences)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
306 (mh-recenter nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
307
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
308 ;; Update the speedbar, if needed.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
309 (when (mh-speed-flists-active-p)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
310 (mh-speed-flists t mh-current-folder))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
311
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
312 ;; Maintain history.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
313 (when (or (and redo-search-flag previous-search) window-config)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
314 (setq mh-previous-window-config old-window-config))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
315 (setq mh-index-previous-search (list folder mh-indexer search-regexp))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
316
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
317 ;; Write out data to disk.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
318 (unless mh-flists-called-flag (mh-index-write-data))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
319
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
320 (message "%s found %s matches in %s folders"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
321 (upcase-initials (symbol-name mh-indexer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
322 (loop for msg-hash being hash-values of mh-index-data
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
323 sum (hash-table-count msg-hash))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
324 (loop for msg-hash being hash-values of mh-index-data
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
325 count (> (hash-table-count msg-hash) 0))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
326
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
327 (defun mh-search-folder (folder window-config)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
328 "Search FOLDER for messages matching a pattern.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
329
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
330 In a program, argument WINDOW-CONFIG is the current window
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
331 configuration and is used when the search folder is dismissed."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
332 (interactive (list (mh-prompt-for-folder "Search" mh-current-folder nil nil t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
333 (current-window-configuration)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
334 (let ((pick-folder (if (equal folder "+") mh-current-folder folder)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
335 (switch-to-buffer-other-window "search-pattern")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
336 (if (or (zerop (buffer-size))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
337 (not (y-or-n-p "Reuse pattern? ")))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
338 (mh-make-pick-template)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
339 (message ""))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
340 (mh-make-local-vars 'mh-current-folder folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
341 'mh-previous-window-config window-config)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
342 (message "%s" (substitute-command-keys
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
343 (concat "Type \\[mh-index-do-search] to search messages, "
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
344 "\\[mh-pick-do-search] to use pick, "
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
345 "\\[mh-help] for help")))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
346
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
347 (defun mh-make-pick-template ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
348 "Initialize the current buffer with a template for a pick pattern."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
349 (let ((inhibit-read-only t)) (erase-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
350 (insert "From: \n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
351 "To: \n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
352 "Cc: \n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
353 "Date: \n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
354 "Subject: \n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
355 "---------\n")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
356 (mh-search-mode)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
357 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
358 (dotimes (i 5)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
359 (add-text-properties (point) (1+ (point)) '(front-sticky t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
360 (add-text-properties (- (line-end-position) 2) (1- (line-end-position))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
361 '(rear-nonsticky t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
362 (add-text-properties (point) (1- (line-end-position)) '(read-only t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
363 (forward-line))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
364 (add-text-properties (point) (1+ (point)) '(front-sticky t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
365 (add-text-properties (point) (1- (line-end-position)) '(read-only t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
366 (goto-char (point-max)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
367
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
368 (defvar mh-search-mode-map (make-sparse-keymap)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
369 "Keymap for searching folder.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
370
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
371 ;; If this changes, modify mh-search-mode-help-messages accordingly, below.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
372 (gnus-define-keys mh-search-mode-map
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
373 "\C-c?" mh-help
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
374 "\C-c\C-c" mh-index-do-search
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
375 "\C-c\C-p" mh-pick-do-search
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
376 "\C-c\C-f\C-b" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
377 "\C-c\C-f\C-c" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
378 "\C-c\C-f\C-d" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
379 "\C-c\C-f\C-f" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
380 "\C-c\C-f\C-r" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
381 "\C-c\C-f\C-s" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
382 "\C-c\C-f\C-t" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
383 "\C-c\C-fb" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
384 "\C-c\C-fc" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
385 "\C-c\C-fd" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
386 "\C-c\C-ff" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
387 "\C-c\C-fr" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
388 "\C-c\C-fs" mh-to-field
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
389 "\C-c\C-ft" mh-to-field)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
390
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
391 (easy-menu-define
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
392 mh-pick-menu mh-search-mode-map "Menu for MH-E Search"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
393 '("Search"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
394 ["Perform Search" mh-index-do-search t]
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
395 ["Search with pick" mh-pick-do-search t]))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
396
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
397 ;; Group messages logically, more or less.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
398 (defvar mh-search-mode-help-messages
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
399 '((nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
400 "Perform search: \\[mh-index-do-search]\n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
401 "Search with pick: \\[mh-pick-do-search]\n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
402 "Move to a field by typing C-c C-f C-<field>\n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
403 "where <field> is the first letter of the desired field\n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
404 "(except for From: which uses \"m\")."))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
405 "Key binding cheat sheet.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
406
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
407 This is an associative array which is used to show the most common
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
408 commands. The key is a prefix char. The value is one or more strings
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
409 which are concatenated together and displayed in the minibuffer if ?
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
410 is pressed after the prefix character. The special key nil is used to
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
411 display the non-prefixed commands.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
412
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
413 The substitutions described in `substitute-command-keys' are performed
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
414 as well.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
415
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
416 (put 'mh-search-mode 'mode-class 'special)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
417
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
418 (define-derived-mode mh-search-mode fundamental-mode "MH-Search"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
419 "Mode for creating search templates in MH-E.\\<mh-search-mode-map>
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
420
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
421 After each field name, enter the pattern to search for. If a field's
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
422 value does not matter for the search, leave it empty. To search the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
423 entire message, supply the pattern in the \"body\" of the template.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
424 Each non-empty field must be matched for a message to be selected. To
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
425 effect a logical \"or\", use \\[mh-search-folder] multiple times. When
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
426 you have finished, type \\[mh-pick-do-search] to do the search.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
427
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
428 The hook `mh-search-mode-hook' is called upon entry to this mode.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
429
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
430 \\{mh-search-mode-map}"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
431
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
432 (make-local-variable 'mh-help-messages)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
433 (easy-menu-add mh-pick-menu)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
434 (setq mh-help-messages mh-search-mode-help-messages))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
435
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
436 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
437 (defun mh-index-do-search (&optional indexer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
438 "Find messages that match the qualifications in the current pattern buffer.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
439 If optional argument INDEXER is present, use it instead of
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
440 `mh-index-program'."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
441 (interactive)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
442 (unless (mh-index-choose indexer) (error "No indexing program found"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
443 (let* ((regexp-list (mh-pick-parse-search-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
444 (pattern (funcall mh-index-regexp-builder regexp-list)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
445 (if pattern
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
446 (mh-search nil mh-current-folder pattern mh-previous-window-config)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
447 (error "No search terms"))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
448
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
449 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
450 (defun mh-pick-do-search ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
451 "Find messages that match the qualifications in the current pattern buffer.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
452
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
453 Uses the pick method described in `mh-pick-execute-search'."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
454 (interactive)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
455 (mh-index-do-search 'pick))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
456
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
457 (defun mh-pick-parse-search-buffer ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
458 "Parse the search buffer contents.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
459 The function returns a alist. The car of each element is either
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
460 the header name to search in or nil to search the whole message.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
461 The cdr of the element is the pattern to search."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
462 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
463 (let ((pattern-list ())
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
464 (in-body-flag nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
465 start begin)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
466 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
467 (while (not (eobp))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
468 (if (search-forward "--------" (line-end-position) t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
469 (setq in-body-flag t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
470 (beginning-of-line)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
471 (setq begin (point))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
472 (setq start (if in-body-flag
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
473 (point)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
474 (search-forward ":" (line-end-position) t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
475 (point)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
476 (push (cons (and (not in-body-flag)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
477 (intern (downcase
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
478 (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
479 begin (1- start)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
480 (mh-index-parse-search-regexp
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
481 (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
482 start (line-end-position))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
483 pattern-list))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
484 (forward-line))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
485 pattern-list)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
486
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
487 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
488 (defun mh-index-parse-search-regexp (input-string)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
489 "Construct parse tree for INPUT-STRING.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
490 All occurrences of &, |, ! and ~ in INPUT-STRING are replaced by
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
491 AND, OR and NOT as appropriate. Then the resulting string is
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
492 parsed."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
493 (let (input)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
494 (with-temp-buffer
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
495 (insert input-string)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
496 ;; replace tabs
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
497 (mh-replace-string "\t" " ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
498 ;; synonyms of AND
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
499 (mh-replace-string " AND " " and ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
500 (mh-replace-string "&" " and ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
501 (mh-replace-string " -and " " and ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
502 ;; synonyms of OR
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
503 (mh-replace-string " OR " " or ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
504 (mh-replace-string "|" " or ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
505 (mh-replace-string " -or " " or ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
506 ;; synonyms of NOT
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
507 (mh-replace-string " NOT " " not ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
508 (mh-replace-string "!" " not ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
509 (mh-replace-string "~" " not ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
510 (mh-replace-string " -not " " not ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
511 ;; synonyms of left brace
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
512 (mh-replace-string "(" " ( ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
513 (mh-replace-string " -lbrace " " ( ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
514 ;; synonyms of right brace
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
515 (mh-replace-string ")" " ) ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
516 (mh-replace-string " -rbrace " " ) ")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
517 ;; get the normalized input
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
518 (setq input (format "( %s )" (buffer-substring (point-min) (point-max)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
519
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
520 (let ((tokens (mh-index-add-implicit-ops (split-string input)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
521 (op-stack ())
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
522 (operand-stack ())
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
523 oper1)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
524 (dolist (token tokens)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
525 (cond ((equal token "(") (push 'paren op-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
526 ((equal token "not") (push 'not op-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
527 ((equal token "or") (push 'or op-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
528 ((equal token "and") (push 'and op-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
529 ((equal token ")")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
530 (multiple-value-setq (op-stack operand-stack)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
531 (mh-index-evaluate op-stack operand-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
532 (when (eq (car op-stack) 'not)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
533 (setq op-stack (cdr op-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
534 (push `(not ,(pop operand-stack)) operand-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
535 (when (eq (car op-stack) 'and)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
536 (setq op-stack (cdr op-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
537 (setq oper1 (pop operand-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
538 (push `(and ,(pop operand-stack) ,oper1) operand-stack)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
539 ((eq (car op-stack) 'not)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
540 (setq op-stack (cdr op-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
541 (push `(not ,token) operand-stack)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
542 (when (eq (car op-stack) 'and)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
543 (setq op-stack (cdr op-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
544 (setq oper1 (pop operand-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
545 (push `(and ,(pop operand-stack) ,oper1) operand-stack)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
546 ((eq (car op-stack) 'and)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
547 (setq op-stack (cdr op-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
548 (push `(and ,(pop operand-stack) ,token) operand-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
549 (t (push token operand-stack))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
550 (prog1 (pop operand-stack)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
551 (when (or op-stack operand-stack)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
552 (error "Invalid regexp: %s" input))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
553
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
554 (defun mh-index-add-implicit-ops (tokens)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
555 "Add implicit operators in the list TOKENS."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
556 (let ((result ())
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
557 (literal-seen nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
558 current)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
559 (while tokens
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
560 (setq current (pop tokens))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
561 (cond ((or (equal current ")") (equal current "and") (equal current "or"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
562 (setq literal-seen nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
563 (push current result))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
564 ((and literal-seen
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
565 (push "and" result)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
566 (setq literal-seen nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
567 nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
568 (t
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
569 (push current result)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
570 (unless (or (equal current "(") (equal current "not"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
571 (setq literal-seen t)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
572 (nreverse result)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
573
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
574 (defun mh-index-evaluate (op-stack operand-stack)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
575 "Read expression till starting paren based on OP-STACK and OPERAND-STACK."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
576 (block mh-index-evaluate
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
577 (let (op oper1)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
578 (while op-stack
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
579 (setq op (pop op-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
580 (cond ((eq op 'paren)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
581 (return-from mh-index-evaluate (values op-stack operand-stack)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
582 ((eq op 'not)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
583 (push `(not ,(pop operand-stack)) operand-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
584 ((or (eq op 'and) (eq op 'or))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
585 (setq oper1 (pop operand-stack))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
586 (push `(,op ,(pop operand-stack) ,oper1) operand-stack))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
587 (error "Ran out of tokens"))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
588
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
589
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
590
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
591 ;;; Sequence browsing
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
592
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
593 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
594 (defun mh-index-new-messages (folders)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
595 "Display unseen messages.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
596
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
597 If you use a program such as \"procmail\" to use \"rcvstore\" to file
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
598 your incoming mail automatically, you can display new, unseen,
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
599 messages using this command. All messages in the \"unseen\"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
600 sequence from the folders in `mh-new-messages-folders' are
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
601 listed.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
602
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
603 With a prefix argument, enter a space-separated list of FOLDERS,
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
604 or nothing to search all folders."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
605 (interactive
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
606 (list (if current-prefix-arg
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
607 (split-string (read-string "Search folder(s) (default all): "))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
608 mh-new-messages-folders)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
609 (mh-index-sequenced-messages folders mh-unseen-seq))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
610
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
611 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
612 (defun mh-index-ticked-messages (folders)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
613 "Display ticked messages.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
614
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
615 All messages in `mh-tick-seq' from the folders in
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
616 `mh-ticked-messages-folders' are listed.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
617
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
618 With a prefix argument, enter a space-separated list of FOLDERS,
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
619 or nothing to search all folders."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
620 (interactive
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
621 (list (if current-prefix-arg
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
622 (split-string (read-string "Search folder(s) (default all): "))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
623 mh-ticked-messages-folders)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
624 (mh-index-sequenced-messages folders mh-tick-seq))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
625
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
626 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
627 (defun mh-index-sequenced-messages (folders sequence)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
628 "Display messages in any sequence.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
629
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
630 All messages from the FOLDERS in `mh-new-messages-folders' in the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
631 SEQUENCE you provide are listed. With a prefix argument, enter a
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
632 space-separated list of folders at the prompt, or nothing to
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
633 search all folders."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
634 (interactive
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
635 (list (if current-prefix-arg
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
636 (split-string (read-string "Search folder(s) (default all): "))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
637 mh-new-messages-folders)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
638 (mh-read-seq-default "Search" nil)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
639 (unless sequence (setq sequence mh-unseen-seq))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
640 (let* ((mh-flists-search-folders folders)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
641 (mh-flists-sequence sequence)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
642 (mh-flists-called-flag t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
643 (mh-indexer 'flists)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
644 (mh-index-execute-search-function 'mh-flists-execute)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
645 (mh-index-next-result-function 'mh-mairix-next-result)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
646 (mh-mairix-folder mh-user-path)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
647 (mh-index-regexp-builder nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
648 (new-folder (format "%s/%s/%s" mh-index-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
649 mh-flists-results-folder sequence))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
650 (window-config (if (equal new-folder mh-current-folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
651 mh-previous-window-config
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
652 (current-window-configuration)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
653 (redo-flag nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
654 message)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
655 (cond ((buffer-live-p (get-buffer new-folder))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
656 ;; The destination folder is being visited. Trick `mh-search'
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
657 ;; into thinking that the folder resulted from a previous search.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
658 (set-buffer new-folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
659 (setq mh-index-previous-search (list folders mh-indexer sequence))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
660 (setq redo-flag t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
661 ((mh-folder-exists-p new-folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
662 ;; Folder exists but we don't have it open. That means they are
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
663 ;; stale results from a old flists search. Clear it out.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
664 (mh-exec-cmd-quiet nil "rmf" new-folder)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
665 (setq message (mh-search redo-flag "+" mh-flists-results-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
666 window-config)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
667 mh-index-sequence-search-flag t
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
668 mh-index-previous-search (list folders mh-indexer sequence))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
669 (mh-index-write-data)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
670 (when (stringp message) (message "%s" message))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
671
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
672 (defvar mh-flists-search-folders)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
673
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
674 (defun mh-flists-execute (&rest args)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
675 "Execute flists.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
676 Search for messages belonging to `mh-flists-sequence' in the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
677 folders specified by `mh-flists-search-folders'. If
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
678 `mh-recursive-folders-flag' is t, then the folders are searched
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
679 recursively. All parameters ARGS are ignored."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
680 (set-buffer (get-buffer-create mh-temp-index-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
681 (erase-buffer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
682 (unless (executable-find "sh")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
683 (error "Didn't find sh"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
684 (with-temp-buffer
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
685 (let ((seq (symbol-name mh-flists-sequence)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
686 (insert "for folder in `" (expand-file-name "flists" mh-progs) " "
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
687 (cond ((eq mh-flists-search-folders t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
688 (mh-quote-for-shell mh-inbox))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
689 ((eq mh-flists-search-folders nil) "")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
690 ((listp mh-flists-search-folders)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
691 (loop for folder in mh-flists-search-folders
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
692 concat
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
693 (concat " " (mh-quote-for-shell folder)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
694 (if mh-recursive-folders-flag " -recurse" "")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
695 " -sequence " seq " -noshowzero -fast` ; do\n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
696 (expand-file-name "mhpath" mh-progs) " \"+$folder\" " seq "\n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
697 "done\n"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
698 (call-process-region
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
699 (point-min) (point-max) "sh" nil (get-buffer mh-temp-index-buffer))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
700
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
701
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
702
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
703 ;;; Folder navigation and utilities
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
704
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
705 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
706 (defun mh-index-group-by-folder ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
707 "Partition the messages based on source folder.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
708 Returns an alist with the the folder names in the car and the cdr
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
709 being the list of messages originally from that folder."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
710 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
711 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
712 (let ((result-table (make-hash-table :test #'equal)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
713 (loop for msg being hash-keys of mh-index-msg-checksum-map
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
714 do (push msg (gethash (car (gethash
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
715 (gethash msg mh-index-msg-checksum-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
716 mh-index-checksum-origin-map))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
717 result-table)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
718 (loop for x being the hash-keys of result-table
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
719 collect (cons x (nreverse (gethash x result-table)))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
720
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
721 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
722 (defun mh-index-insert-folder-headers ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
723 "Annotate the search results with original folder names."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
724 (let ((cur-msg (mh-get-msg-num nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
725 (old-buffer-modified-flag (buffer-modified-p))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
726 (buffer-read-only nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
727 current-folder last-folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
728 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
729 (while (not (eobp))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
730 (setq current-folder (car (gethash (gethash (mh-get-msg-num nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
731 mh-index-msg-checksum-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
732 mh-index-checksum-origin-map)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
733 (when (and current-folder (not (equal current-folder last-folder)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
734 (insert (if last-folder "\n" "") current-folder "\n")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
735 (setq last-folder current-folder))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
736 (forward-line))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
737 (when cur-msg
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
738 (mh-notate-cur)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
739 (mh-goto-msg cur-msg t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
740 (set-buffer-modified-p old-buffer-modified-flag))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
741 (mh-index-create-imenu-index))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
742
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
743 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
744 (defun mh-index-delete-folder-headers ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
745 "Delete the folder headers."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
746 (let ((cur-msg (mh-get-msg-num nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
747 (old-buffer-modified-flag (buffer-modified-p))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
748 (buffer-read-only nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
749 (while (and (not cur-msg) (not (eobp)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
750 (forward-line)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
751 (setq cur-msg (mh-get-msg-num nil)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
752 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
753 (while (not (eobp))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
754 (if (or (char-equal (char-after) ?+) (char-equal (char-after) 10))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
755 (delete-region (point) (progn (forward-line) (point)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
756 (forward-line)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
757 (when cur-msg (mh-goto-msg cur-msg t t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
758 (set-buffer-modified-p old-buffer-modified-flag)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
759
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
760 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
761 (defun mh-index-create-imenu-index ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
762 "Create alist of folder names and positions in index folder buffers."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
763 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
764 (setq which-func-mode t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
765 (let ((alist ()))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
766 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
767 (while (re-search-forward "^+" nil t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
768 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
769 (beginning-of-line)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
770 (push (cons (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
771 (point) (line-end-position))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
772 (set-marker (make-marker) (point)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
773 alist)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
774 (setq imenu--index-alist (nreverse alist)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
775
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
776 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
777 (defun mh-index-next-folder (&optional backward-flag)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
778 "Jump to the next folder marker.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
779
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
780 With non-nil optional argument BACKWARD-FLAG, jump to the previous
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
781 group of results."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
782 (interactive "P")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
783 (if (null mh-index-data)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
784 (message "Only applicable in an MH-E index search buffer")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
785 (let ((point (point)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
786 (forward-line (if backward-flag 0 1))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
787 (cond ((if backward-flag
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
788 (re-search-backward "^+" (point-min) t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
789 (re-search-forward "^+" (point-max) t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
790 (beginning-of-line))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
791 ((and (if backward-flag
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
792 (goto-char (point-max))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
793 (goto-char (point-min)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
794 nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
795 ((if backward-flag
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
796 (re-search-backward "^+" (point-min) t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
797 (re-search-forward "^+" (point-max) t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
798 (beginning-of-line))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
799 (t (goto-char point))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
800
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
801 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
802 (defun mh-index-previous-folder ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
803 "Jump to the previous folder marker."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
804 (interactive)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
805 (mh-index-next-folder t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
806
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
807 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
808 (defun mh-index-visit-folder ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
809 "Visit original folder from where the message at point was found."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
810 (interactive)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
811 (unless mh-index-data
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
812 (error "Not in an index folder"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
813 (let (folder msg)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
814 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
815 (cond ((and (bolp) (eolp))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
816 (ignore-errors (forward-line -1))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
817 (setq msg (mh-get-msg-num t)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
818 ((equal (char-after (line-beginning-position)) ?+)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
819 (setq folder (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
820 (line-beginning-position) (line-end-position))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
821 (t (setq msg (mh-get-msg-num t)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
822 (when (not folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
823 (setq folder (car (gethash (gethash msg mh-index-msg-checksum-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
824 mh-index-checksum-origin-map))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
825 (when (or (not (get-buffer folder))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
826 (y-or-n-p (format "Reuse buffer displaying %s? " folder)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
827 (mh-visit-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
828 folder (loop for x being the hash-keys of (gethash folder mh-index-data)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
829 when (mh-msg-exists-p x folder) collect x)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
830
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
831 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
832 (defun mh-index-p ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
833 "Non-nil means that this folder was generated by an index search."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
834 mh-index-data)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
835
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
836 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
837 (defun mh-index-execute-commands ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
838 "Delete/refile the actual messages.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
839 The copies in the searched folder are then deleted/refiled to get
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
840 the desired result. Before deleting the messages we make sure
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
841 that the message being deleted is identical to the one that the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
842 user has marked in the index buffer."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
843 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
844 (let ((folders ())
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
845 (mh-speed-flists-inhibit-flag t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
846 (maphash
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
847 (lambda (folder msgs)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
848 (push folder folders)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
849 (if (not (get-buffer folder))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
850 ;; If source folder not open, just delete the messages...
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
851 (apply #'mh-exec-cmd "rmm" folder (mh-coalesce-msg-list msgs))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
852 ;; Otherwise delete the messages in the source buffer...
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
853 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
854 (set-buffer folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
855 (let ((old-refile-list mh-refile-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
856 (old-delete-list mh-delete-list))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
857 (setq mh-refile-list nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
858 mh-delete-list msgs)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
859 (unwind-protect (mh-execute-commands)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
860 (setq mh-refile-list
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
861 (mapcar (lambda (x)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
862 (cons (car x)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
863 (loop for y in (cdr x)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
864 unless (memq y msgs) collect y)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
865 old-refile-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
866 mh-delete-list
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
867 (loop for x in old-delete-list
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
868 unless (memq x msgs) collect x))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
869 (mh-set-folder-modified-p (mh-outstanding-commands-p))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
870 (when (mh-outstanding-commands-p)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
871 (mh-notate-deleted-and-refiled)))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
872 (mh-index-matching-source-msgs (append (loop for x in mh-refile-list
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
873 append (cdr x))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
874 mh-delete-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
875 t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
876 folders)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
877
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
878
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
879
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
880 ;;; Indexing functions
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
881
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
882 ;; Support different indexing programs
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
883 (defvar mh-indexer-choices
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
884 '((swish++
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
885 mh-swish++-binary mh-swish++-execute-search mh-swish++-next-result
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
886 mh-swish++-regexp-builder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
887 (swish
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
888 mh-swish-binary mh-swish-execute-search mh-swish-next-result nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
889 (mairix
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
890 mh-mairix-binary mh-mairix-execute-search mh-mairix-next-result
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
891 mh-mairix-regexp-builder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
892 (namazu
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
893 mh-namazu-binary mh-namazu-execute-search mh-namazu-next-result nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
894 (pick
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
895 mh-pick-binary mh-pick-execute-search mh-pick-next-result
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
896 mh-pick-regexp-builder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
897 (grep
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
898 mh-grep-binary mh-grep-execute-search mh-grep-next-result nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
899 "List of possible indexer choices.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
900
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
901 (defun mh-index-choose (&optional indexer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
902 "Choose an indexing function.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
903 The side-effects of this function are that the variables
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
904 `mh-indexer', `mh-index-execute-search-function', and
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
905 `mh-index-next-result-function' are set according to the first
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
906 indexer in `mh-indexer-choices' present on the system.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
907 If optional argument INDEXER is present, use it instead of
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
908 `mh-index-program'."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
909 (block nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
910 (let ((program-alist (cond (indexer
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
911 (list (assoc indexer mh-indexer-choices)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
912 (mh-index-program
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
913 (list
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
914 (assoc mh-index-program mh-indexer-choices)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
915 (t mh-indexer-choices))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
916 (while program-alist
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
917 (let* ((current (pop program-alist))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
918 (executable (symbol-value (cadr current))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
919 (when executable
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
920 (setq mh-indexer (car current))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
921 (setq mh-index-execute-search-function (nth 2 current))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
922 (setq mh-index-next-result-function (nth 3 current))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
923 (setq mh-index-regexp-builder (nth 4 current))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
924 (return mh-indexer))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
925 nil)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
926
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
927 ;;; Swish++ interface
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
928
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
929 (defvar mh-swish++-binary (or (executable-find "search++")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
930 (executable-find "search")))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
931 (defvar mh-swish++-directory ".swish++")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
932 (defvar mh-swish-folder nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
933
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
934 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
935 (defun mh-swish++-execute-search (folder-path search-regexp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
936 "Execute swish++ and read the results.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
937
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
938 In the examples below, replace \"/home/user/Mail\" with the path to
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
939 your MH directory.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
940
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
941 First create the directory \"/home/user/Mail/.swish++\". Then create
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
942 the file \"/home/user/Mail/.swish++/swish++.conf\" with the following
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
943 contents:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
944
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
945 IncludeMeta Bcc Cc Comments Content-Description From Keywords
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
946 IncludeMeta Newsgroups Resent-To Subject To
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
947 IncludeMeta Message-Id References In-Reply-To
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
948 IncludeFile Mail *
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
949 IndexFile /home/user/Mail/.swish++/swish++.index
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
950
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
951 Use the following command line to generate the swish index. Run
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
952 this daily from cron:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
953
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
954 find /home/user/Mail -path /home/user/Mail/mhe-index -prune \\
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
955 -o -path /home/user/Mail/.swish++ -prune \\
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
956 -o -name \"[0-9]*\" -print \\
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
957 | index -c /home/user/Mail/.swish++/swish++.conf -
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
958
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
959 This command does not index the folders that hold the results of your
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
960 searches in \"+mhe-index\" since they tend to be ephemeral and the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
961 original messages are indexed anyway.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
962
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
963 On some systems (Debian GNU/Linux, for example), use \"index++\"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
964 instead of \"index\".
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
965
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
966 In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP is
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
967 used to search."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
968 (set-buffer (get-buffer-create mh-temp-index-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
969 (erase-buffer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
970 (unless mh-swish++-binary
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
971 (error "Set `mh-swish++-binary' appropriately"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
972 (call-process mh-swish++-binary nil '(t nil) nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
973 "-m" "10000"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
974 (format "-i%s%s/swish++.index"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
975 mh-user-path mh-swish++-directory)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
976 search-regexp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
977 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
978 (setq mh-swish-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
979 (let ((last-char (substring folder-path (1- (length folder-path)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
980 (if (equal last-char "/")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
981 folder-path
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
982 (format "%s/" folder-path)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
983
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
984 (defalias 'mh-swish++-next-result 'mh-swish-next-result)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
985
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
986 (defun mh-swish++-regexp-builder (regexp-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
987 "Generate query for swish++.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
988 REGEXP-LIST is an alist of fields and values."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
989 (let ((regexp ""))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
990 (dolist (elem regexp-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
991 (when (cdr elem)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
992 (setq regexp (concat regexp " and "
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
993 (if (car elem) "(" "")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
994 (if (car elem) (symbol-name (car elem)) "")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
995 (if (car elem) " = " "")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
996 (mh-swish++-print-regexp (cdr elem))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
997 (if (car elem) ")" "")))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
998 (substring regexp 4)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
999
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1000 (defun mh-swish++-print-regexp (expr)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1001 "Return infix expression corresponding to EXPR."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1002 (cond ((atom expr) (format "%s" expr))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1003 ((eq (car expr) 'not)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1004 (format "(not %s)" (mh-swish++-print-regexp (cadr expr))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1005 (t (format "(%s %s %s)" (mh-swish++-print-regexp (cadr expr))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1006 (symbol-name (car expr))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1007 (mh-swish++-print-regexp (caddr expr))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1008
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1009 ;;; Swish interface
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1010
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1011 (defvar mh-swish-binary (executable-find "swish-e"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1012 (defvar mh-swish-directory ".swish")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1013
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1014 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1015 (defun mh-swish-execute-search (folder-path search-regexp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1016 "Execute swish-e and read the results.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1017
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1018 In the examples below, replace \"/home/user/Mail\" with the path
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1019 to your MH directory.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1020
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1021 First create the directory \"/home/user/Mail/.swish\". Then
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1022 create the file \"/home/user/Mail/.swish/config\" with the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1023 following contents:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1024
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1025 DefaultContents TXT*
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1026 IndexDir /home/user/Mail
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1027 IndexFile /home/user/Mail/.swish/index
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1028 IndexName \"Mail Index\"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1029 IndexDescription \"Mail Index\"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1030 IndexPointer \"http://nowhere\"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1031 IndexAdmin \"nobody\"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1032 #MetaNames automatic
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1033 IndexReport 3
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1034 FollowSymLinks no
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1035 UseStemming no
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1036 IgnoreTotalWordCountWhenRanking yes
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1037 WordCharacters abcdefghijklmnopqrstuvwxyz0123456789-
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1038 BeginCharacters abcdefghijklmnopqrstuvwxyz
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1039 EndCharacters abcdefghijklmnopqrstuvwxyz0123456789
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1040 IgnoreLimit 50 1000
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1041 IndexComments 0
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1042 FileRules filename contains \\D
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1043 FileRules pathname contains /home/user/Mail/.swish
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1044 FileRules pathname contains /home/user/Mail/mhe-index
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1045
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1046 This configuration does not index the folders that hold the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1047 results of your searches in \"+mhe-index\" since they tend to be
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1048 ephemeral and the original messages are indexed anyway.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1049
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1050 If there are any directories you would like to ignore, append
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1051 lines like the following to \"config\":
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1052
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1053 FileRules pathname contains /home/user/Mail/scripts
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1054
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1055 Use the following command line to generate the swish index. Run
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1056 this daily from cron:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1057
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1058 swish-e -c /home/user/Mail/.swish/config
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1059
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1060 In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1061 is used to search."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1062 (set-buffer (get-buffer-create mh-temp-index-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1063 (erase-buffer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1064 (unless mh-swish-binary
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1065 (error "Set `mh-swish-binary' appropriately"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1066 (call-process mh-swish-binary nil '(t nil) nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1067 "-w" search-regexp
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1068 "-f" (format "%s%s/index" mh-user-path mh-swish-directory))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1069 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1070 (setq mh-swish-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1071 (let ((last-char (substring folder-path (1- (length folder-path)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1072 (if (equal last-char "/")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1073 folder-path
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1074 (format "%s/" folder-path)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1075
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1076 (defun mh-swish-next-result ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1077 "Get the next result from swish output."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1078 (prog1
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1079 (block nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1080 (when (or (eobp) (equal (char-after (point)) ?.))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1081 (return nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1082 (when (equal (char-after (point)) ?#)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1083 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1084 (let* ((start (search-forward " " (line-end-position) t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1085 (end (search-forward " " (line-end-position) t)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1086 (unless (and start end)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1087 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1088 (setq end (1- end))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1089 (unless (file-exists-p (buffer-substring-no-properties start end))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1090 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1091 (unless (search-backward "/" start t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1092 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1093 (list (let* ((s (buffer-substring-no-properties start (1+ (point)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1094 (unless (string-match mh-swish-folder s)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1095 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1096 (if (and (string-match mh-user-path s)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1097 (< (match-end 0) (1- (length s))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1098 (format "+%s"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1099 (substring s (match-end 0) (1- (length s))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1100 (return 'error)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1101 (let* ((s (buffer-substring-no-properties (1+ (point)) end))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1102 (val (ignore-errors (read-from-string s))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1103 (if (and (consp val) (numberp (car val)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1104 (car val)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1105 (return 'error)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1106 nil)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1107 (forward-line)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1108
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1109 ;;; Mairix interface
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1110
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1111 (defvar mh-mairix-binary (executable-find "mairix"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1112 (defvar mh-mairix-directory ".mairix")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1113 (defvar mh-mairix-folder nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1114
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1115 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1116 (defun mh-mairix-execute-search (folder-path search-regexp-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1117 "Execute mairix and read the results.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1118
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1119 In the examples below, replace \"/home/user/Mail\" with the path
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1120 to your MH directory.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1121
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1122 First create the directory \"/home/user/Mail/.mairix\". Then
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1123 create the file \"/home/user/Mail/.mairix/config\" with the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1124 following contents:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1125
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1126 base=/home/user/Mail
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1127
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1128 # List of folders that should be indexed. 3 dots at the end means there
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1129 # are subfolders within the folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1130 mh=archive...:inbox:drafts:news:sent:trash
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1131
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1132 vfolder_format=raw
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1133 database=/home/user/Mail/mairix/database
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1134
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1135 Use the following command line to generate the mairix index. Run
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1136 this daily from cron:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1137
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1138 mairix -f /home/user/Mail/.mairix/config
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1139
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1140 In a program, FOLDER-PATH is the directory in which
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1141 SEARCH-REGEXP-LIST is used to search."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1142 (set-buffer (get-buffer-create mh-temp-index-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1143 (erase-buffer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1144 (unless mh-mairix-binary
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1145 (error "Set `mh-mairix-binary' appropriately"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1146 (apply #'call-process mh-mairix-binary nil '(t nil) nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1147 "-r" "-f" (format "%s%s/config" mh-user-path mh-mairix-directory)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1148 search-regexp-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1149 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1150 (setq mh-mairix-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1151 (let ((last-char (substring folder-path (1- (length folder-path)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1152 (if (equal last-char "/")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1153 folder-path
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1154 (format "%s/" folder-path)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1155
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1156 (defun mh-mairix-next-result ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1157 "Return next result from mairix output."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1158 (prog1
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1159 (block nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1160 (when (or (eobp) (and (bolp) (eolp)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1161 (return nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1162 (unless (eq (char-after) ?/)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1163 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1164 (let ((start (point))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1165 end msg-start)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1166 (setq end (line-end-position))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1167 (unless (search-forward mh-mairix-folder end t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1168 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1169 (goto-char (match-beginning 0))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1170 (unless (equal (point) start)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1171 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1172 (goto-char end)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1173 (unless (search-backward "/" start t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1174 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1175 (setq msg-start (1+ (point)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1176 (goto-char start)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1177 (unless (search-forward mh-user-path end t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1178 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1179 (list (format "+%s" (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1180 (point) (1- msg-start)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1181 (car (read-from-string
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1182 (buffer-substring-no-properties msg-start end)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1183 ())))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1184 (forward-line)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1185
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1186 (defun mh-mairix-regexp-builder (regexp-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1187 "Generate query for mairix.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1188 REGEXP-LIST is an alist of fields and values."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1189 (let ((result ()))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1190 (dolist (pair regexp-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1191 (when (cdr pair)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1192 (push
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1193 (concat
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1194 (cond ((eq (car pair) 'to) "t:")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1195 ((eq (car pair) 'from) "f:")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1196 ((eq (car pair) 'cc) "c:")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1197 ((eq (car pair) 'subject) "s:")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1198 ((eq (car pair) 'date) "d:")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1199 (t ""))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1200 (let ((sop (cdr (mh-mairix-convert-to-sop* (cdr pair))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1201 (final ""))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1202 (dolist (conjunct sop)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1203 (let ((expr-list (cdr conjunct))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1204 (expr-string ""))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1205 (dolist (e expr-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1206 (setq expr-string (concat expr-string ","
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1207 (if (atom e) "" "~")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1208 (if (atom e) e (cadr e)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1209 (setq final (concat final "/" (substring expr-string 1)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1210 (substring final 1)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1211 result)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1212 result))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1213
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1214 (defun mh-mairix-convert-to-sop* (expr)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1215 "Convert EXPR to sum of product form."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1216 (cond ((atom expr) `(or (and ,expr)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1217 ((eq (car expr) 'or)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1218 (cons 'or
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1219 (loop for e in (mapcar #'mh-mairix-convert-to-sop* (cdr expr))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1220 append (cdr e))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1221 ((eq (car expr) 'and)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1222 (let ((conjuncts (mapcar #'mh-mairix-convert-to-sop* (cdr expr)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1223 result next-factor)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1224 (setq result (pop conjuncts))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1225 (while conjuncts
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1226 (setq next-factor (pop conjuncts))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1227 (setq result (let ((res ()))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1228 (dolist (t1 (cdr result))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1229 (dolist (t2 (cdr next-factor))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1230 (push `(and ,@(cdr t1) ,@(cdr t2)) res)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1231 (cons 'or res))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1232 result))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1233 ((atom (cadr expr)) `(or (and ,expr)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1234 ((eq (caadr expr) 'not) (mh-mairix-convert-to-sop* (cadadr expr)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1235 ((eq (caadr expr) 'and) (mh-mairix-convert-to-sop*
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1236 `(or ,@(mapcar #'(lambda (x) `(not ,x))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1237 (cdadr expr)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1238 ((eq (caadr expr) 'or) (mh-mairix-convert-to-sop*
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1239 `(and ,@(mapcar #'(lambda (x) `(not ,x))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1240 (cdadr expr)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1241 (t (error "Unreachable: %s" expr))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1242
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1243 ;;; Namazu interface
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1244
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1245 (defvar mh-namazu-binary (executable-find "namazu"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1246 (defvar mh-namazu-directory ".namazu")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1247 (defvar mh-namazu-folder nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1248
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1249 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1250 (defun mh-namazu-execute-search (folder-path search-regexp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1251 "Execute namazu and read the results.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1252
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1253 In the examples below, replace \"/home/user/Mail\" with the path to
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1254 your MH directory.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1255
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1256 First create the directory \"/home/user/Mail/.namazu\". Then create
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1257 the file \"/home/user/Mail/.namazu/mknmzrc\" with the following
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1258 contents:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1259
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1260 package conf; # Don't remove this line!
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1261 $ADDRESS = 'user@localhost';
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1262 $ALLOW_FILE = \"[0-9]*\";
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1263 $EXCLUDE_PATH = \"^/home/user/Mail/(mhe-index|spam)\";
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1264
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1265 This configuration does not index the folders that hold the results of
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1266 your searches in \"+mhe-index\" since they tend to be ephemeral and
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1267 the original messages are indexed anyway.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1268
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1269 Use the following command line to generate the namazu index. Run this
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1270 daily from cron:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1271
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1272 mknmz -f /home/user/Mail/.namazu/mknmzrc -O /home/user/Mail/.namazu \\
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1273 /home/user/Mail
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1274
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1275 In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1276 is used to search."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1277 (let ((namazu-index-directory
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1278 (format "%s%s" mh-user-path mh-namazu-directory)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1279 (unless (file-exists-p namazu-index-directory)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1280 (error "Namazu directory %s not present" namazu-index-directory))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1281 (unless (executable-find mh-namazu-binary)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1282 (error "Set `mh-namazu-binary' appropriately"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1283 (set-buffer (get-buffer-create mh-temp-index-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1284 (erase-buffer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1285 (call-process mh-namazu-binary nil '(t nil) nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1286 "-alR" search-regexp namazu-index-directory)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1287 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1288 (setq mh-namazu-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1289 (let ((last (substring folder-path (1- (length folder-path)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1290 (if (equal last "/")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1291 folder-path
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1292 (format "%s/" folder-path))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1293
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1294 (defun mh-namazu-next-result ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1295 "Get the next result from namazu output."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1296 (prog1
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1297 (block nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1298 (when (eobp) (return nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1299 (let ((file-name (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1300 (point) (line-end-position))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1301 (unless (equal (string-match mh-namazu-folder file-name) 0)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1302 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1303 (unless (file-exists-p file-name)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1304 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1305 (string-match mh-user-path file-name)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1306 (let* ((folder/msg (substring file-name (match-end 0)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1307 (mark (mh-search-from-end ?/ folder/msg)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1308 (unless mark (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1309 (list (format "+%s" (substring folder/msg 0 mark))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1310 (let ((n (ignore-errors (read-from-string
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1311 (substring folder/msg (1+ mark))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1312 (if (and (consp n) (numberp (car n)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1313 (car n)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1314 (return 'error)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1315 nil))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1316 (forward-line)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1317
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1318 ;;; Pick interface
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1319
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1320 (defvar mh-index-pick-folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1321 (defvar mh-pick-binary "pick")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1322 (defconst mh-pick-single-dash '(cc date from subject to)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1323 "Search components that are supported by single-dash option in pick.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1324
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1325 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1326 (defun mh-pick-execute-search (folder-path search-regexp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1327 "Execute pick.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1328
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1329 There are no semantics associated with the search criteria--they
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1330 are simply treated as strings. Case is ignored when all lowercase
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1331 is used, and regular expressions (a la \"ed\") are available.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1332
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1333 Unlike the other index search programs, you must specify a
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1334 folder. In addition, this command does not descend into any
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1335 sub-folders that may be present.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1336
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1337 In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1338 is used to search."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1339 (set-buffer (get-buffer-create mh-temp-index-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1340 (erase-buffer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1341 (setq mh-index-pick-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1342 (concat "+" (substring folder-path (length mh-user-path))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1343 (apply #'call-process (expand-file-name "pick" mh-progs) nil '(t nil) nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1344 mh-index-pick-folder "-list" search-regexp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1345 (goto-char (point-min)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1346
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1347 (defun mh-pick-next-result ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1348 "Return the next pick search result."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1349 (prog1 (block nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1350 (when (eobp) (return nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1351 (unless (re-search-forward "^[1-9][0-9]*$" (line-end-position) t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1352 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1353 (list mh-index-pick-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1354 (car (read-from-string (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1355 (line-beginning-position)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1356 (line-end-position))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1357 nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1358 (forward-line)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1359
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1360 ;; All implementations of pick have special options -cc, -date, -from and
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1361 ;; -subject that allow to search for corresponding components. Any other
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1362 ;; component is searched using option --COMPNAME, for example: `pick
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1363 ;; --x-mailer mh-e'. Mailutils "pick" supports this option using a certain
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1364 ;; kludge, but it prefers the following syntax for this purpose:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1365 ;; "--component=COMPNAME --pattern=PATTERN".
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1366 ;; -- Sergey Poznyakoff, Aug 2003
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1367 (defun mh-pick-regexp-builder (pattern-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1368 "Generate pick search expression from PATTERN-LIST."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1369 (let ((result ()))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1370 (dolist (pattern pattern-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1371 (when (cdr pattern)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1372 (setq result `(,@result "-and" "-lbrace"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1373 ,@(mh-pick-construct-regexp
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1374 (if (and (mh-variant-p 'mu-mh) (car pattern))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1375 (format "--pattern=%s" (cdr pattern))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1376 (cdr pattern))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1377 (if (car pattern)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1378 (cond
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1379 ((mh-variant-p 'mu-mh)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1380 (format "--component=%s" (car pattern)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1381 ((member (car pattern) mh-pick-single-dash)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1382 (format "-%s" (car pattern)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1383 (t
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1384 (format "--%s" (car pattern))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1385 "-search"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1386 "-rbrace"))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1387 (cdr result)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1388
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1389 (defun mh-pick-construct-regexp (expr component)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1390 "Construct pick compatible expression corresponding to EXPR.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1391 COMPONENT is the component to search."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1392 (cond ((atom expr) (list component expr))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1393 ((eq (car expr) 'and)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1394 `("-lbrace" ,@(mh-pick-construct-regexp (cadr expr) component) "-and"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1395 ,@(mh-pick-construct-regexp (caddr expr) component) "-rbrace"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1396 ((eq (car expr) 'or)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1397 `("-lbrace" ,@(mh-pick-construct-regexp (cadr expr) component) "-or"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1398 ,@(mh-pick-construct-regexp (caddr expr) component) "-rbrace"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1399 ((eq (car expr) 'not)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1400 `("-lbrace" "-not" ,@(mh-pick-construct-regexp (cadr expr) component)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1401 "-rbrace"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1402 (t (error "Unknown operator %s seen" (car expr)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1403
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1404 ;;; Grep interface
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1405
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1406 (defvar mh-grep-binary (executable-find "grep"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1407
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1408 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1409 (defun mh-grep-execute-search (folder-path search-regexp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1410 "Execute grep and read the results.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1411
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1412 In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1413 is used to search."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1414 (set-buffer (get-buffer-create mh-temp-index-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1415 (erase-buffer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1416 (call-process mh-grep-binary nil '(t nil) nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1417 "-i" "-r" search-regexp folder-path)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1418 (goto-char (point-min)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1419
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1420 (defun mh-grep-next-result ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1421 "Read the next result.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1422 Parse it and return the message folder, message index and the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1423 match. If no other matches left then return nil. If the current
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1424 record is invalid return 'error."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1425 (prog1
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1426 (block nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1427 (when (eobp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1428 (return nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1429 (let ((eol-pos (line-end-position))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1430 (bol-pos (line-beginning-position))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1431 folder-start msg-end)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1432 (goto-char bol-pos)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1433 (unless (search-forward mh-user-path eol-pos t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1434 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1435 (setq folder-start (point))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1436 (unless (search-forward ":" eol-pos t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1437 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1438 (let ((match (buffer-substring-no-properties (point) eol-pos)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1439 (forward-char -1)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1440 (setq msg-end (point))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1441 (unless (search-backward "/" folder-start t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1442 (return 'error))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1443 (list (format "+%s" (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1444 folder-start (point)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1445 (let ((val (ignore-errors (read-from-string
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1446 (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1447 (1+ (point)) msg-end)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1448 (if (and (consp val) (integerp (car val)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1449 (car val)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1450 (return 'error)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1451 match))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1452 (forward-line)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1453
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1454
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1455
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1456 ;;; Folder support
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1457
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1458 (defun mh-index-generate-pretty-name (string)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1459 "Given STRING generate a name which is suitable for use as a folder name.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1460 White space from the beginning and end are removed. All spaces in
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1461 the name are replaced with underscores and all / are replaced
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1462 with $. If STRING is longer than 20 it is truncated too. STRING
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1463 could be a list of strings in which case they are concatenated to
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1464 construct the base name."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1465 (with-temp-buffer
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1466 (if (stringp string)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1467 (insert string)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1468 (when (car string) (insert (car string)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1469 (dolist (s (cdr string))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1470 (insert "_" s)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1471 (setq string (mh-replace-string "-lbrace" " "))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1472 (setq string (mh-replace-string "-rbrace" " "))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1473 (subst-char-in-region (point-min) (point-max) ?( ? t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1474 (subst-char-in-region (point-min) (point-max) ?) ? t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1475 (subst-char-in-region (point-min) (point-max) ?- ? t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1476 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1477 (while (and (not (eobp)) (memq (char-after) '(? ?\t ?\n ?\r ?_)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1478 (delete-char 1))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1479 (goto-char (point-max))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1480 (while (and (not (bobp)) (memq (char-before) '(? ?\t ?\n ?\r ?_)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1481 (delete-backward-char 1))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1482 (subst-char-in-region (point-min) (point-max) ? ?_ t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1483 (subst-char-in-region (point-min) (point-max) ?\t ?_ t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1484 (subst-char-in-region (point-min) (point-max) ?\n ?_ t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1485 (subst-char-in-region (point-min) (point-max) ?\r ?_ t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1486 (subst-char-in-region (point-min) (point-max) ?/ ?$ t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1487 (let ((out (truncate-string-to-width (buffer-string) 20)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1488 (cond ((eq mh-indexer 'flists)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1489 (format "%s/%s" mh-flists-results-folder mh-flists-sequence))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1490 ((equal out mh-flists-results-folder) (concat out "1"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1491 (t out)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1492
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1493 (defun mh-folder-exists-p (folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1494 "Check if FOLDER exists."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1495 (and (mh-folder-name-p folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1496 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1497 (with-temp-buffer
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1498 (mh-exec-cmd-output "folder" nil "-fast" "-nocreate" folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1499 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1500 (not (eobp))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1501
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1502 (defun mh-msg-exists-p (msg folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1503 "Check if MSG exists in FOLDER."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1504 (file-exists-p (format "%s%s/%s" mh-user-path (substring folder 1) msg)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1505
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1506 (defun mh-index-new-folder (name search-regexp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1507 "Return a folder name based on NAME for search results of SEARCH-REGEXP.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1508
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1509 If folder NAME already exists and was generated for the same
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1510 SEARCH-REGEXP then it is reused.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1511
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1512 Otherwise if the folder NAME was generated from a different
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1513 search then check if NAME<2> can be used. Otherwise try NAME<3>.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1514 This is repeated till we find a new folder name.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1515
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1516 If the folder returned doesn't exist then it is created."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1517 (unless (mh-folder-name-p name)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1518 (error "The argument should be a valid MH folder name"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1519 (let ((chosen-name
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1520 (loop for i from 1
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1521 for candidate = (if (equal i 1) name (format "%s<%s>" name i))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1522 when (or (not (mh-folder-exists-p candidate))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1523 (equal (mh-index-folder-search-regexp candidate)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1524 search-regexp))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1525 return candidate)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1526 ;; Do pending refiles/deletes...
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1527 (when (get-buffer chosen-name)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1528 (mh-process-or-undo-commands chosen-name))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1529 ;; Recreate folder...
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1530 (save-excursion (mh-exec-cmd-quiet nil "rmf" chosen-name))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1531 (mh-exec-cmd-quiet nil "folder" "-create" "-fast" chosen-name)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1532 (mh-remove-from-sub-folders-cache chosen-name)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1533 (when (boundp 'mh-speed-folder-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1534 (mh-speed-add-folder chosen-name))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1535 chosen-name))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1536
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1537 (defun mh-index-folder-search-regexp (folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1538 "If FOLDER was created by a index search, return the search regexp.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1539 Return nil if FOLDER doesn't exist or the .mhe_index file is
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1540 garbled."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1541 (ignore-errors
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1542 (with-temp-buffer
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1543 (insert-file-contents
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1544 (format "%s%s/%s" mh-user-path (substring folder 1) mh-index-data-file))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1545 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1546 (forward-list 3)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1547 (cadr (read (current-buffer))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1548
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1549
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1550
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1551 ;;; Sequence support
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1552
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1553 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1554 (defun mh-index-create-sequences ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1555 "Mirror sequences present in source folders in index folder."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1556 (let ((seq-hash (make-hash-table :test #'equal))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1557 (seq-list ()))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1558 (loop for folder being the hash-keys of mh-index-data
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1559 do (setf (gethash folder seq-hash)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1560 (mh-create-sequence-map
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1561 (mh-read-folder-sequences folder nil))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1562 (dolist (msg (mh-translate-range mh-current-folder "all"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1563 (let* ((checksum (gethash msg mh-index-msg-checksum-map))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1564 (pair (gethash checksum mh-index-checksum-origin-map))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1565 (ofolder (car pair))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1566 (omsg (cdr pair)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1567 (loop for seq in (ignore-errors
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1568 (gethash omsg (gethash ofolder seq-hash)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1569 do (if (assoc seq seq-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1570 (push msg (cdr (assoc seq seq-list)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1571 (push (list seq msg) seq-list)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1572 (loop for seq in seq-list
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1573 do (apply #'mh-exec-cmd "mark" mh-current-folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1574 "-sequence" (symbol-name (car seq)) "-add"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1575 (mapcar #'(lambda (x) (format "%s" x)) (cdr seq))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1576
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1577 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1578 (defun mh-create-sequence-map (seq-list)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1579 "Return a map from msg number to list of sequences in which it is present.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1580 SEQ-LIST is an assoc list whose keys are sequence names and whose
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1581 cdr is the list of messages in that sequence."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1582 (loop with map = (make-hash-table)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1583 for seq in seq-list
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1584 when (and (not (memq (car seq) (mh-unpropagated-sequences)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1585 (mh-valid-seq-p (car seq)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1586 do (loop for msg in (cdr seq)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1587 do (push (car seq) (gethash msg map)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1588 finally return map))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1589
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1590 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1591 (defun mh-index-add-to-sequence (seq msgs)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1592 "Add to SEQ the messages in the list MSGS.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1593 This function updates the source folder sequences. Also makes an
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1594 attempt to update the source folder buffer if we have it open."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1595 ;; Don't need to do anything for cur
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1596 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1597 (when (and (not (memq seq (mh-unpropagated-sequences)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1598 (mh-valid-seq-p seq))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1599 (let ((folders ())
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1600 (mh-speed-flists-inhibit-flag t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1601 (maphash (lambda (folder msgs)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1602 (push folder folders)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1603 ;; Add messages to sequence in source folder...
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1604 (apply #'mh-exec-cmd-quiet nil "mark" folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1605 "-add" "-nozero" "-sequence" (symbol-name seq)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1606 (mapcar (lambda (x) (format "%s" x))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1607 (mh-coalesce-msg-list msgs)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1608 ;; Update source folder buffer if we have it open...
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1609 (when (get-buffer folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1610 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1611 (set-buffer folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1612 (mh-put-msg-in-seq msgs seq))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1613 (mh-index-matching-source-msgs msgs))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1614 folders))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1615
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1616 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1617 (defun mh-index-delete-from-sequence (seq msgs)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1618 "Delete from SEQ the messages in MSGS.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1619 This function updates the source folder sequences. Also makes an
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1620 attempt to update the source folder buffer if present."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1621 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1622 (when (and (not (memq seq (mh-unpropagated-sequences)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1623 (mh-valid-seq-p seq))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1624 (let ((folders ())
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1625 (mh-speed-flists-inhibit-flag t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1626 (maphash (lambda (folder msgs)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1627 (push folder folders)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1628 ;; Remove messages from sequence in source folder...
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1629 (apply #'mh-exec-cmd-quiet nil "mark" folder
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1630 "-del" "-nozero" "-sequence" (symbol-name seq)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1631 (mapcar (lambda (x) (format "%s" x))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1632 (mh-coalesce-msg-list msgs)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1633 ;; Update source folder buffer if we have it open...
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1634 (when (get-buffer folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1635 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1636 (set-buffer folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1637 (mh-delete-msg-from-seq msgs seq t))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1638 (mh-index-matching-source-msgs msgs))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1639 folders))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1640
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1641 (defvar mh-unpropagated-sequences '(cur range subject search)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1642 "List of sequences that aren't preserved.")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1643
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1644 (defun mh-unpropagated-sequences ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1645 "Return a list of sequences that aren't propagated to the source folders.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1646 It is just the sequences in the variable
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1647 `mh-unpropagated-sequences' in addition to the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1648 Previous-Sequence (see mh-profile 5)."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1649 (if mh-previous-seq
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1650 (cons mh-previous-seq mh-unpropagated-sequences)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1651 mh-unpropagated-sequences))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1652
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1653 (defun mh-index-matching-source-msgs (msgs &optional delete-from-index-data)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1654 "Return a table of original messages and folders for messages in MSGS.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1655 If optional argument DELETE-FROM-INDEX-DATA is non-nil, then each
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1656 of the messages, whose counter-part is found in some source
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1657 folder, is removed from `mh-index-data'."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1658 (let ((table (make-hash-table :test #'equal)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1659 (dolist (msg msgs)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1660 (let* ((checksum (gethash msg mh-index-msg-checksum-map))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1661 (pair (gethash checksum mh-index-checksum-origin-map)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1662 (when (and checksum (car pair) (cdr pair)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1663 (mh-index-match-checksum (cdr pair) (car pair) checksum))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1664 (push (cdr pair) (gethash (car pair) table))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1665 (when delete-from-index-data
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1666 (remhash (cdr pair) (gethash (car pair) mh-index-data))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1667 table))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1668
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1669 (defun mh-index-match-checksum (msg folder checksum)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1670 "Check if MSG in FOLDER has X-MHE-Checksum header value of CHECKSUM."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1671 (with-temp-buffer
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1672 (mh-exec-cmd-output mh-scan-prog nil "-width" "80"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1673 "-format" "%{x-mhe-checksum}\n" folder msg)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1674 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1675 (string-equal (buffer-substring-no-properties (point) (line-end-position))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1676 checksum)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1677
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1678
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1679
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1680 ;;; Serialization of index data
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1681
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1682 (defun mh-index-write-data ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1683 "Write index data to file."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1684 (ignore-errors
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1685 (unless (eq major-mode 'mh-folder-mode)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1686 (error "Can't be called from folder in \"%s\"" major-mode))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1687 (let ((data mh-index-data)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1688 (msg-checksum-map mh-index-msg-checksum-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1689 (checksum-origin-map mh-index-checksum-origin-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1690 (previous-search mh-index-previous-search)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1691 (sequence-search-flag mh-index-sequence-search-flag)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1692 (outfile (concat buffer-file-name mh-index-data-file))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1693 (print-length nil)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1694 (print-level nil))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1695 (with-temp-file outfile
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1696 (mh-index-write-hashtable
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1697 data (lambda (x) (loop for y being the hash-keys of x collect y)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1698 (mh-index-write-hashtable msg-checksum-map #'identity)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1699 (mh-index-write-hashtable checksum-origin-map #'identity)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1700 (pp previous-search (current-buffer)) (insert "\n")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1701 (pp sequence-search-flag (current-buffer)) (insert "\n")))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1702
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1703 (defun mh-index-write-hashtable (table proc)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1704 "Write TABLE to `current-buffer'.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1705 PROC is used to serialize the values corresponding to the hash
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1706 table keys."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1707 (pp (loop for x being the hash-keys of table
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1708 collect (cons x (funcall proc (gethash x table))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1709 (current-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1710 (insert "\n"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1711
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1712 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1713 (defun mh-index-read-data ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1714 "Read index data from file."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1715 (ignore-errors
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1716 (unless (eq major-mode 'mh-folder-mode)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1717 (error "Can't be called from folder in \"%s\"" major-mode))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1718 (let ((infile (concat buffer-file-name mh-index-data-file))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1719 t1 t2 t3 t4 t5)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1720 (with-temp-buffer
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1721 (insert-file-contents-literally infile)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1722 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1723 (setq t1 (mh-index-read-hashtable
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1724 (lambda (data)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1725 (loop with table = (make-hash-table :test #'equal)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1726 for x in data do (setf (gethash x table) t)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1727 finally return table)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1728 t2 (mh-index-read-hashtable #'identity)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1729 t3 (mh-index-read-hashtable #'identity)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1730 t4 (read (current-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1731 t5 (read (current-buffer))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1732 (setq mh-index-data t1
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1733 mh-index-msg-checksum-map t2
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1734 mh-index-checksum-origin-map t3
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1735 mh-index-previous-search t4
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1736 mh-index-sequence-search-flag t5))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1737
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1738 (defun mh-index-read-hashtable (proc)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1739 "From BUFFER read a hash table serialized as a list.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1740 PROC is used to convert the value to actual data."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1741 (loop with table = (make-hash-table :test #'equal)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1742 for pair in (read (current-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1743 do (setf (gethash (car pair) table) (funcall proc (cdr pair)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1744 finally return table))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1745
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1746
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1747
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1748 ;;; Checksum routines
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1749
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1750 ;; A few different checksum programs are supported. The supported programs
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1751 ;; are:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1752 ;;
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1753 ;; 1. md5sum
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1754 ;; 2. md5
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1755 ;; 3. openssl
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1756 ;;
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1757 ;; To add support for your favorite checksum program add a clause to the cond
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1758 ;; statement in mh-checksum-choose. This should set the variable
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1759 ;; mh-checksum-cmd to the command line needed to run the checsum program and
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1760 ;; should set mh-checksum-parser to a function which returns a cons cell
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1761 ;; containing the message number and checksum string.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1762
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1763 (defvar mh-checksum-cmd)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1764 (defvar mh-checksum-parser)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1765
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1766 (defun mh-checksum-choose ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1767 "Check if a program to create a checksum is present."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1768 (unless (boundp 'mh-checksum-cmd)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1769 (let ((exec-path (append '("/sbin" "/usr/sbin") exec-path)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1770 (cond ((executable-find "md5sum")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1771 (setq mh-checksum-cmd (list (executable-find "md5sum")))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1772 (setq mh-checksum-parser #'mh-md5sum-parser))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1773 ((executable-find "openssl")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1774 (setq mh-checksum-cmd (list (executable-find "openssl") "md5"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1775 (setq mh-checksum-parser #'mh-openssl-parser))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1776 ((executable-find "md5")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1777 (setq mh-checksum-cmd (list (executable-find "md5")))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1778 (setq mh-checksum-parser #'mh-md5-parser))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1779 (t (error "No suitable checksum program"))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1780
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1781 (defun mh-md5sum-parser ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1782 "Parse md5sum output."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1783 (let ((begin (line-beginning-position))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1784 (end (line-end-position))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1785 first-space last-slash)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1786 (setq first-space (search-forward " " end t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1787 (goto-char end)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1788 (setq last-slash (search-backward "/" begin t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1789 (cond ((and first-space last-slash)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1790 (cons (car (read-from-string (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1791 (1+ last-slash) end)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1792 (buffer-substring-no-properties begin (1- first-space))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1793 (t (cons nil nil)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1794
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1795 (defun mh-openssl-parser ()
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1796 "Parse openssl output."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1797 (let ((begin (line-beginning-position))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1798 (end (line-end-position))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1799 last-space last-slash)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1800 (goto-char end)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1801 (setq last-space (search-backward " " begin t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1802 (setq last-slash (search-backward "/" begin t))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1803 (cond ((and last-slash last-space)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1804 (cons (car (read-from-string (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1805 (1+ last-slash) (1- last-space))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1806 (buffer-substring-no-properties (1+ last-space) end))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1807
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1808 (defalias 'mh-md5-parser 'mh-openssl-parser)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1809
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1810 ;;;###mh-autoload
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1811 (defun mh-index-update-maps (folder &optional origin-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1812 "Annotate all as yet unannotated messages in FOLDER with their MD5 hash.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1813 As a side effect msg -> checksum map is updated. Optional
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1814 argument ORIGIN-MAP is a hashtable which maps each message in the
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1815 index folder to the original folder and message from whence it
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1816 was copied. If present the checksum -> (origin-folder,
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1817 origin-index) map is updated too."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1818 (clrhash mh-index-msg-checksum-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1819 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1820 ;; Clear temp buffer
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1821 (set-buffer (get-buffer-create mh-temp-checksum-buffer))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1822 (erase-buffer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1823 ;; Run scan to check if any messages needs MD5 annotations at all
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1824 (with-temp-buffer
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1825 (mh-exec-cmd-output mh-scan-prog nil "-width" "80"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1826 "-format" "%(msg)\n%{x-mhe-checksum}\n"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1827 folder "all")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1828 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1829 (let (msg checksum)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1830 (while (not (eobp))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1831 (setq msg (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1832 (point) (line-end-position)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1833 (forward-line)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1834 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1835 (cond ((not (string-match "^[0-9]*$" msg)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1836 ((eolp)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1837 ;; need to compute checksum
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1838 (set-buffer mh-temp-checksum-buffer)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1839 (insert mh-user-path (substring folder 1) "/" msg "\n"))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1840 (t
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1841 ;; update maps
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1842 (setq checksum (buffer-substring-no-properties
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1843 (point) (line-end-position)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1844 (let ((msg (car (read-from-string msg))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1845 (set-buffer folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1846 (mh-index-update-single-msg msg checksum origin-map)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1847 (forward-line))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1848 ;; Run checksum program if needed
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1849 (unless (and (eobp) (bobp))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1850 (apply #'mh-xargs mh-checksum-cmd)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1851 (goto-char (point-min))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1852 (while (not (eobp))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1853 (let* ((intermediate (funcall mh-checksum-parser))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1854 (msg (car intermediate))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1855 (checksum (cdr intermediate)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1856 (when msg
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1857 ;; annotate
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1858 (mh-exec-cmd "anno" folder msg "-component" "X-MHE-Checksum"
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1859 "-nodate" "-text" checksum "-inplace")
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1860 ;; update maps
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1861 (save-excursion
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1862 (set-buffer folder)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1863 (mh-index-update-single-msg msg checksum origin-map)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1864 (forward-line)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1865 (mh-index-write-data))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1866
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1867 (defun mh-index-update-single-msg (msg checksum origin-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1868 "Update various maps for one message.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1869 MSG is a index folder message, CHECKSUM its MD5 hash and
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1870 ORIGIN-MAP, if non-nil, a hashtable containing which maps each
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1871 message in the index folder to the folder and message that it was
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1872 copied from. The function updates the hash tables
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1873 `mh-index-msg-checksum-map' and `mh-index-checksum-origin-map'.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1874
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1875 This function should only be called in the appropriate index
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1876 folder buffer."
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1877 (cond ((and origin-map (gethash checksum mh-index-checksum-origin-map))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1878 (let* ((intermediate (gethash msg origin-map))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1879 (ofolder (car intermediate))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1880 (omsg (cdr intermediate)))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1881 ;; This is most probably a duplicate. So eliminate it.
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1882 (call-process "rm" nil nil nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1883 (format "%s%s/%s" mh-user-path
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1884 (substring mh-current-folder 1) msg))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1885 (when (gethash ofolder mh-index-data)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1886 (remhash omsg (gethash ofolder mh-index-data)))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1887 (t
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1888 (setf (gethash msg mh-index-msg-checksum-map) checksum)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1889 (when origin-map
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1890 (setf (gethash checksum mh-index-checksum-origin-map)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1891 (gethash msg origin-map))))))
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1892
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1893 (provide 'mh-search)
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1894
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1895 ;; Local Variables:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1896 ;; indent-tabs-mode: nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1897 ;; sentence-end-double-space: nil
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1898 ;; End:
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1899
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1900 ;; arch-tag: 607762ad-0dff-4fe1-a27e-6c0dde0dcc47
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1901 ;;; mh-search ends here