diff lisp/mh-e/mh-index.el @ 62847:aa8c2e12ee24

Upgraded to MH-E version 7.84. See etc/MH-E-NEWS and lisp/mh-e/ChangeLog for details.
author Bill Wohler <wohler@newt.com>
date Sat, 28 May 2005 22:04:54 +0000
parents 4f4f410e6fe8
children 18a818a2ee7c 01137c1fdbe9
line wrap: on
line diff
--- a/lisp/mh-e/mh-index.el	Sat May 28 16:57:21 2005 +0000
+++ b/lisp/mh-e/mh-index.el	Sat May 28 22:04:54 2005 +0000
@@ -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 @@
 (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.
+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 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.
+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*
 
-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 \"pick\" and \"grep\" commands do not perform a recursive search on
+     the given folder.
 
-The documentation for the following functions describes how to generate the
-index for each program:
+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 @@
 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 @@
 
 (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 @@
 (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 @@
               (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 @@
 (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.
+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:
+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 .*~
+     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:
+following to \"config\":
 
-    FileRules pathname contains /home/user/Mail/scripts
+     FileRules pathname contains /home/user/Mail/scripts
 
-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 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 @@
           (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 @@
 (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 @@
 (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)\";
-
-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.
+     package conf;  # Don't remove this line!
+     $ADDRESS = 'user@localhost';
+     $ALLOW_FILE = \"[0-9]*\";
+     $EXCLUDE_PATH = \"^/home/user/Mail/(mhe-index|spam)\";
 
-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.
+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.
 
-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)