/[emacs]/emacs/lisp/mh-e/mh-index.el
ViewVC logotype

Diff of /emacs/lisp/mh-e/mh-index.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by ttn, Wed May 18 11:01:20 2005 UTC revision 1.10 by wohler, Sat May 28 22:04:54 2005 UTC
# Line 1  Line 1 
1  ;;; mh-index  --  MH-E interface to indexing programs  ;;; mh-index  --  MH-E interface to indexing programs
2    
3  ;; Copyright (C) 2005 Free Software Foundation, Inc.  ;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4    
5  ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>  ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>
6  ;; Maintainer: Bill Wohler <wohler@newt.com>  ;; Maintainer: Bill Wohler <wohler@newt.com>
# Line 31  Line 31 
31  ;;;        swish-e  ;;;        swish-e
32  ;;;        mairix  ;;;        mairix
33  ;;;        namazu  ;;;        namazu
34    ;;;        pick
35  ;;;        grep  ;;;        grep
36  ;;;  ;;;
37  ;;;  (2) To use this package, you first have to build an index. Please read  ;;;  (2) To use this package, you first have to build an index. Please read
# Line 352  they are concatenated to construct the b Line 353  they are concatenated to construct the b
353  (defun* mh-index-search (redo-search-flag folder search-regexp  (defun* mh-index-search (redo-search-flag folder search-regexp
354                          &optional window-config)                          &optional window-config)
355    "Perform an indexed search in an MH mail folder.    "Perform an indexed search in an MH mail folder.
356  Use a prefix argument to repeat the search, as in REDO-SEARCH-FLAG below.  Use a prefix argument to repeat the search.
357    
358  If REDO-SEARCH-FLAG is non-nil and the current folder buffer was generated by a  Unlike regular searches, the prompt for the folder to search can be `all' to
359  index search, then the search is repeated. Otherwise, FOLDER is searched with  search all folders; in addition, the search works recursively on the listed
360  SEARCH-REGEXP and the results are presented in an MH-E folder. If FOLDER is  folder. The search criteria are entered in an MH-Pick buffer as described in
361  \"+\" then mail in all folders are searched. Optional argument WINDOW-CONFIG  `mh-search-folder'.
362  stores the window configuration that will be restored after the user quits the  
363  folder containing the index search results.  To perform the search, type \\<mh-pick-mode-map>\\[mh-do-search]. Another
364    difference from the regular searches is that because the search operates on
365  Four indexing programs are supported; if none of these are present, then grep  more than one folder, the messages that are found are put in a temporary
366  is used. This function picks the first program that is available on your  sub-folder of `+mhe-index' and are displayed in an MH-Folder buffer. This
367  system. If you would prefer to use a different program, set the customization  buffer is special because it displays messages from multiple folders; each set
368  variable `mh-index-program' accordingly.  of messages from a given folder has a heading with the folder name.
369    
370  The documentation for the following functions describes how to generate the  In addition, the \\<mh-folder-mode-map>\\[mh-index-visit-folder] command can
371  index for each program:  be used to visit the folder of the message at point. Initially, only the
372    messages that matched the search criteria are displayed in the folder. While
373    the temporary buffer has its own set of message numbers, the actual messages
374    numbers are shown in the visited folder. Thus, the \\[mh-index-visit-folder]
375    command is useful to find the actual message number of an interesting message,
376    or to view surrounding messages with the \\[mh-rescan-folder] command.
377    
378    Because this folder is temporary, you'll probably get in the habit of killing
379    it when you're done with \\[mh-kill-folder].
380    
381    If you have run the \\[mh-search-folder] command, but change your mind while
382    entering the search criteria and actually want to run an indexed search, then
383    you can use the \\<mh-pick-mode-map>\\[mh-index-do-search] command in the
384    MH-Pick buffer.
385    
386    The \\<mh-folder-mode-map>\\[mh-index-search] command runs the command defined
387    by the `mh-index-program' option. The default value is \"Auto-detect\" which
388    means that MH-E will automatically choose one of \"swish++\", \"swish-e\",
389    \"mairix\", \"namazu\", \"pick\" and \"grep\" in that order. If, for example,
390    you have both \"swish++\" and \"mairix\" installed and you want to use
391    \"mairix\", then you can set this option to \"mairix\".
392    
393                                    *NOTE*
394    
395         The \"pick\" and \"grep\" commands do not perform a recursive search on
396         the given folder.
397    
398    This command uses an \"X-MHE-Checksum:\" header field to cache the MD5
399    checksum of a message. This means that if an incoming message already contains
400    an \"X-MHE-Checksum:\" field, that message might not be found by this command.
401    The following \"procmail\" recipe avoids this problem by renaming the existing
402    header field:
403    
404         :0 wf
405         | formail -R \"X-MHE-Checksum\" \"X-Old-MHE-Checksum\"
406    
407    The documentation for the following commands describe how to set up the
408    various indexing programs to use with MH-E. The \"pick\" and \"grep\" commands
409    do not require additional configuration.
410    
411      - `mh-swish++-execute-search'      - `mh-swish++-execute-search'
412      - `mh-swish-execute-search'      - `mh-swish-execute-search'
413      - `mh-mairix-execute-search'      - `mh-mairix-execute-search'
414      - `mh-namazu-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:  
   
415      - `mh-pick-execute-search'      - `mh-pick-execute-search'
416      - `mh-grep-execute-search'      - `mh-grep-execute-search'
417    
418  This and related functions use an X-MHE-Checksum header to cache the MD5  In a program, if REDO-SEARCH-FLAG is non-nil and the current folder buffer was
419  checksum of a message. This means that already present X-MHE-Checksum headers  generated by a index search, then the search is repeated. Otherwise, FOLDER is
420  in the incoming email could result in messages not being found. The following  searched with SEARCH-REGEXP and the results are presented in an MH-E folder.
421  procmail recipe should avoid this:  If FOLDER is \"+\" then mail in all folders are searched. Optional argument
422    WINDOW-CONFIG stores the window configuration that will be restored after the
423    :0 wf  user quits the folder containing the index search results."
   | formail -R \"X-MHE-Checksum\" \"Old-X-MHE-Checksum\"  
   
 This has the effect of renaming already present X-MHE-Checksum headers."  
424    (interactive    (interactive
425     (list current-prefix-arg     (list current-prefix-arg
426           (progn           (progn
# Line 998  Unlike the other index search programs \ Line 1030  Unlike the other index search programs \
1030  in the folder itself and does not descend into any sub-folders that may be  in the folder itself and does not descend into any sub-folders that may be
1031  present.  present.
1032    
1033  FOLDER-PATH is the directory containing the mails to be searched and  In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP is used
1034  SEARCH-REGEXP is the pattern that pick gets."  to search."
1035    (set-buffer (get-buffer-create mh-index-temp-buffer))    (set-buffer (get-buffer-create mh-index-temp-buffer))
1036    (erase-buffer)    (erase-buffer)
1037    (setq mh-index-pick-folder    (setq mh-index-pick-folder
# Line 1029  SEARCH-REGEXP is the pattern that pick g Line 1061  SEARCH-REGEXP is the pattern that pick g
1061    
1062  (defun mh-grep-execute-search (folder-path search-regexp)  (defun mh-grep-execute-search (folder-path search-regexp)
1063    "Execute grep and read the results.    "Execute grep and read the results.
1064  FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."  
1065    Unlike the other index search programs \"grep\" only searches messages present
1066    in the folder itself and does not descend into any sub-folders that may be
1067    present.
1068    
1069    In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP is used
1070    to search."
1071    (set-buffer (get-buffer-create mh-index-temp-buffer))    (set-buffer (get-buffer-create mh-index-temp-buffer))
1072    (erase-buffer)    (erase-buffer)
1073    (call-process mh-grep-binary nil '(t nil) nil    (call-process mh-grep-binary nil '(t nil) nil
# Line 1081  other matches left then return nil. If t Line 1119  other matches left then return nil. If t
1119  (defun mh-mairix-execute-search (folder-path search-regexp-list)  (defun mh-mairix-execute-search (folder-path search-regexp-list)
1120    "Execute mairix and read the results.    "Execute mairix and read the results.
1121    
1122  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
1123  directory.  directory.
1124    
1125  First create the directory /home/user/Mail/.mairix. Then create the file  First create the directory \"/home/user/Mail/.mairix\". Then create the file
1126  /home/user/Mail/.mairix/config with the following contents:  \"/home/user/Mail/.mairix/config\" with the following contents:
1127    
1128     # This should contain the same thing as your `mh-user-path'       base=/home/user/Mail
    base=/home/user/Mail  
1129    
1130     # List of folders that should be indexed. 3 dots at the end means there are       # List of folders that should be indexed. 3 dots at the end means there
1131     # subfolders within the folder       # are subfolders within the folder
1132     mh_folders=archive...:inbox:drafts:news:sent:trash       mh=archive...:inbox:drafts:news:sent:trash
1133    
1134     vfolder_format=raw       vfolder_format=raw
1135     database=/home/user/Mail/mairix/database       database=/home/user/Mail/mairix/database
1136    
1137  Use the following command line to generate the mairix index. Run this daily  Use the following command line to generate the mairix index. Run this daily
1138  from cron:  from cron:
1139    
1140      mairix -f /home/user/Mail/.mairix/config       mairix -f /home/user/Mail/.mairix/config
1141    
1142  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
1143    to search."
1144    (set-buffer (get-buffer-create mh-index-temp-buffer))    (set-buffer (get-buffer-create mh-index-temp-buffer))
1145    (erase-buffer)    (erase-buffer)
1146    (unless mh-mairix-binary    (unless mh-mairix-binary
1147      (error "Set mh-mairix-binary appropriately"))      (error "Set mh-mairix-binary appropriately"))
1148    (apply #'call-process mh-mairix-binary nil '(t nil) nil    (apply #'call-process mh-mairix-binary nil '(t nil) nil
1149           "-f" (format "%s%s/config" mh-user-path mh-mairix-directory)           "-r" "-f" (format "%s%s/config" mh-user-path mh-mairix-directory)
1150           search-regexp-list)           search-regexp-list)
1151    (goto-char (point-min))    (goto-char (point-min))
1152    (setq mh-mairix-folder    (setq mh-mairix-folder
# Line 1167  REGEXP-LIST is an alist of fields and va Line 1205  REGEXP-LIST is an alist of fields and va
1205                (let ((expr-list (cdr conjunct))                (let ((expr-list (cdr conjunct))
1206                      (expr-string ""))                      (expr-string ""))
1207                  (dolist (e expr-list)                  (dolist (e expr-list)
1208                    (setq expr-string (concat expr-string "+"                    (setq expr-string (concat expr-string ","
1209                                              (if (atom e) "" "~")                                              (if (atom e) "" "~")
1210                                              (if (atom e) e (cadr e)))))                                              (if (atom e) e (cadr e)))))
1211                  (setq final (concat final "," (substring expr-string 1)))))                  (setq final (concat final "/" (substring expr-string 1)))))
1212              (substring final 1)))              (substring final 1)))
1213           result)))           result)))
1214      result))      result))
# Line 1327  space-separated list of FOLDERS, or noth Line 1365  space-separated list of FOLDERS, or noth
1365  (defun mh-swish-execute-search (folder-path search-regexp)  (defun mh-swish-execute-search (folder-path search-regexp)
1366    "Execute swish-e and read the results.    "Execute swish-e and read the results.
1367    
1368  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
1369  directory.  MH directory.
1370    
1371  First create the directory /home/user/Mail/.swish. Then create the file  First create the directory \"/home/user/Mail/.swish\". Then create the file
1372  /home/user/Mail/.swish/config with the following contents:  \"/home/user/Mail/.swish/config\" with the following contents:
1373    
1374      IndexDir /home/user/Mail       DefaultContents TXT*
1375      IndexFile /home/user/Mail/.swish/index       IndexDir /home/user/Mail
1376      IndexName \"Mail Index\"       IndexFile /home/user/Mail/.swish/index
1377      IndexDescription \"Mail Index\"       IndexName \"Mail Index\"
1378      IndexPointer \"http://nowhere\"       IndexDescription \"Mail Index\"
1379      IndexAdmin \"nobody\"       IndexPointer \"http://nowhere\"
1380      #MetaNames automatic       IndexAdmin \"nobody\"
1381      IndexReport 3       #MetaNames automatic
1382      FollowSymLinks no       IndexReport 3
1383      UseStemming no       FollowSymLinks no
1384      IgnoreTotalWordCountWhenRanking yes       UseStemming no
1385      WordCharacters abcdefghijklmnopqrstuvwxyz0123456789-       IgnoreTotalWordCountWhenRanking yes
1386      BeginCharacters abcdefghijklmnopqrstuvwxyz       WordCharacters abcdefghijklmnopqrstuvwxyz0123456789-
1387      EndCharacters abcdefghijklmnopqrstuvwxyz0123456789       BeginCharacters abcdefghijklmnopqrstuvwxyz
1388      IgnoreLimit 50 1000       EndCharacters abcdefghijklmnopqrstuvwxyz0123456789
1389      IndexComments 0       IgnoreLimit 50 1000
1390      FileRules pathname contains /home/user/Mail/.swish       IndexComments 0
1391      FileRules pathname contains /home/user/Mail/mhe-index       FileRules filename contains \\D
1392      FileRules filename is index       FileRules pathname contains /home/user/Mail/.swish
1393      FileRules filename is \\..*       FileRules pathname contains /home/user/Mail/mhe-index
1394      FileRules filename is #.*  
1395      FileRules filename is ,.*  This configuration does not index the folders that hold the results of your
1396      FileRules filename is .*~  searches in \"+mhe-index\" since they tend to be ephemeral and the original
1397    messages are indexed anyway.
1398    
1399  If there are any directories you would like to ignore, append lines like the  If there are any directories you would like to ignore, append lines like the
1400  following to config:  following to \"config\":
   
     FileRules pathname contains /home/user/Mail/scripts  
1401    
1402  You do not want to index the folders that hold the results of your searches       FileRules pathname contains /home/user/Mail/scripts
 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.  
1403    
1404  Use the following command line to generate the swish index. Run this  Use the following command line to generate the swish index. Run this daily
1405  daily from cron:  from cron:
1406    
1407      swish-e -c /home/user/Mail/.swish/config           swish-e -c /home/user/Mail/.swish/config
1408    
1409  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
1410    search."
1411    (set-buffer (get-buffer-create mh-index-temp-buffer))    (set-buffer (get-buffer-create mh-index-temp-buffer))
1412    (erase-buffer)    (erase-buffer)
1413    (unless mh-swish-binary    (unless mh-swish-binary
# Line 1407  FOLDER-PATH is the directory in which SE Line 1442  FOLDER-PATH is the directory in which SE
1442            (list (let* ((s (buffer-substring-no-properties start (1+ (point)))))            (list (let* ((s (buffer-substring-no-properties start (1+ (point)))))
1443                    (unless (string-match mh-swish-folder s)                    (unless (string-match mh-swish-folder s)
1444                      (return 'error))                      (return 'error))
1445                    (if (string-match mh-user-path s)                    (if (and (string-match mh-user-path s)
1446                               (< (match-end 0) (1- (length s))))
1447                        (format "+%s"                        (format "+%s"
1448                                (substring s (match-end 0) (1- (length s))))                                (substring s (match-end 0) (1- (length s))))
1449                      (return 'error)))                      (return 'error)))
# Line 1431  FOLDER-PATH is the directory in which SE Line 1467  FOLDER-PATH is the directory in which SE
1467  (defun mh-swish++-execute-search (folder-path search-regexp)  (defun mh-swish++-execute-search (folder-path search-regexp)
1468    "Execute swish++ and read the results.    "Execute swish++ and read the results.
1469    
1470  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
1471  directory.  directory.
1472    
1473  First create the directory /home/user/Mail/.swish++. Then create the file  First create the directory \"/home/user/Mail/.swish++\". Then create the file
1474  /home/user/Mail/.swish++/swish++.conf with the following contents:  \"/home/user/Mail/.swish++/swish++.conf\" with the following contents:
1475    
1476      IncludeMeta         Bcc Cc Comments Content-Description From Keywords       IncludeMeta         Bcc Cc Comments Content-Description From Keywords
1477      IncludeMeta         Newsgroups Resent-To Subject To       IncludeMeta         Newsgroups Resent-To Subject To
1478      IncludeMeta         Message-Id References In-Reply-To       IncludeMeta         Message-Id References In-Reply-To
1479      IncludeFile         Mail    *       IncludeFile         Mail    *
1480      IndexFile           /home/user/Mail/.swish++/swish++.index       IndexFile           /home/user/Mail/.swish++/swish++.index
1481    
1482  Use the following command line to generate the swish index. Run this  Use the following command line to generate the swish index. Run this daily
1483  daily from cron:  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  
   
 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.  
1484    
1485  On some systems (Debian GNU/Linux, for example), use index++ instead of index.       find /home/user/Mail -path /home/user/Mail/mhe-index -prune \\
1486                              -o -path /home/user/Mail/.swish++ -prune \\
1487                              -o -name \"[0-9]*\" -print \\
1488             | index -c /home/user/Mail/.swish++/swish++.conf -
1489    
1490    This command does not index the folders that hold the results of your searches
1491    in \"+mhe-index\" since they tend to be ephemeral and the original messages
1492    are indexed anyway.
1493    
1494  FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."  On some systems (Debian GNU/Linux, for example), use \"index++\" instead of
1495    \"index\".
1496    
1497    In a program, FOLDER-PATH is the directory in which SEARCH-REGEXP is used to
1498    search."
1499    (set-buffer (get-buffer-create mh-index-temp-buffer))    (set-buffer (get-buffer-create mh-index-temp-buffer))
1500    (erase-buffer)    (erase-buffer)
1501    (unless mh-swish++-binary    (unless mh-swish++-binary
# Line 1512  REGEXP-LIST is an alist of fields and va Line 1549  REGEXP-LIST is an alist of fields and va
1549  (defun mh-namazu-execute-search (folder-path search-regexp)  (defun mh-namazu-execute-search (folder-path search-regexp)
1550    "Execute namazu and read the results.    "Execute namazu and read the results.
1551    
1552  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
1553  directory.  directory.
1554    
1555  First create the directory /home/user/Mail/.namazu. Then create the file  First create the directory \"/home/user/Mail/.namazu\". Then create the file
1556  /home/user/Mail/.namazu/mknmzrc with the following contents:  \"/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)\";  
1557    
1558  In the above example configuration, none of the mail files contained in the       package conf;  # Don't remove this line!
1559  directories /home/user/Mail/mhe-index and /home/user/Mail/spam are indexed.       $ADDRESS = 'user@localhost';
1560         $ALLOW_FILE = \"[0-9]*\";
1561         $EXCLUDE_PATH = \"^/home/user/Mail/(mhe-index|spam)\";
1562    
1563    This configuration does not index the folders that hold the results of your
1564    searches in \"+mhe-index\" since they tend to be ephemeral and the original
1565    messages are indexed anyway.
1566    
1567  You do not want to index the folders that hold the results of your searches  Use the following command line to generate the namazu index. Run this daily
1568  since they tend to be ephemeral and the original messages are indexed anyway.  from cron:
 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:  
1569    
1570     mknmz -f /home/user/Mail/.namazu/mknmzrc -O /home/user/Mail/.namazu \\       mknmz -f /home/user/Mail/.namazu/mknmzrc -O /home/user/Mail/.namazu \\
1571           /home/user/Mail                /home/user/Mail
1572    
1573  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
1574    search."
1575    (let ((namazu-index-directory    (let ((namazu-index-directory
1576           (format "%s%s" mh-user-path mh-namazu-directory)))           (format "%s%s" mh-user-path mh-namazu-directory)))
1577      (unless (file-exists-p namazu-index-directory)      (unless (file-exists-p namazu-index-directory)

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26