annotate lisp/mh-e/mh-search.el @ 110037:314f04d4d276

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