annotate lisp/mail/mh-index.el @ 49418:9ab0a4464ac9

(jka-compr-insert-file-contents): Call docode-coding-inserted-region.
author Kenichi Handa <handa@m17n.org>
date Fri, 24 Jan 2003 13:28:24 +0000
parents 30c4902b654d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1 ;;; mh-index -- MH-E interface to indexing programs
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
2
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
3 ;; Copyright (C) 2002 Free Software Foundation, Inc.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
4
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
5 ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
6 ;; Maintainer: Bill Wohler <wohler@newt.com>
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
7 ;; Keywords: mail
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
8 ;; See: mh-e.el
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
9
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
11
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
15 ;; any later version.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
16
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
21
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
26
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
27 ;;; Commentary:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
28
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
29 ;;; (1) The following search engines are supported:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
30 ;;; swish++
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
31 ;;; swish-e
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
32 ;;; namazu
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
33 ;;; glimpse
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
34 ;;; grep
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
35 ;;;
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
36 ;;; (2) To use this package, you first have to build an index. Please read
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
37 ;;; the documentation for `mh-index-search' to get started. That
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
38 ;;; documentation will direct you to the specific instructions for your
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
39 ;;; particular indexer.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
40
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
41 ;;; Change Log:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
42
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
43 ;; $Id: mh-index.el,v 1.73 2003/01/07 21:15:49 satyaki Exp $
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
44
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
45 ;;; Code:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
46
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
47 (require 'cl)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
48 (require 'mh-e)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
49 (require 'mh-mime)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
50
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
51 (autoload 'gnus-local-map-property "gnus-util")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
52 (autoload 'gnus-eval-format "gnus-spec")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
53 (autoload 'widget-convert-button "wid-edit")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
54 (autoload 'executable-find "executable")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
55
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
56 ;; Support different indexing programs
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
57 (defvar mh-indexer-choices
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
58 '((swish++
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
59 mh-swish++-binary mh-swish++-execute-search mh-swish++-next-result)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
60 (swish
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
61 mh-swish-binary mh-swish-execute-search mh-swish-next-result)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
62 (namazu
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
63 mh-namazu-binary mh-namazu-execute-search mh-namazu-next-result)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
64 (glimpse
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
65 mh-glimpse-binary mh-glimpse-execute-search mh-glimpse-next-result)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
66 (grep
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
67 mh-grep-binary mh-grep-execute-search mh-grep-next-result))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
68 "List of possible indexer choices.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
69 (defvar mh-indexer nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
70 "Chosen index program.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
71 (defvar mh-index-execute-search-function nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
72 "Function which executes the search program.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
73 (defvar mh-index-next-result-function nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
74 "Function to parse the next line of output.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
75
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
76 ;; FIXME: This should be a defcustom...
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
77 (defvar mh-index-folder "+mhe-index"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
78 "Folder that contains the folders resulting from the index searches.")
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
79
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
80 ;; Temporary buffers for search results
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
81 (defvar mh-index-temp-buffer " *mh-index-temp*")
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
82 (defvar mh-checksum-buffer " *mh-checksum-buffer*")
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
83
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
84
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
85
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
86 ;;; A few different checksum programs are supported. The supported programs
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
87 ;;; are:
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
88 ;;; 1. md5sum
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
89 ;;; 2. md5
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
90 ;;; 3. openssl
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
91 ;;;
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
92 ;;; To add support for your favorite checksum program add a clause to the cond
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
93 ;;; statement in mh-checksum-choose. This should set the variable
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
94 ;;; mh-checksum-cmd to the command line needed to run the checsum program and
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
95 ;;; should set mh-checksum-parser to a function which returns a cons cell
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
96 ;;; containing the message number and checksum string.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
97
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
98 (defvar mh-checksum-cmd)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
99 (defvar mh-checksum-parser)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
100
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
101 (defun mh-checksum-choose ()
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
102 "Check if a program to create a checksum is present."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
103 (unless (boundp 'mh-checksum-cmd)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
104 (let ((exec-path (append '("/sbin" "/usr/sbin") exec-path)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
105 (cond ((executable-find "md5sum")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
106 (setq mh-checksum-cmd (list (executable-find "md5sum")))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
107 (setq mh-checksum-parser #'mh-md5sum-parser))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
108 ((executable-find "openssl")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
109 (setq mh-checksum-cmd (list (executable-find "openssl") "md5"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
110 (setq mh-checksum-parser #'mh-openssl-parser))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
111 ((executable-find "md5")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
112 (setq mh-checksum-cmd (list (executable-find "md5")))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
113 (setq mh-checksum-parser #'mh-md5-parser))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
114 (t (error "No suitable checksum program"))))))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
115
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
116 (defun mh-md5sum-parser ()
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
117 "Parse md5sum output."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
118 (let ((begin (line-beginning-position))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
119 (end (line-end-position))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
120 first-space last-slash)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
121 (setq first-space (search-forward " " end t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
122 (goto-char end)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
123 (setq last-slash (search-backward "/" begin t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
124 (cond ((and first-space last-slash)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
125 (cons (car (read-from-string (buffer-substring-no-properties
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
126 (1+ last-slash) end)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
127 (buffer-substring-no-properties begin (1- first-space))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
128 (t (cons nil nil)))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
129
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
130 (defun mh-openssl-parser ()
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
131 "Parse openssl output."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
132 (let ((begin (line-beginning-position))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
133 (end (line-end-position))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
134 last-space last-slash)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
135 (goto-char end)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
136 (setq last-space (search-backward " " begin t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
137 (setq last-slash (search-backward "/" begin t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
138 (cond ((and last-slash last-space)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
139 (cons (car (read-from-string (buffer-substring-no-properties
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
140 (1+ last-slash) (1- last-space))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
141 (buffer-substring-no-properties (1+ last-space) end))))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
142
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
143 (defalias 'mh-md5-parser 'mh-openssl-parser)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
144
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
145
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
146
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
147 ;;; Make sure that we don't produce too long a command line.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
148
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
149 (defvar mh-index-max-cmdline-args 500
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
150 "Maximum number of command line args.")
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
151
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
152 (defun mh-index-execute (cmd &rest args)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
153 "Partial imitation of xargs.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
154 The current buffer contains a list of strings, one on each line. The function
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
155 will execute CMD with ARGS and pass the first `mh-index-max-cmdline-args'
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
156 strings to it. This is repeated till all the strings have been used."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
157 (goto-char (point-min))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
158 (let ((out (get-buffer-create " *mh-xargs-output*")))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
159 (save-excursion
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
160 (set-buffer out)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
161 (erase-buffer))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
162 (while (not (eobp))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
163 (let ((arg-list (reverse args))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
164 (count 0))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
165 (while (and (not (eobp)) (< count mh-index-max-cmdline-args))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
166 (push (buffer-substring-no-properties (point) (line-end-position))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
167 arg-list)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
168 (incf count)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
169 (forward-line))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
170 (apply #'call-process cmd nil (list out nil) nil (nreverse arg-list))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
171 (erase-buffer)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
172 (insert-buffer-substring out)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
173
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
174
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
175
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
176 (defun mh-index-update-single-msg (msg checksum origin-map)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
177 "Update various maps for one message.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
178 MSG is a index folder message, CHECKSUM its MD5 hash and ORIGIN-MAP, if
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
179 non-nil, a hashtable containing which maps each message in the index folder to
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
180 the folder and message that it was copied from. The function updates the hash
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
181 tables `mh-index-msg-checksum-map' and `mh-index-checksum-origin-map'.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
182
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
183 This function should only be called in the appropriate index folder buffer."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
184 (cond ((and origin-map (gethash checksum mh-index-checksum-origin-map))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
185 (let* ((intermediate (gethash msg origin-map))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
186 (ofolder (car intermediate))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
187 (omsg (cdr intermediate)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
188 ;; This is most probably a duplicate. So eliminate it.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
189 (call-process "rm" nil nil nil
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
190 (format "%s%s/%s" mh-user-path
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
191 (substring mh-current-folder 1) msg))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
192 (remhash omsg (gethash ofolder mh-index-data))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
193 (t
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
194 (setf (gethash msg mh-index-msg-checksum-map) checksum)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
195 (when origin-map
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
196 (setf (gethash checksum mh-index-checksum-origin-map)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
197 (gethash msg origin-map))))))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
198
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
199 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
200 (defun mh-index-update-maps (folder &optional origin-map)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
201 "Annotate all as yet unannotated messages in FOLDER with their MD5 hash.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
202 As a side effect msg -> checksum map is updated. Optional argument ORIGIN-MAP
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
203 is a hashtable which maps each message in the index folder to the original
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
204 folder and message from whence it was copied. If present the
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
205 checksum -> (origin-folder, origin-index) map is updated too."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
206 (clrhash mh-index-msg-checksum-map)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
207 (save-excursion
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
208 ;; Clear temp buffer
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
209 (set-buffer (get-buffer-create mh-checksum-buffer))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
210 (erase-buffer)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
211 ;; Run scan to check if any messages needs MD5 annotations at all
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
212 (with-temp-buffer
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
213 (mh-exec-cmd-output mh-scan-prog nil "-width" "80"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
214 "-format" "%(msg)\n%{x-mhe-checksum}\n"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
215 folder "all")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
216 (goto-char (point-min))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
217 (let (msg checksum)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
218 (while (not (eobp))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
219 (setq msg (buffer-substring-no-properties
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
220 (point) (line-end-position)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
221 (forward-line)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
222 (save-excursion
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
223 (cond ((eolp)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
224 ;; need to compute checksum
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
225 (set-buffer mh-checksum-buffer)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
226 (insert mh-user-path (substring folder 1) "/" msg "\n"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
227 (t
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
228 ;; update maps
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
229 (setq checksum (buffer-substring-no-properties
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
230 (point) (line-end-position)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
231 (let ((msg (car (read-from-string msg))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
232 (set-buffer folder)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
233 (mh-index-update-single-msg msg checksum origin-map)))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
234 (forward-line))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
235 ;; Run checksum program if needed
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
236 (unless (and (eobp) (bobp))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
237 (apply #'mh-index-execute mh-checksum-cmd)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
238 (goto-char (point-min))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
239 (while (not (eobp))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
240 (let* ((intermediate (funcall mh-checksum-parser))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
241 (msg (car intermediate))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
242 (checksum (cdr intermediate)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
243 (when msg
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
244 ;; annotate
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
245 (mh-exec-cmd "anno" folder msg "-component" "X-MHE-Checksum"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
246 "-nodate" "-text" checksum "-inplace")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
247 ;; update maps
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
248 (save-excursion
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
249 (set-buffer folder)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
250 (mh-index-update-single-msg msg checksum origin-map)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
251 (forward-line))))))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
252
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
253 (defun mh-index-generate-pretty-name (string)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
254 "Given STRING generate a name which is suitable for use as a folder name.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
255 White space from the beginning and end are removed. All spaces in the name are
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
256 replaced with underscores and all / are replaced with $. If STRING is longer
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
257 than 20 it is truncated too."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
258 (with-temp-buffer
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
259 (insert string)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
260 (goto-char (point-min))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
261 (while (and (not (eobp)) (memq (char-after) '(? ?\t ?\n ?\r)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
262 (delete-char 1))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
263 (goto-char (point-max))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
264 (while (and (not (bobp)) (memq (char-before) '(? ?\t ?\n ?\r)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
265 (delete-backward-char 1))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
266 (subst-char-in-region (point-min) (point-max) ? ?_ t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
267 (subst-char-in-region (point-min) (point-max) ?\t ?_ t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
268 (subst-char-in-region (point-min) (point-max) ?\n ?_ t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
269 (subst-char-in-region (point-min) (point-max) ?\r ?_ t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
270 (subst-char-in-region (point-min) (point-max) ?/ ?$ t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
271 (truncate-string-to-width (buffer-substring (point-min) (point-max)) 20)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
272
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
273 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
274 (defun mh-index-search (redo-search-flag folder search-regexp)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
275 "Perform an indexed search in an MH mail folder.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
276
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
277 If REDO-SEARCH-FLAG is non-nil and the current folder buffer was generated by a
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
278 index search, then the search is repeated. Otherwise, FOLDER is searched with
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
279 SEARCH-REGEXP and the results are presented in an MH-E folder. If FOLDER is
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
280 \"+\" then mail in all folders are searched.
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
281
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
282 Four indexing programs are supported; if none of these are present, then grep
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
283 is used. This function picks the first program that is available on your
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
284 system. If you would prefer to use a different program, set the customization
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
285 variable `mh-index-program' accordingly.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
286
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
287 The documentation for the following functions describes how to generate the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
288 index for each program:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
289
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
290 - `mh-swish++-execute-search'
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
291 - `mh-swish-execute-search'
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
292 - `mh-namazu-execute-search'
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
293 - `mh-glimpse-execute-search'
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
294
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
295 This and related functions use an X-MHE-Checksum header to cache the MD5
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
296 checksum of a message. This means that already present X-MHE-Checksum headers
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
297 in the incoming email could result in messages not being found. The following
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
298 procmail recipe should avoid this:
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
299
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
300 :0 wf
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
301 | formail -R \"X-MHE-Checksum\" \"Old-X-MHE-Checksum\"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
302
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
303 This has the effect of renaming already present X-MHE-Checksum headers."
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
304 (interactive
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
305 (list current-prefix-arg
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
306 (progn
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
307 (unless mh-find-path-run (mh-find-path))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
308 (or (and current-prefix-arg (car mh-index-previous-search))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
309 (mh-prompt-for-folder "Search" "+" nil "all")))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
310 (progn
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
311 ;; Yes, we do want to call mh-index-choose every time in case the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
312 ;; user has switched the indexer manually.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
313 (unless (mh-index-choose) (error "No indexing program found"))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
314 (or (and current-prefix-arg (cadr mh-index-previous-search))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
315 (read-string (format "%s regexp: "
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
316 (upcase-initials
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
317 (symbol-name mh-indexer))))))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
318 (mh-checksum-choose)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
319 (let ((result-count 0)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
320 (old-window-config mh-previous-window-config)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
321 (previous-search mh-index-previous-search)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
322 (index-folder (format "%s/%s" mh-index-folder
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
323 (mh-index-generate-pretty-name search-regexp))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
324 ;; Create a new folder for the search results or recreate the old one...
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
325 (if (and redo-search-flag mh-index-previous-search)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
326 (let ((buffer-name (buffer-name (current-buffer))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
327 (mh-process-or-undo-commands buffer-name)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
328 (save-excursion (mh-exec-cmd-quiet nil "rmf" buffer-name))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
329 (mh-exec-cmd-quiet nil "folder" "-create" "-fast" buffer-name)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
330 (setq index-folder buffer-name))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
331 (setq index-folder (mh-index-new-folder index-folder)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
332
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
333 (let ((folder-path (format "%s%s" mh-user-path (substring folder 1)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
334 (folder-results-map (make-hash-table :test #'equal))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
335 (origin-map (make-hash-table :test #'equal)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
336 ;; Run search program...
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
337 (message "Executing %s... " mh-indexer)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
338 (funcall mh-index-execute-search-function folder-path search-regexp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
339
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
340 ;; Parse indexer output
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
341 (message "Processing %s output... " mh-indexer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
342 (goto-char (point-min))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
343 (loop for next-result = (funcall mh-index-next-result-function)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
344 when (null next-result) return nil
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
345 do (unless (eq next-result 'error)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
346 (unless (gethash (car next-result) folder-results-map)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
347 (setf (gethash (car next-result) folder-results-map)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
348 (make-hash-table :test #'equal)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
349 (setf (gethash (cadr next-result)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
350 (gethash (car next-result) folder-results-map))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
351 t)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
352
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
353 ;; Copy the search results over
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
354 (maphash #'(lambda (folder msgs)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
355 (let ((msgs (sort (loop for msg being the hash-keys of msgs
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
356 collect msg)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
357 #'<)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
358 (mh-exec-cmd "refile" msgs "-src" folder
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
359 "-link" index-folder)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
360 (loop for msg in msgs
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
361 do (incf result-count)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
362 (setf (gethash result-count origin-map)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
363 (cons folder msg)))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
364 folder-results-map)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
365
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
366 ;; Generate scan lines for the hits.
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
367 (let ((mh-show-threads-flag nil))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
368 (mh-visit-folder index-folder () (list folder-results-map origin-map)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
369
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
370 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
371 (forward-line)
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
372 (mh-update-sequences)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
373 (mh-recenter nil)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
374
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
375 ;; Maintain history
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
376 (when (and redo-search-flag previous-search)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
377 (setq mh-previous-window-config old-window-config))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
378 (setq mh-index-previous-search (list folder search-regexp))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
379
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
380 (message "%s found %s matches in %s folders"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
381 (upcase-initials (symbol-name mh-indexer))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
382 (loop for msg-hash being hash-values of mh-index-data
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
383 sum (hash-table-count msg-hash))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
384 (loop for msg-hash being hash-values of mh-index-data
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
385 count (> (hash-table-count msg-hash) 0))))))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
386
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
387 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
388 (defun mh-index-next-folder (&optional backward-flag)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
389 "Jump to the next folder marker.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
390 The function is only applicable to folders displaying index search results.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
391 With non-nil optional argument BACKWARD-FLAG, jump to the previous group of
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
392 results."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
393 (interactive "P")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
394 (if (or (null mh-index-data)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
395 (memq 'unthread mh-view-ops))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
396 (message "Only applicable in an unthreaded MH-E index search buffer")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
397 (let ((point (point)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
398 (forward-line (if backward-flag -1 1))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
399 (cond ((if backward-flag
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
400 (re-search-backward "^+" (point-min) t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
401 (re-search-forward "^+" (point-max) t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
402 (beginning-of-line))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
403 ((and (if backward-flag
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
404 (goto-char (point-max))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
405 (goto-char (point-min)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
406 nil))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
407 ((if backward-flag
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
408 (re-search-backward "^+" (point-min) t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
409 (re-search-forward "^+" (point-max) t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
410 (beginning-of-line))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
411 (t (goto-char point))))))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
412
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
413 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
414 (defun mh-index-previous-folder ()
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
415 "Jump to the previous folder marker."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
416 (interactive)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
417 (mh-index-next-folder t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
418
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
419 (defun mh-folder-exists-p (folder)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
420 "Check if FOLDER exists."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
421 (and (mh-folder-name-p folder)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
422 (save-excursion
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
423 (with-temp-buffer
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
424 (mh-exec-cmd-output "folder" nil "-fast" "-nocreate" folder)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
425 (goto-char (point-min))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
426 (not (eobp))))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
427
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
428 (defun mh-msg-exists-p (msg folder)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
429 "Check if MSG exists in FOLDER."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
430 (file-exists-p (format "%s%s/%s" mh-user-path (substring folder 1) msg)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
431
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
432 (defun mh-index-new-folder (name)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
433 "Create and return an MH folder name based on NAME.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
434 If the folder NAME already exists then check if NAME<2> exists. If it doesn't
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
435 then it is created and returned. Otherwise try NAME<3>. This is repeated till
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
436 we find a new folder name."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
437 (unless (mh-folder-name-p name)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
438 (error "The argument should be a valid MH folder name"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
439 (let ((chosen-name name))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
440 (block unique-name
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
441 (unless (mh-folder-exists-p name)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
442 (return-from unique-name))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
443 (loop for index from 2
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
444 do (let ((new-name (format "%s<%s>" name index)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
445 (unless (mh-folder-exists-p new-name)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
446 (setq chosen-name new-name)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
447 (return-from unique-name)))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
448 (mh-exec-cmd-quiet nil "folder" "-create" "-fast" chosen-name)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
449 (when (boundp 'mh-speed-folder-map)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
450 (mh-speed-add-folder chosen-name))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
451 (push (list chosen-name) mh-folder-list)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
452 chosen-name))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
453
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
454 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
455 (defun mh-index-insert-folder-headers ()
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
456 "Annotate the search results with original folder names."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
457 (let ((cur-msg (mh-get-msg-num nil))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
458 (old-buffer-modified-flag (buffer-modified-p))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
459 (buffer-read-only nil)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
460 current-folder last-folder)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
461 (goto-char (point-min))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
462 (while (not (eobp))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
463 (setq current-folder (car (gethash (gethash (mh-get-msg-num nil)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
464 mh-index-msg-checksum-map)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
465 mh-index-checksum-origin-map)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
466 (when (and current-folder (not (eq current-folder last-folder)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
467 (insert (if last-folder "\n" "") current-folder "\n")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
468 (setq last-folder current-folder))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
469 (forward-line))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
470 (when cur-msg (mh-goto-msg cur-msg t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
471 (set-buffer-modified-p old-buffer-modified-flag)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
472
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
473 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
474 (defun mh-index-delete-folder-headers ()
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
475 "Delete the folder headers."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
476 (let ((cur-msg (mh-get-msg-num nil))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
477 (old-buffer-modified-flag (buffer-modified-p))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
478 (buffer-read-only nil))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
479 (goto-char (point-min))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
480 (while (not (eobp))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
481 (if (or (char-equal (char-after) ?+) (char-equal (char-after) 10))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
482 (delete-region (point) (progn (forward-line) (point)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
483 (forward-line)))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
484 (when cur-msg (mh-goto-msg cur-msg t t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
485 (set-buffer-modified-p old-buffer-modified-flag)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
486
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
487 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
488 (defun mh-index-visit-folder ()
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
489 "Visit original folder from where the message at point was found."
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
490 (interactive)
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
491 (unless mh-index-data
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
492 (error "Not in an index folder"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
493 (let (folder msg)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
494 (save-excursion
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
495 (cond ((and (bolp) (eolp))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
496 (ignore-errors (forward-line -1))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
497 (setq msg (mh-get-msg-num t)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
498 ((equal (char-after (line-beginning-position)) ?+)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
499 (setq folder (buffer-substring-no-properties
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
500 (line-beginning-position) (line-end-position))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
501 (t (setq msg (mh-get-msg-num t)))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
502 (when (not folder)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
503 (setq folder (car (gethash (gethash msg mh-index-msg-checksum-map)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
504 mh-index-checksum-origin-map))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
505 (mh-visit-folder
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
506 folder (loop for x being the hash-keys of (gethash folder mh-index-data)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
507 when (mh-msg-exists-p x folder) collect x))))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
508
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
509 (defun mh-index-match-checksum (msg folder checksum)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
510 "Check if MSG in FOLDER has X-MHE-Checksum header value of CHECKSUM."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
511 (with-temp-buffer
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
512 (mh-exec-cmd-output mh-scan-prog nil "-width" "80"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
513 "-format" "%{x-mhe-checksum}\n" folder msg)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
514 (goto-char (point-min))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
515 (string-equal (buffer-substring-no-properties (point) (line-end-position))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
516 checksum)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
517
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
518 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
519 (defun mh-index-execute-commands ()
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
520 "Delete/refile the actual messages.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
521 The copies in the searched folder are then deleted/refiled to get the desired
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
522 result. Before deleting the messages we make sure that the message being
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
523 deleted is identical to the one that the user has marked in the index buffer."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
524 (let ((message-table (make-hash-table :test #'equal)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
525 (dolist (msg-list (cons mh-delete-list (mapcar #'cdr mh-refile-list)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
526 (dolist (msg msg-list)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
527 (let* ((checksum (gethash msg mh-index-msg-checksum-map))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
528 (pair (gethash checksum mh-index-checksum-origin-map)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
529 (when (and checksum (car pair) (cdr pair)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
530 (mh-index-match-checksum (cdr pair) (car pair) checksum))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
531 (push (cdr pair) (gethash (car pair) message-table))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
532 (remhash (cdr pair) (gethash (car pair) mh-index-data))))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
533 (maphash (lambda (folder msgs)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
534 (apply #'mh-exec-cmd "rmm" folder (mh-coalesce-msg-list msgs)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
535 message-table)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
536
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
537
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
538
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
539 ;; Glimpse interface
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
540
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
541 (defvar mh-glimpse-binary (executable-find "glimpse"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
542 (defvar mh-glimpse-directory ".glimpse")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
543
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
544 ;;;###mh-autoload
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
545 (defun mh-glimpse-execute-search (folder-path search-regexp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
546 "Execute glimpse and read the results.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
547
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
548 In the examples below, replace /home/user/Mail with the path to your MH
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
549 directory.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
550
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
551 First create the directory /home/user/Mail/.glimpse. Then create the file
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
552 /home/user/Mail/.glimpse/.glimpse_exclude with the following contents:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
553
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
554 */.*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
555 */#*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
556 */,*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
557 */*~
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
558 ^/home/user/Mail/.glimpse
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
559 ^/home/user/Mail/mhe-index
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
560
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
561 If there are any directories you would like to ignore, append lines like the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
562 following to .glimpse_exclude:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
563
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
564 ^/home/user/Mail/scripts
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
565
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
566 You do not want to index the folders that hold the results of your searches
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
567 since they tend to be ephemeral and the original messages are indexed anyway.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
568 The configuration file above assumes that the results are found in sub-folders
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
569 of `mh-index-folder' which is +mhe-index by default.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
570
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
571 Use the following command line to generate the glimpse index. Run this
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
572 daily from cron:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
573
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
574 glimpseindex -H /home/user/Mail/.glimpse /home/user/Mail
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
575
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
576 FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
577 (set-buffer (get-buffer-create mh-index-temp-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
578 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
579 (call-process mh-glimpse-binary nil '(t nil) nil
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
580 ;(format "-%s" fuzz)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
581 "-i" "-y"
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
582 "-H" (format "%s%s" mh-user-path mh-glimpse-directory)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
583 "-F" (format "^%s" folder-path)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
584 search-regexp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
585 (goto-char (point-min)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
586
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
587 (defun mh-glimpse-next-result ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
588 "Read the next result.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
589 Parse it and return the message folder, message index and the match. If no
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
590 other matches left then return nil. If the current record is invalid return
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
591 'error."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
592 (prog1
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
593 (block nil
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
594 (when (eobp)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
595 (return nil))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
596 (let ((eol-pos (line-end-position))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
597 (bol-pos (line-beginning-position))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
598 folder-start msg-end)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
599 (goto-char bol-pos)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
600 (unless (search-forward mh-user-path eol-pos t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
601 (return 'error))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
602 (setq folder-start (point))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
603 (unless (search-forward ": " eol-pos t)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
604 (return 'error))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
605 (let ((match (buffer-substring-no-properties (point) eol-pos)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
606 (forward-char -2)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
607 (setq msg-end (point))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
608 (unless (search-backward "/" folder-start t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
609 (return 'error))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
610 (list (format "+%s" (buffer-substring-no-properties
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
611 folder-start (point)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
612 (let ((val (ignore-errors (read-from-string
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
613 (buffer-substring-no-properties
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
614 (1+ (point)) msg-end)))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
615 (if (and (consp val) (integerp (car val)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
616 (car val)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
617 (return 'error)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
618 match))))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
619 (forward-line)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
620
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
621
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
622
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
623 ;; Grep interface
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
624
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
625 (defvar mh-grep-binary (executable-find "grep"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
626
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
627 (defun mh-grep-execute-search (folder-path search-regexp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
628 "Execute grep and read the results.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
629 FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
630 (set-buffer (get-buffer-create mh-index-temp-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
631 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
632 (call-process mh-grep-binary nil '(t nil) nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
633 "-i" "-r" search-regexp folder-path)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
634 (goto-char (point-min)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
635
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
636 (defun mh-grep-next-result ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
637 "Read the next result.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
638 Parse it and return the message folder, message index and the match. If no
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
639 other matches left then return nil. If the current record is invalid return
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
640 'error."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
641 (prog1
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
642 (block nil
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
643 (when (eobp)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
644 (return nil))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
645 (let ((eol-pos (line-end-position))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
646 (bol-pos (line-beginning-position))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
647 folder-start msg-end)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
648 (goto-char bol-pos)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
649 (unless (search-forward mh-user-path eol-pos t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
650 (return 'error))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
651 (setq folder-start (point))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
652 (unless (search-forward ":" eol-pos t)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
653 (return 'error))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
654 (let ((match (buffer-substring-no-properties (point) eol-pos)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
655 (forward-char -1)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
656 (setq msg-end (point))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
657 (unless (search-backward "/" folder-start t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
658 (return 'error))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
659 (list (format "+%s" (buffer-substring-no-properties
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
660 folder-start (point)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
661 (let ((val (ignore-errors (read-from-string
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
662 (buffer-substring-no-properties
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
663 (1+ (point)) msg-end)))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
664 (if (and (consp val) (integerp (car val)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
665 (car val)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
666 (return 'error)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
667 match))))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
668 (forward-line)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
669
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
670
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
671
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
672 ;; Swish interface
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
673
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
674 (defvar mh-swish-binary (executable-find "swish-e"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
675 (defvar mh-swish-directory ".swish")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
676 (defvar mh-swish-folder nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
677
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
678 ;;;###mh-autoload
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
679 (defun mh-swish-execute-search (folder-path search-regexp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
680 "Execute swish-e and read the results.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
681
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
682 In the examples below, replace /home/user/Mail with the path to your MH
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
683 directory.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
684
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
685 First create the directory /home/user/Mail/.swish. Then create the file
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
686 /home/user/Mail/.swish/config with the following contents:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
687
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
688 IndexDir /home/user/Mail
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
689 IndexFile /home/user/Mail/.swish/index
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
690 IndexName \"Mail Index\"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
691 IndexDescription \"Mail Index\"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
692 IndexPointer \"http://nowhere\"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
693 IndexAdmin \"nobody\"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
694 #MetaNames automatic
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
695 IndexReport 3
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
696 FollowSymLinks no
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
697 UseStemming no
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
698 IgnoreTotalWordCountWhenRanking yes
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
699 WordCharacters abcdefghijklmnopqrstuvwxyz0123456789-
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
700 BeginCharacters abcdefghijklmnopqrstuvwxyz
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
701 EndCharacters abcdefghijklmnopqrstuvwxyz0123456789
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
702 IgnoreLimit 50 1000
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
703 IndexComments 0
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
704 FileRules pathname contains /home/user/Mail/.swish
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
705 FileRules pathname contains /home/user/Mail/mhe-index
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
706 FileRules filename is index
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
707 FileRules filename is \..*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
708 FileRules filename is #.*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
709 FileRules filename is ,.*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
710 FileRules filename is .*~
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
711
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
712 If there are any directories you would like to ignore, append lines like the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
713 following to config:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
714
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
715 FileRules pathname contains /home/user/Mail/scripts
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
716
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
717 You do not want to index the folders that hold the results of your searches
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
718 since they tend to be ephemeral and the original messages are indexed anyway.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
719 The configuration file above assumes that the results are found in sub-folders
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
720 of `mh-index-folder' which is +mhe-index by default.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
721
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
722 Use the following command line to generate the swish index. Run this
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
723 daily from cron:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
724
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
725 swish-e -c /home/user/Mail/.swish/config
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
726
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
727 FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
728 (set-buffer (get-buffer-create mh-index-temp-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
729 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
730 (unless mh-swish-binary
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
731 (error "Set mh-swish-binary appropriately"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
732 (call-process mh-swish-binary nil '(t nil) nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
733 "-w" search-regexp
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
734 "-f" (format "%s%s/index" mh-user-path mh-swish-directory))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
735 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
736 (setq mh-swish-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
737 (let ((last-char (substring folder-path (1- (length folder-path)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
738 (if (equal last-char "/")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
739 folder-path
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
740 (format "%s/" folder-path)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
741
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
742 (defun mh-swish-next-result ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
743 "Get the next result from swish output."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
744 (prog1
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
745 (block nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
746 (when (or (eobp) (equal (char-after (point)) ?.))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
747 (return nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
748 (when (equal (char-after (point)) ?#)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
749 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
750 (let* ((start (search-forward " " (line-end-position) t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
751 (end (search-forward " " (line-end-position) t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
752 (unless (and start end)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
753 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
754 (setq end (1- end))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
755 (unless (file-exists-p (buffer-substring-no-properties start end))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
756 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
757 (unless (search-backward "/" start t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
758 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
759 (list (let* ((s (buffer-substring-no-properties start (1+ (point)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
760 (unless (string-match mh-swish-folder s)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
761 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
762 (if (string-match mh-user-path s)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
763 (format "+%s"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
764 (substring s (match-end 0) (1- (length s))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
765 (return 'error)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
766 (let* ((s (buffer-substring-no-properties (1+ (point)) end))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
767 (val (ignore-errors (read-from-string s))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
768 (if (and (consp val) (numberp (car val)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
769 (car val)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
770 (return 'error)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
771 nil)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
772 (forward-line)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
773
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
774
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
775
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
776 ;; Swish++ interface
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
777
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
778 (defvar mh-swish++-binary (or (executable-find "search++")
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
779 (executable-find "search")))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
780 (defvar mh-swish++-directory ".swish++")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
781
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
782 ;;;###mh-autoload
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
783 (defun mh-swish++-execute-search (folder-path search-regexp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
784 "Execute swish++ and read the results.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
785
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
786 In the examples below, replace /home/user/Mail with the path to your MH
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
787 directory.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
788
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
789 First create the directory /home/user/Mail/.swish++. Then create the file
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
790 /home/user/Mail/.swish++/swish++.conf with the following contents:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
791
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
792 IncludeMeta Bcc Cc Comments Content-Description From Keywords
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
793 IncludeMeta Newsgroups Resent-To Subject To
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
794 IncludeMeta Message-Id References In-Reply-To
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
795 IncludeFile Mail *
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
796 IndexFile /home/user/Mail/.swish++/swish++.index
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
797
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
798 Use the following command line to generate the swish index. Run this
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
799 daily from cron:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
800
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
801 find /home/user/Mail -path /home/user/Mail/mhe-index -prune \\
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
802 -o -path /home/user/Mail/.swish++ -prune \\
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
803 -o -name \"[0-9]*\" -print \\
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
804 | index -c /home/user/Mail/.swish++/swish++.conf /home/user/Mail
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
805
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
806 You do not want to index the folders that hold the results of your searches
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
807 since they tend to be ephemeral and the original messages are indexed anyway.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
808 The command above assumes that the results are found in sub-folders of
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
809 `mh-index-folder' which is +mhe-index by default.
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
810
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
811 On some systems (Debian GNU/Linux, for example), use index++ instead of index.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
812
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
813 FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
814 (set-buffer (get-buffer-create mh-index-temp-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
815 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
816 (unless mh-swish++-binary
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
817 (error "Set mh-swish++-binary appropriately"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
818 (call-process mh-swish++-binary nil '(t nil) nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
819 "-m" "10000"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
820 (format "-i%s%s/swish++.index"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
821 mh-user-path mh-swish++-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
822 search-regexp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
823 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
824 (setq mh-swish-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
825 (let ((last-char (substring folder-path (1- (length folder-path)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
826 (if (equal last-char "/")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
827 folder-path
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
828 (format "%s/" folder-path)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
829
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
830 (defalias 'mh-swish++-next-result 'mh-swish-next-result)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
831
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
832
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
833
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
834 ;; Namazu interface
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
835
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
836 (defvar mh-namazu-binary (executable-find "namazu"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
837 (defvar mh-namazu-directory ".namazu")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
838 (defvar mh-namazu-folder nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
839
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
840 ;;;###mh-autoload
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
841 (defun mh-namazu-execute-search (folder-path search-regexp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
842 "Execute namazu and read the results.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
843
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
844 In the examples below, replace /home/user/Mail with the path to your MH
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
845 directory.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
846
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
847 First create the directory /home/user/Mail/.namazu. Then create the file
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
848 /home/user/Mail/.namazu/mknmzrc with the following contents:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
849
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
850 package conf; # Don't remove this line!
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
851 $ADDRESS = 'user@localhost';
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
852 $ALLOW_FILE = \"[0-9]*\";
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
853 $EXCLUDE_PATH = \"^/home/user/Mail/(mhe-index|spam)\";
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
854
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
855 In the above example configuration, none of the mail files contained in the
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
856 directories /home/user/Mail/mhe-index and /home/user/Mail/spam are indexed.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
857
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
858 You do not want to index the folders that hold the results of your searches
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
859 since they tend to be ephemeral and the original messages are indexed anyway.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
860 The configuration file above assumes that the results are found in sub-folders
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
861 of `mh-index-folder' which is +mhe-index by default.
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
862
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
863 Use the following command line to generate the namazu index. Run this
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
864 daily from cron:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
865
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
866 mknmz -f /home/user/Mail/.namazu/mknmzrc -O /home/user/Mail/.namazu \\
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
867 /home/user/Mail
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
868
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
869 FOLDER-PATH is the directory in which SEARCH-REGEXP is used to search."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
870 (let ((namazu-index-directory
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
871 (format "%s%s" mh-user-path mh-namazu-directory)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
872 (unless (file-exists-p namazu-index-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
873 (error "Namazu directory %s not present" namazu-index-directory))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
874 (unless (executable-find mh-namazu-binary)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
875 (error "Set mh-namazu-binary appropriately"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
876 (set-buffer (get-buffer-create mh-index-temp-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
877 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
878 (call-process mh-namazu-binary nil '(t nil) nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
879 "-alR" search-regexp namazu-index-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
880 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
881 (setq mh-namazu-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
882 (let ((last (substring folder-path (1- (length folder-path)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
883 (if (equal last "/")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
884 folder-path
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
885 (format "%s/" folder-path))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
886
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
887 (defun mh-namazu-next-result ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
888 "Get the next result from namazu output."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
889 (prog1
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
890 (block nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
891 (when (eobp) (return nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
892 (let ((file-name (buffer-substring-no-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
893 (point) (line-end-position))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
894 (unless (equal (string-match mh-namazu-folder file-name) 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
895 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
896 (unless (file-exists-p file-name)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
897 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
898 (string-match mh-user-path file-name)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
899 (let* ((folder/msg (substring file-name (match-end 0)))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
900 (mark (mh-search-from-end ?/ folder/msg)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
901 (unless mark (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
902 (list (format "+%s" (substring folder/msg 0 mark))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
903 (let ((n (ignore-errors (read-from-string
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
904 (substring folder/msg (1+ mark))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
905 (if (and (consp n) (numberp (car n)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
906 (car n)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
907 (return 'error)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
908 nil))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
909 (forward-line)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
910
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
911
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
912
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
913 (defun mh-index-choose ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
914 "Choose an indexing function.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
915 The side-effects of this function are that the variables `mh-indexer',
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
916 `mh-index-execute-search-function', and `mh-index-next-result-function' are
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
917 set according to the first indexer in `mh-indexer-choices' present on the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
918 system."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
919 (block nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
920 ;; The following favors the user's preference; otherwise, the last
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
921 ;; automatically chosen indexer is used for efficiency rather than going
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
922 ;; through the list.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
923 (let ((program-alist (cond (mh-index-program
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
924 (list
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
925 (assoc mh-index-program mh-indexer-choices)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
926 (mh-indexer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
927 (list (assoc mh-indexer mh-indexer-choices)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
928 (t mh-indexer-choices))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
929 (while program-alist
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
930 (let* ((current (pop program-alist))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
931 (executable (symbol-value (cadr current))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
932 (when executable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
933 (setq mh-indexer (car current))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
934 (setq mh-index-execute-search-function (caddr current))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
935 (setq mh-index-next-result-function (cadddr current))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
936 (return mh-indexer))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
937 nil)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
938
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
939
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
940
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
941 (provide 'mh-index)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
942
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
943 ;;; Local Variables:
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
944 ;;; indent-tabs-mode: nil
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
945 ;;; sentence-end-double-space: nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
946 ;;; End:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
947
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
948 ;;; mh-index ends here