summaryrefslogtreecommitdiff
path: root/lisp/mh-e/mh-index.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mh-e/mh-index.el')
-rw-r--r--lisp/mh-e/mh-index.el290
1 files changed, 162 insertions, 128 deletions
diff --git a/lisp/mh-e/mh-index.el b/lisp/mh-e/mh-index.el
index cde630236b0..7a52b94dd2b 100644
--- a/lisp/mh-e/mh-index.el
+++ b/lisp/mh-e/mh-index.el
@@ -1,6 +1,6 @@
;;; mh-index -- MH-E interface to indexing programs
-;; Copyright (C) 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
;; Author: Satyaki Das <satyaki@theforce.stanford.edu>
;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -31,6 +31,7 @@
;;; swish-e
;;; mairix
;;; namazu
+;;; pick
;;; grep
;;;
;;; (2) To use this package, you first have to build an index. Please read
@@ -352,43 +353,74 @@ they are concatenated to construct the base name."
(defun* mh-index-search (redo-search-flag folder search-regexp
&optional window-config)
"Perform an indexed search in an MH mail folder.
-Use a prefix argument to repeat the search, as in REDO-SEARCH-FLAG below.
-
-If REDO-SEARCH-FLAG is non-nil and the current folder buffer was generated by a
-index search, then the search is repeated. Otherwise, FOLDER is searched with
-SEARCH-REGEXP and the results are presented in an MH-E folder. If FOLDER is
-\"+\" then mail in all folders are searched. Optional argument WINDOW-CONFIG
-stores the window configuration that will be restored after the user quits the
-folder containing the index search results.
-
-Four indexing programs are supported; if none of these are present, then grep
-is used. This function picks the first program that is available on your
-system. If you would prefer to use a different program, set the customization
-variable `mh-index-program' accordingly.
-
-The documentation for the following functions describes how to generate the
-index for each program:
+Use a prefix argument to repeat the search.
+
+Unlike regular searches, the prompt for the folder to search can be `all' to
+search all folders; in addition, the search works recursively on the listed
+folder. The search criteria are entered in an MH-Pick buffer as described in
+`mh-search-folder'.
+
+To perform the search, type \\<mh-pick-mode-map>\\[mh-do-search]. Another
+difference from the regular searches is that because the search operates on
+more than one folder, the messages that are found are put in a temporary
+sub-folder of `+mhe-index' and are displayed in an MH-Folder buffer. This
+buffer is special because it displays messages from multiple folders; each set
+of messages from a given folder has a heading with the folder name.
+
+In addition, the \\<mh-folder-mode-map>\\[mh-index-visit-folder] command can
+be used to visit the folder of the message at point. Initially, only the
+messages that matched the search criteria are displayed in the folder. While
+the temporary buffer has its own set of message numbers, the actual messages
+numbers are shown in the visited folder. Thus, the \\[mh-index-visit-folder]
+command is useful to find the actual message number of an interesting message,
+or to view surrounding messages with the \\[mh-rescan-folder] command.
+
+Because this folder is temporary, you'll probably get in the habit of killing
+it when you're done with \\[mh-kill-folder].
+
+If you have run the \\[mh-search-folder] command, but change your mind while
+entering the search criteria and actually want to run an indexed search, then
+you can use the \\<mh-pick-mode-map>\\[mh-index-do-search] command in the
+MH-Pick buffer.
+
+The \\<mh-folder-mode-map>\\[mh-index-search] command runs the command defined
+by the `mh-index-program' option. The default value is \"Auto-detect\" which
+means that MH-E will automatically choose one of \"swish++\", \"swish-e\",
+\"mairix\", \"namazu\", \"pick\" and \"grep\" in that order. If, for example,
+you have both \"swish++\" and \"mairix\" installed and you want to use
+\"mairix\", then you can set this option to \"mairix\".
+
+ *NOTE*
+
+ The \"pick\" and \"grep\" commands do not perform a recursive search on
+ the given folder.
+
+This command uses an \"X-MHE-Checksum:\" header field to cache the MD5
+checksum of a message. This means that if an incoming message already contains
+an \"X-MHE-Checksum:\" field, that message might not be found by this command.
+The following \"procmail\" recipe avoids this problem by renaming the existing
+header field:
+
+ :0 wf
+ | formail -R \"X-MHE-Checksum\" \"X-Old-MHE-Checksum\"
+
+The documentation for the following commands describe how to set up the
+various indexing programs to use with MH-E. The \"pick\" and \"grep\" commands
+do not require additional configuration.
- `mh-swish++-execute-search'
- `mh-swish-execute-search'
- `mh-mairix-execute-search'
- `mh-namazu-execute-search'
-
-If none of these programs are present then we use pick. If desired grep can be
-used instead. Details about these methods can be found in:
-
- `mh-pick-execute-search'
- `mh-grep-execute-search'
-This and related functions use an X-MHE-Checksum header to cache the MD5
-checksum of a message. This means that already present X-MHE-Checksum headers
-in the incoming email could result in messages not being found. The following
-procmail recipe should avoid this:
-
- :0 wf
- | formail -R \"X-MHE-Checksum\" \"Old-X-MHE-Checksum\"
-
-This has the effect of renaming already present X-MHE-Checksum headers."
+In a program, if REDO-SEARCH-FLAG is non-nil and the current folder buffer was
+generated by a index search, then the search is repeated. Otherwise, FOLDER is
+searched with SEARCH-REGEXP and the results are presented in an MH-E folder.
+If FOLDER is \"+\" then mail in all folders are searched. Optional argument
+WINDOW-CONFIG stores the window configuration that will be restored after the
+user quits the folder containing the index search results."
(interactive
(list current-prefix-arg
(progn
@@ -998,8 +1030,8 @@ Unlike the other index search programs \"pick\" only searches messages present
in the folder itself and does not descend into any sub-folders that may be
present.
-FOLDER-PATH is the directory containing the mails to be searched and
-SEARCH-REGEXP is the pattern that pick gets."
+In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP is used
+to search."
(set-buffer (get-buffer-create mh-index-temp-buffer))
(erase-buffer)
(setq mh-index-pick-folder
@@ -1029,7 +1061,13 @@ SEARCH-REGEXP is the pattern that pick gets."
(defun mh-grep-execute-search (folder-path search-regexp)
"Execute grep and read the results.
-FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
+
+Unlike the other index search programs \"grep\" only searches messages present
+in the folder itself and does not descend into any sub-folders that may be
+present.
+
+In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP is used
+to search."
(set-buffer (get-buffer-create mh-index-temp-buffer))
(erase-buffer)
(call-process mh-grep-binary nil '(t nil) nil
@@ -1081,34 +1119,34 @@ other matches left then return nil. If the current record is invalid return
(defun mh-mairix-execute-search (folder-path search-regexp-list)
"Execute mairix and read the results.
-In the examples below replace /home/user/Mail with the path to your MH
+In the examples below, replace \"/home/user/Mail\" with the path to your MH
directory.
-First create the directory /home/user/Mail/.mairix. Then create the file
-/home/user/Mail/.mairix/config with the following contents:
+First create the directory \"/home/user/Mail/.mairix\". Then create the file
+\"/home/user/Mail/.mairix/config\" with the following contents:
- # This should contain the same thing as your `mh-user-path'
- base=/home/user/Mail
+ base=/home/user/Mail
- # List of folders that should be indexed. 3 dots at the end means there are
- # subfolders within the folder
- mh_folders=archive...:inbox:drafts:news:sent:trash
+ # List of folders that should be indexed. 3 dots at the end means there
+ # are subfolders within the folder
+ mh=archive...:inbox:drafts:news:sent:trash
- vfolder_format=raw
- database=/home/user/Mail/mairix/database
+ vfolder_format=raw
+ database=/home/user/Mail/mairix/database
Use the following command line to generate the mairix index. Run this daily
from cron:
- mairix -f /home/user/Mail/.mairix/config
+ mairix -f /home/user/Mail/.mairix/config
-FOLDER-PATH is the directory in which SEARCH-REGEXP-LIST is used to search."
+In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP-LIST is used
+to search."
(set-buffer (get-buffer-create mh-index-temp-buffer))
(erase-buffer)
(unless mh-mairix-binary
(error "Set mh-mairix-binary appropriately"))
(apply #'call-process mh-mairix-binary nil '(t nil) nil
- "-f" (format "%s%s/config" mh-user-path mh-mairix-directory)
+ "-r" "-f" (format "%s%s/config" mh-user-path mh-mairix-directory)
search-regexp-list)
(goto-char (point-min))
(setq mh-mairix-folder
@@ -1167,10 +1205,10 @@ REGEXP-LIST is an alist of fields and values."
(let ((expr-list (cdr conjunct))
(expr-string ""))
(dolist (e expr-list)
- (setq expr-string (concat expr-string "+"
+ (setq expr-string (concat expr-string ","
(if (atom e) "" "~")
(if (atom e) e (cadr e)))))
- (setq final (concat final "," (substring expr-string 1)))))
+ (setq final (concat final "/" (substring expr-string 1)))))
(substring final 1)))
result)))
result))
@@ -1327,52 +1365,49 @@ space-separated list of FOLDERS, or nothing to search all folders."
(defun mh-swish-execute-search (folder-path search-regexp)
"Execute swish-e and read the results.
-In the examples below, replace /home/user/Mail with the path to your MH
-directory.
-
-First create the directory /home/user/Mail/.swish. Then create the file
-/home/user/Mail/.swish/config with the following contents:
-
- IndexDir /home/user/Mail
- IndexFile /home/user/Mail/.swish/index
- IndexName \"Mail Index\"
- IndexDescription \"Mail Index\"
- IndexPointer \"http://nowhere\"
- IndexAdmin \"nobody\"
- #MetaNames automatic
- IndexReport 3
- FollowSymLinks no
- UseStemming no
- IgnoreTotalWordCountWhenRanking yes
- WordCharacters abcdefghijklmnopqrstuvwxyz0123456789-
- BeginCharacters abcdefghijklmnopqrstuvwxyz
- EndCharacters abcdefghijklmnopqrstuvwxyz0123456789
- IgnoreLimit 50 1000
- IndexComments 0
- FileRules pathname contains /home/user/Mail/.swish
- FileRules pathname contains /home/user/Mail/mhe-index
- FileRules filename is index
- FileRules filename is \\..*
- FileRules filename is #.*
- FileRules filename is ,.*
- FileRules filename is .*~
+In the examples below, replace \"/home/user/Mail\" with the path to your
+MH directory.
+
+First create the directory \"/home/user/Mail/.swish\". Then create the file
+\"/home/user/Mail/.swish/config\" with the following contents:
+
+ DefaultContents TXT*
+ IndexDir /home/user/Mail
+ IndexFile /home/user/Mail/.swish/index
+ IndexName \"Mail Index\"
+ IndexDescription \"Mail Index\"
+ IndexPointer \"http://nowhere\"
+ IndexAdmin \"nobody\"
+ #MetaNames automatic
+ IndexReport 3
+ FollowSymLinks no
+ UseStemming no
+ IgnoreTotalWordCountWhenRanking yes
+ WordCharacters abcdefghijklmnopqrstuvwxyz0123456789-
+ BeginCharacters abcdefghijklmnopqrstuvwxyz
+ EndCharacters abcdefghijklmnopqrstuvwxyz0123456789
+ IgnoreLimit 50 1000
+ IndexComments 0
+ FileRules filename contains \\D
+ FileRules pathname contains /home/user/Mail/.swish
+ FileRules pathname contains /home/user/Mail/mhe-index
+
+This configuration does not index the folders that hold the results of your
+searches in \"+mhe-index\" since they tend to be ephemeral and the original
+messages are indexed anyway.
If there are any directories you would like to ignore, append lines like the
-following to config:
-
- FileRules pathname contains /home/user/Mail/scripts
+following to \"config\":
-You do not want to index the folders that hold the results of your searches
-since they tend to be ephemeral and the original messages are indexed anyway.
-The configuration file above assumes that the results are found in sub-folders
-of `mh-index-folder' which is +mhe-index by default.
+ FileRules pathname contains /home/user/Mail/scripts
-Use the following command line to generate the swish index. Run this
-daily from cron:
+Use the following command line to generate the swish index. Run this daily
+from cron:
- swish-e -c /home/user/Mail/.swish/config
+ swish-e -c /home/user/Mail/.swish/config
-FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
+In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP is used to
+search."
(set-buffer (get-buffer-create mh-index-temp-buffer))
(erase-buffer)
(unless mh-swish-binary
@@ -1407,7 +1442,8 @@ FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
(list (let* ((s (buffer-substring-no-properties start (1+ (point)))))
(unless (string-match mh-swish-folder s)
(return 'error))
- (if (string-match mh-user-path s)
+ (if (and (string-match mh-user-path s)
+ (< (match-end 0) (1- (length s))))
(format "+%s"
(substring s (match-end 0) (1- (length s))))
(return 'error)))
@@ -1431,34 +1467,35 @@ FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
(defun mh-swish++-execute-search (folder-path search-regexp)
"Execute swish++ and read the results.
-In the examples below, replace /home/user/Mail with the path to your MH
+In the examples below, replace \"/home/user/Mail\" with the path to your MH
directory.
-First create the directory /home/user/Mail/.swish++. Then create the file
-/home/user/Mail/.swish++/swish++.conf with the following contents:
+First create the directory \"/home/user/Mail/.swish++\". Then create the file
+\"/home/user/Mail/.swish++/swish++.conf\" with the following contents:
- IncludeMeta Bcc Cc Comments Content-Description From Keywords
- IncludeMeta Newsgroups Resent-To Subject To
- IncludeMeta Message-Id References In-Reply-To
- IncludeFile Mail *
- IndexFile /home/user/Mail/.swish++/swish++.index
+ IncludeMeta Bcc Cc Comments Content-Description From Keywords
+ IncludeMeta Newsgroups Resent-To Subject To
+ IncludeMeta Message-Id References In-Reply-To
+ IncludeFile Mail *
+ IndexFile /home/user/Mail/.swish++/swish++.index
-Use the following command line to generate the swish index. Run this
-daily from cron:
+Use the following command line to generate the swish index. Run this daily
+from cron:
- find /home/user/Mail -path /home/user/Mail/mhe-index -prune \\
- -o -path /home/user/Mail/.swish++ -prune \\
- -o -name \"[0-9]*\" -print \\
- | index -c /home/user/Mail/.swish++/swish++.conf /home/user/Mail
+ find /home/user/Mail -path /home/user/Mail/mhe-index -prune \\
+ -o -path /home/user/Mail/.swish++ -prune \\
+ -o -name \"[0-9]*\" -print \\
+ | index -c /home/user/Mail/.swish++/swish++.conf -
-You do not want to index the folders that hold the results of your searches
-since they tend to be ephemeral and the original messages are indexed anyway.
-The command above assumes that the results are found in sub-folders of
-`mh-index-folder' which is +mhe-index by default.
+This command does not index the folders that hold the results of your searches
+in \"+mhe-index\" since they tend to be ephemeral and the original messages
+are indexed anyway.
-On some systems (Debian GNU/Linux, for example), use index++ instead of index.
+On some systems (Debian GNU/Linux, for example), use \"index++\" instead of
+\"index\".
-FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
+In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP is used to
+search."
(set-buffer (get-buffer-create mh-index-temp-buffer))
(erase-buffer)
(unless mh-swish++-binary
@@ -1512,32 +1549,29 @@ REGEXP-LIST is an alist of fields and values."
(defun mh-namazu-execute-search (folder-path search-regexp)
"Execute namazu and read the results.
-In the examples below, replace /home/user/Mail with the path to your MH
+In the examples below, replace \"/home/user/Mail\" with the path to your MH
directory.
-First create the directory /home/user/Mail/.namazu. Then create the file
-/home/user/Mail/.namazu/mknmzrc with the following contents:
+First create the directory \"/home/user/Mail/.namazu\". Then create the file
+\"/home/user/Mail/.namazu/mknmzrc\" with the following contents:
- package conf; # Don't remove this line!
- $ADDRESS = 'user@localhost';
- $ALLOW_FILE = \"[0-9]*\";
- $EXCLUDE_PATH = \"^/home/user/Mail/(mhe-index|spam)\";
+ package conf; # Don't remove this line!
+ $ADDRESS = 'user@localhost';
+ $ALLOW_FILE = \"[0-9]*\";
+ $EXCLUDE_PATH = \"^/home/user/Mail/(mhe-index|spam)\";
-In the above example configuration, none of the mail files contained in the
-directories /home/user/Mail/mhe-index and /home/user/Mail/spam are indexed.
+This configuration does not index the folders that hold the results of your
+searches in \"+mhe-index\" since they tend to be ephemeral and the original
+messages are indexed anyway.
-You do not want to index the folders that hold the results of your searches
-since they tend to be ephemeral and the original messages are indexed anyway.
-The configuration file above assumes that the results are found in sub-folders
-of `mh-index-folder' which is +mhe-index by default.
-
-Use the following command line to generate the namazu index. Run this
-daily from cron:
+Use the following command line to generate the namazu index. Run this daily
+from cron:
- mknmz -f /home/user/Mail/.namazu/mknmzrc -O /home/user/Mail/.namazu \\
- /home/user/Mail
+ mknmz -f /home/user/Mail/.namazu/mknmzrc -O /home/user/Mail/.namazu \\
+ /home/user/Mail
-FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
+In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP is used to
+search."
(let ((namazu-index-directory
(format "%s%s" mh-user-path mh-namazu-directory)))
(unless (file-exists-p namazu-index-directory)