annotate lisp/mail/mh-index.el @ 48777:f6687dde33ff

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Mon, 09 Dec 2002 20:24:40 +0000
parents 8aaba207e44b
children 30c4902b654d
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
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
5 ;; Author: Bill Wohler <wohler@newt.com>
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 ;;; (3) Right now only viewing messages and moving between messages works in
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
42 ;;; the index buffer. With a little bit of work more stuff like
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
43 ;;; replying or forwarding messages can be done.
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 ;;; Change Log:
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 ;; $Id: mh-index.el,v 1.51 2002/11/13 18:43:57 satyaki Exp $
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
48
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
49 ;;; Code:
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 (require 'cl)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
52 (require 'mh-e)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
53 (require 'mh-mime)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
54
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
55 ;; Shush the byte-compiler
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
56 (defvar font-lock-defaults)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
57
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
58 (autoload 'gnus-local-map-property "gnus-util")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
59 (autoload 'gnus-eval-format "gnus-spec")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
60 (autoload 'widget-convert-button "wid-edit")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
61 (autoload 'executable-find "executable")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
62
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
63 ;;; User customizable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
64 (defcustom mh-index-program nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
65 "Indexing program that MH-E shall use.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
66 The possible choices are swish++, swish-e, namazu, glimpse and grep. By
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
67 default this variable is nil which means that the programs are tried in order
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
68 and the first one found is used."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
69 :group 'mh
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
70 :type '(choice (const :tag "auto-detect" nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
71 (const :tag "swish++" swish++)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
72 (const :tag "swish-e" swish)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
73 (const :tag "namazu" namazu)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
74 (const :tag "glimpse" glimpse)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
75 (const :tag "grep" grep)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
76
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
77 ;;; Hooks
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
78 (defcustom mh-index-show-hook nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
79 "Invoked after the message has been displayed."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
80 :type 'hook
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
81 :group 'mh-hook)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
82
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
83 ;; Support different indexing programs
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
84 (defvar mh-indexer-choices
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
85 '((swish++
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
86 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
87 (swish
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
88 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
89 (namazu
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
90 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
91 (glimpse
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
92 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
93 (grep
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
94 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
95 "List of possible indexer choices.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
96 (defvar mh-indexer nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
97 "Chosen index program.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
98 (defvar mh-index-execute-search-function nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
99 "Function which executes the search program.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
100 (defvar mh-index-next-result-function nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
101 "Function to parse the next line of output.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
102
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
103 ;; Names for the default mh-index-buffers...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
104 (defvar mh-index-buffer "*mh-index*")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
105 (defvar mh-index-show-buffer "*mh-index-show*")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
106
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
107 ;; For use with adaptive size setting...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
108 (defvar mh-index-max-msg-index 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
109
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
110 ;; Buffer locals to allow multiple concurrent search folders.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
111 (defvar mh-index-other-buffer nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
112 "Keeps track of other buffer associated with current buffer.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
113 The value is the show buffer or the folder-buffer depending on whether we are
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
114 in a folder buffer or show buffer respectively.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
115 (defvar mh-index-matches nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
116 "Map of folder to messages which match.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
117 (defvar mh-index-previous-window-configuration nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
118 "Keep track of previous window configuration that is restored on exit.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
119 (defvar mh-index-current-msg nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
120 "Message index of message being shown.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
121
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
122 ;; Make variables buffer local ...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
123 (make-variable-buffer-local 'mh-index-other-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
124 (make-variable-buffer-local 'mh-index-matches)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
125 (make-variable-buffer-local 'mh-index-previous-window-configuration)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
126 (make-variable-buffer-local 'mh-current-folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
127 (make-variable-buffer-local 'mh-index-current-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
128
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
129 ;; ... and arrange for them to not get slaughtered by a call to text-mode
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
130 ;; (text-mode is called by mh-show-mode and mh-folder-mode).
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
131 (put 'mh-index-other-buffer 'permanent-local t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
132 (put 'mh-index-matches 'permanent-local t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
133 (put 'mh-index-previous-window-configuration 'permanent-local t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
134 (put 'mh-index-current-msg 'permanent-local t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
135 (put 'mh-current-folder 'permanent-local t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
136 (put 'mh-cmd-note 'permanent-local t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
137
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
138 ;; Temporary buffer where search results are output.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
139 (defvar mh-index-temp-buffer " *mh-index-temp*")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
140
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
141 ;; Keymaps
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
142
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
143 ;; N.B. If this map were named mh-index-folder-mode-map, it would inherit the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
144 ;; keymap from mh-folder-mode. Since we want our own keymap, we tweak the name
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
145 ;; to avoid this unwanted inheritance.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
146 (defvar mh-index-folder-mode-keymap (make-sparse-keymap)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
147 "Keymap for MH index folder.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
148 (suppress-keymap mh-index-folder-mode-keymap)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
149 (gnus-define-keys mh-index-folder-mode-keymap
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
150 " " mh-index-page-msg
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
151 "," mh-index-header-display
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
152 "." mh-index-show
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
153 [mouse-2] mh-index-show
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
154 "?" mh-help
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
155 "\177" mh-index-previous-page
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
156 "\M-\t" mh-index-prev-button
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
157 [backtab] mh-index-prev-button
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
158 "\r" mh-index-show
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
159 "\t" mh-index-next-button
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
160 "i" mh-inc-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
161 "m" mh-send ;alias
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
162 "n" mh-index-next
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
163 "p" mh-index-prev
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
164 "q" mh-index-quit
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
165 "s" mh-send)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
166
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
167 (gnus-define-keys (mh-index-folder-map "F" mh-index-folder-mode-keymap)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
168 "?" mh-prefix-help
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
169 "f" mh-visit-folder ;alias
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
170 "i" mh-index-search-again
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
171 "o" mh-visit-folder ;alias
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
172 "v" mh-visit-folder)
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 (defvar mh-index-button-map (make-sparse-keymap))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
175 (gnus-define-keys mh-index-button-map
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
176 "\r" mh-index-press-button)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
177
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
178
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
179
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
180 ;;; Help Messages
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
181
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
182 ;;; If you add a new prefix, add appropriate text to the nil key.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
183 ;;;
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
184 ;;; In general, messages are grouped logically. Taking the main commands for
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
185 ;;; example, the first line is "ways to view messages," the second line is
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
186 ;;; "things you can do with messages", and the third is "composing" messages.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
187 ;;;
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
188 ;;; When adding a new prefix, ensure that the help message contains "what" the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
189 ;;; prefix is for. For example, if the word "folder" were not present in the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
190 ;;; `F' entry, it would not be clear what these commands operated upon.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
191 (defvar mh-index-folder-mode-help-messages
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
192 '((nil "[i]nc, [.]show, [,]show all, [n]ext, [p]revious,\n"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
193 "[s]end, [q]uit")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
194 (?F "[v]isit folder; [i]ndexed search"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
195 "Key binding cheat sheet.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
196
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
197 This is an associative array which is used to show the most common commands.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
198 The key is a prefix char. The value is one or more strings which are
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
199 concatenated together and displayed in the minibuffer if ? is pressed after
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
200 the prefix character. The special key nil is used to display the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
201 non-prefixed commands.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
202
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
203 The substitutions described in `substitute-command-keys' are performed as
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
204 well.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
205
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
206
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
207
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
208 (defun mh-index-search (folder search-regexp &optional new-buffer-flag)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
209 "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
210
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
211 FOLDER is searched with SEARCH-REGEXP and the results are presented in an MH-E
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
212 folder. If FOLDER is \"+\" then mail in all folders are searched. Optional
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
213 prefix argument NEW-BUFFER-FLAG decides whether the results are presented in a
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
214 new buffer. This allows multiple search results to coexist.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
215
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
216 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
217 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
218 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
219 variable `mh-index-program' accordingly.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
220
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
221 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
222 index for each program:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
223
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
224 - `mh-swish++-execute-search'
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
225 - `mh-swish-execute-search'
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
226 - `mh-namazu-execute-search'
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
227 - `mh-glimpse-execute-search'"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
228 (interactive
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
229 (list (progn
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
230 (unless mh-find-path-run (mh-find-path))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
231 (mh-prompt-for-folder "Search" "+" nil "all"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
232 (progn
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
233 ;; 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
234 ;; user has switched the indexer manually.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
235 (unless (mh-index-choose) (error "No indexing program found"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
236 (read-string (format "%s regexp: "
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
237 (upcase-initials (symbol-name mh-indexer)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
238 current-prefix-arg))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
239 (setq mh-index-max-msg-index 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
240 (let ((config (current-window-configuration))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
241 (mh-index-buffer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
242 (cond (new-buffer-flag
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
243 (buffer-name (generate-new-buffer mh-index-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
244 ((and (eq major-mode 'mh-index-folder-mode))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
245 (buffer-name (current-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
246 (t mh-index-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
247 (mh-index-show-buffer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
248 (cond (new-buffer-flag
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
249 (buffer-name (generate-new-buffer mh-index-show-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
250 ((eq major-mode 'mh-index-folder-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
251 mh-index-other-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
252 (t mh-index-show-buffer))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
253 (when (buffer-live-p (get-buffer mh-index-show-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
254 (kill-buffer (get-buffer mh-index-show-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
255 (get-buffer-create mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
256 (get-buffer-create mh-index-show-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
257 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
258 (set-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
259 (setq mh-index-other-buffer mh-index-show-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
260 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
261 (set-buffer mh-index-show-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
262 (setq mh-index-other-buffer mh-index-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
263 (set-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
264 (setq buffer-read-only nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
265 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
266 (let* ((folder-path (format "%s%s" mh-user-path (substring folder 1)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
267 (count 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
268 (folder-count 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
269 cur-folder last-folder cur-index last-index
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
270 parse-results button-start button-end)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
271 (setq mh-index-matches (make-hash-table :test #'equal))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
272
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
273 ;; Run search program...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
274 (message "%s searching... " (upcase-initials (symbol-name mh-indexer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
275 (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
276
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
277 ;; Parse output and generate folder view
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
278 (message "Processing %s output... " mh-indexer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
279 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
280 (while (setq parse-results (funcall mh-index-next-result-function))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
281 (unless (eq parse-results 'error)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
282 (setq cur-folder (car parse-results)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
283 cur-index (cadr parse-results))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
284 (setq mh-index-max-msg-index (max mh-index-max-msg-index cur-index))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
285 (cond ((and (equal cur-folder last-folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
286 (= cur-index last-index))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
287 nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
288 ((equal cur-folder last-folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
289 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
290 (set-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
291 (push cur-index (gethash cur-folder mh-index-matches))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
292 (t
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
293 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
294 (set-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
295 (unless (gethash cur-folder mh-index-matches)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
296 (setq button-start (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
297 (gnus-eval-format "%T\n" '((?T cur-folder ?s))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
298 `(,@(gnus-local-map-property
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
299 mh-index-button-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
300 mh-callback mh-index-callback
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
301 mh-data ,cur-folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
302 (setq button-end (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
303 (widget-convert-button
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
304 'link button-start button-end
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
305 :button-keymap mh-index-button-map
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
306 :action 'mh-index-callback)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
307 (insert "\n"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
308 (push cur-index (gethash cur-folder mh-index-matches)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
309 (setq last-folder cur-folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
310 (setq last-index cur-index)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
311
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
312 ;; Get rid of extra line at end of the buffer if there were any hits.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
313 (set-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
314 (goto-char (point-max))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
315 (when (and (= (forward-line -1) 0) (bolp) (eolp))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
316 (delete-char 1))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
317
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
318 ;; Set mh-cmd-note to a large enough value...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
319 (when mh-adaptive-cmd-note-flag
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
320 (mh-set-cmd-note (mh-index-find-max-width mh-index-max-msg-index)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
321
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
322 ;; Generate scan lines for the hits.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
323 (message "Generating scan lines... ")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
324 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
325 (while (not (eobp))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
326 (let ((folder (get-text-property (point) 'mh-data)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
327 (when folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
328 (incf folder-count)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
329 (forward-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
330 (incf count (mh-index-insert-scan folder))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
331 (forward-line))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
332
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
333 ;; Go to the first hit (if any).
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
334 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
335 (forward-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
336
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
337 ;; Remember old window configuration
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
338 (setq mh-index-previous-window-configuration config)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
339
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
340 ;; Setup folder buffer mode
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
341 (when mh-decode-mime-flag
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
342 (add-hook 'kill-buffer-hook 'mh-mime-cleanup))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
343 (mh-index-folder-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
344 (setq mh-show-buffer mh-index-show-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
345 (setq buffer-read-only t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
346 (set-buffer-modified-p nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
347 (mh-index-configure-one-window)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
348 (setq mh-current-folder nil mh-index-current-msg nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
349 (message "%s found %s matches in %s folders"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
350 (upcase-initials (symbol-name mh-indexer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
351 count folder-count))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
352
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
353 (defun mh-index-find-max-width (max-index)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
354 "Given MAX-INDEX find the number of digits necessary to print it."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
355 (let ((result 1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
356 (max-int 9))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
357 (while (< max-int max-index)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
358 (incf result)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
359 (setq max-int (+ (* 10 max-int) 9)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
360 result))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
361
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
362 (defun mh-index-search-again ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
363 "Call `mh-index-search' from index search buffer."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
364 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
365 (cond ((eq major-mode 'mh-index-show-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
366 (set-buffer mh-index-other-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
367 ((not (eq major-mode 'mh-index-folder-mode))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
368 (error "Should be called from one of the index buffers")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
369 (let ((old-buffer (current-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
370 (window-config mh-index-previous-window-configuration))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
371 (unwind-protect (call-interactively 'mh-index-search)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
372 (when (eq old-buffer (current-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
373 (setq mh-index-previous-window-configuration window-config)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
374
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
375 (defun mh-index-insert-scan (folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
376 "Insert scan lines for hits in FOLDER that the indexing program found.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
377 The only twist is to replace the subject/body field with the match (if
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
378 possible)."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
379 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
380 (apply #'mh-exec-cmd-output
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
381 mh-scan-prog nil (mh-scan-format)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
382 "-noclear" "-noheader" "-width" (window-width)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
383 folder (mh-coalesce-msg-list (gethash folder mh-index-matches))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
384 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
385 (let ((window-width (window-width))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
386 (count 0))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
387 (while (not (or (get-text-property (point) 'mh-data) (eobp)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
388 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
389 (unless (and (eolp) (bolp))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
390 (incf count)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
391 (forward-char mh-cmd-note)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
392 (delete-char 1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
393 (insert " "))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
394 (forward-line 1))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
395 count)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
396
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
397 (defun mh-index-callback ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
398 "Callback function for buttons in the index buffer."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
399 (let* ((folder (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
400 (buffer-substring-no-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
401 (progn (beginning-of-line) (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
402 (progn (end-of-line) (point)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
403 (data (get-text-property (point) 'mh-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
404 (msg-list (gethash data mh-index-matches)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
405 (when msg-list
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
406 (mh-visit-folder folder msg-list))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
407
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
408 (defmacro mh-defun-index (func args &rest body)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
409 "Macro to generate a function callable both from index and show buffer.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
410 FUNC is the function name, ARGS the argument list and BODY the function
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
411 body."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
412 (let ((cur (gensym))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
413 interactive-spec doc-string)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
414 (when (stringp (car body))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
415 (setq doc-string (car body))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
416 (setq body (cdr body)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
417 (when (and (listp (car body)) (eq (caar body) 'interactive))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
418 (setq interactive-spec (car body))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
419 (setq body (cdr body)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
420 `(defun ,func ,args
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
421 ,@(if doc-string (list doc-string) ())
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
422 ,interactive-spec
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
423 (let* ((mh-index-buffer (if (eq major-mode 'mh-index-folder-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
424 (buffer-name (current-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
425 mh-index-other-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
426 (mh-index-show-buffer (if (eq major-mode 'mh-index-show-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
427 (buffer-name (current-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
428 mh-index-other-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
429 (,cur (cond ((eq (get-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
430 (current-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
431 mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
432 ((eq (get-buffer mh-index-show-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
433 (current-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
434 mh-index-show-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
435 (t (error "Not called from mh-index buffer")))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
436 (flet ((mh-msg-folder (folder) mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
437 (mh-msg-filename (msg-num folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
438 (format "%s%s/%s" mh-user-path (subseq folder 1) msg-num)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
439 (cond ((eq ,cur mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
440 (mh-index-goto-nearest-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
441 (when (and mh-current-folder mh-index-current-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
442 (mh-index-notate mh-current-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
443 mh-index-current-msg " " mh-cmd-note))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
444 (setq mh-current-folder (mh-index-parse-folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
445 (setq mh-index-current-msg (mh-index-parse-msg-number)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
446 ((eq ,cur mh-index-show-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
447 (set-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
448 (mh-index-goto-msg mh-current-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
449 mh-index-current-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
450 (mh-index-notate nil nil " " mh-cmd-note))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
451 (t (error "This can't happen!")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
452 (unwind-protect
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
453 (progn ,@body)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
454 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
455 (set-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
456 (mh-index-goto-msg mh-current-folder mh-index-current-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
457 (mh-recenter nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
458 (mh-index-configure-windows)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
459 (pop-to-buffer ,cur)))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
460
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
461 (defun mh-index-advance (steps)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
462 "Advance STEPS messages in the folder buffer.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
463 If there are less than STEPS messages left then an error message is printed."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
464 (let* ((backward-flag (< steps 0))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
465 (steps (if backward-flag (- steps) steps))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
466 point)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
467 (block body
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
468 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
469 (while (> steps 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
470 (unless (= (forward-line (if backward-flag -1 1)) 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
471 (return-from body))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
472 (cond ((and (eolp) (bolp) (not backward-flag))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
473 (unless (= (forward-line 2) 0) (return-from body)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
474 ((and (get-text-property (point) 'mh-data) backward-flag)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
475 (unless (= (forward-line -2) 0) (return-from body)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
476 ((or (and (eolp) (bolp))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
477 (get-text-property (point) 'mh-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
478 (error "Mh-index-buffer is inconsistent")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
479 (decf steps))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
480 (setq point (point))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
481 (cond (point (goto-char point) t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
482 (t nil))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
483
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
484 ;; Details about message at point. These functions assume that we are on a
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
485 ;; line which contains a message scan line and not on a blank line or a line
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
486 ;; with a folder name.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
487 (defun mh-index-parse-msg-number ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
488 "Parse message number of message at point."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
489 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
490 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
491 (let* ((b (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
492 (e (progn (forward-char mh-cmd-note) (point)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
493 (data (ignore-errors
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
494 (read-from-string (buffer-substring-no-properties b e)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
495 (unless (and (consp data) (integerp (car data)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
496 (error "Didn't find message number"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
497 (car data))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
498
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
499 (defun mh-index-parse-folder ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
500 "Parse folder of message at point."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
501 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
502 (while (not (get-text-property (point) 'mh-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
503 (unless (eql (forward-line -1) 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
504 (error "Reached beginning of buffer without seeing a folder")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
505 (buffer-substring-no-properties (progn (beginning-of-line) (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
506 (progn (end-of-line) (point)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
507
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
508 (defun mh-index-goto-nearest-msg ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
509 "If point is not at a message go to the closest line with a message on it."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
510 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
511 (cond ((and (eolp) (bolp)) (forward-line -1))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
512 ((get-text-property (point) 'mh-data) (forward-line 1))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
513
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
514 ;; Window configuration for mh-index... There should be similar functions
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
515 ;; in MH-E but I couldn't find them. I got the idea of using next-window,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
516 ;; previous-window and minibuffer-window from MH-E code.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
517 (defun mh-index-configure-windows ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
518 "Configure windows."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
519 (cond ((and (buffer-live-p (get-buffer mh-index-show-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
520 (buffer-live-p (get-buffer mh-index-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
521 (eq (save-excursion (set-buffer mh-index-show-buffer) major-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
522 'mh-index-show-mode))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
523 (mh-index-configure-two-windows))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
524 ((buffer-live-p (get-buffer mh-index-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
525 (mh-index-configure-one-window))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
526
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
527 (defun mh-count-windows ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
528 "Count the number of windows in the current frame.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
529 The minibuffer window is excluded from the count."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
530 (let* ((start-window (next-window nil t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
531 (current-window (next-window start-window t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
532 (count 0))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
533 (while (not (eq current-window start-window))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
534 (incf count)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
535 (setq current-window (next-window current-window t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
536 count))
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 (defun mh-index-configure-two-windows ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
539 "Force a split view like that of MH-E."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
540 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
541 (unless (and (get-buffer mh-index-show-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
542 (get-buffer mh-index-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
543 (error "We don't have both index buffers"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
544 (let ((window-count (mh-count-windows)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
545 (unless (and (= window-count 2)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
546 (eq (window-buffer (next-window (minibuffer-window)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
547 (get-buffer mh-index-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
548 (eq (window-buffer (previous-window (minibuffer-window)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
549 (get-buffer mh-index-show-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
550 (unless (= window-count 2)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
551 (delete-other-windows)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
552 (split-window-vertically))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
553 (set-window-buffer (next-window (minibuffer-window))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
554 mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
555 (set-window-buffer (previous-window (minibuffer-window))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
556 mh-index-show-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
557 (unless (and (get-buffer-window mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
558 (= (window-height (get-buffer-window mh-index-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
559 mh-summary-height))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
560 (pop-to-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
561 (shrink-window (- (window-height) mh-summary-height))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
562 (set-window-point (previous-window (minibuffer-window))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
563 (progn (set-buffer mh-index-show-buffer) (point)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
564 (set-window-point (next-window (minibuffer-window))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
565 (progn (set-buffer mh-index-buffer) (point)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
566
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
567 (defun mh-index-configure-one-window ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
568 "Single window view."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
569 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
570 (unless (buffer-live-p (get-buffer mh-index-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
571 (error "Should have mh-index-buffer"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
572 (switch-to-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
573 (delete-other-windows)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
574 (set-window-point (next-window (minibuffer-window))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
575 (progn (set-buffer mh-index-buffer) (point)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
576
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
577 ;; This is slightly more involved than normal MH-E since we may have multiple
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
578 ;; folders in the same buffer.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
579 (defun mh-index-goto-msg (folder msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
580 "Move the cursor to the message specified by FOLDER and MSG."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
581 (block body
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
582 (unless (buffer-live-p (get-buffer mh-index-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
583 (error "No index buffer to go to"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
584 (set-buffer mh-index-buffer)
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 (while (re-search-forward (format "^%s$" folder) nil t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
587 (forward-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
588 (while (not (eolp))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
589 (when (= (mh-index-parse-msg-number) msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
590 (return-from body))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
591 (forward-line)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
592 (error "Folder: %s, msg: %s doesn't exist" folder msg)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
593
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
594 ;; Can't use mh-notate directly since we could have more than one folder in
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
595 ;; the same buffer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
596 (defun mh-index-notate (folder msg notation offset)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
597 "Add notation to scan line.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
598 FOLDER is the message folder and MSG the message index. These arguments
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
599 specify the message to be notated. NOTATION is the character to be used to
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
600 notate and OFFSET is the number of chars from start of the line where
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
601 notation is to be placed."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
602 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
603 (set-buffer mh-index-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
604 (let ((buffer-read-only nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
605 (modified-p (buffer-modified-p))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
606 (found t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
607 (setq found nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
608 (when (and (stringp folder) (numberp msg))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
609 (block nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
610 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
611 (re-search-forward (format "^%s$" folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
612 (forward-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
613 (while (not (eolp))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
614 (when (= (mh-index-parse-msg-number) msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
615 (setq found t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
616 (return))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
617 (forward-line))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
618 (when found
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
619 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
620 (forward-char offset)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
621 (delete-char 1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
622 (insert notation)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
623 (unless modified-p (set-buffer-modified-p nil))))))
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
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 ;;; User functions
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
628
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
629 (mh-defun-index mh-index-show (display-headers-flag)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
630 "Display message at point.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
631 If there are no messages at point then display the closest message.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
632 The value of `mh-index-show-hook' is a list of functions to be called,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
633 with no arguments, after the message has been displayed.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
634 If DISPLAY-HEADERS-FLAG is non-nil then the raw message is shown."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
635 (interactive (list nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
636 (when (or (and (bolp) (eolp)) (get-text-property (point) 'mh-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
637 (error "No message at point"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
638 (setq mh-current-folder (mh-index-parse-folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
639 (setq mh-index-current-msg (mh-index-parse-msg-number))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
640 ;; Do new notation
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
641 (when (and mh-current-folder mh-index-current-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
642 (mh-index-notate mh-current-folder mh-index-current-msg
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
643 mh-note-cur mh-cmd-note))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
644 (let ((mh-decode-mime-flag (and (not display-headers-flag) mh-decode-mime-flag))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
645 (mh-clean-message-header-flag
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
646 (and (not display-headers-flag) mh-clean-message-header-flag))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
647 (mhl-formfile (if display-headers-flag nil mhl-formfile))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
648 (msg mh-index-current-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
649 (folder mh-current-folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
650 (when (not (eq display-headers-flag mh-showing-with-headers))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
651 (mh-invalidate-show-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
652 (mh-in-show-buffer (mh-index-show-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
653 (mh-display-msg msg folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
654 ;; Search for match in shown message
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
655 (select-window (get-buffer-window mh-index-show-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
656 (set-buffer mh-index-show-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
657 (mh-index-show-mode))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
658 (run-hooks 'mh-index-show-hook))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
659
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
660 (defun mh-index-header-display ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
661 "Show the message with full headers."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
662 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
663 (mh-index-show t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
664 (setq mh-showing-with-headers t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
665
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
666 (mh-defun-index mh-index-next (steps)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
667 "Display next message.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
668 Prefix argument STEPS specifies the number of messages to skip ahead."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
669 (interactive "p")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
670 (mh-index-goto-nearest-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
671 (if (mh-index-advance steps)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
672 (mh-index-show nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
673 (mh-index-show nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
674 (message "Not enough messages")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
675
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
676 (mh-defun-index mh-index-prev (steps)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
677 "Display previous message.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
678 Prefix argument STEPS specifies the number of messages to skip backward."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
679 (interactive "p")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
680 (mh-index-goto-nearest-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
681 (if (mh-index-advance (- steps))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
682 (mh-index-show nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
683 (mh-index-show nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
684 (message "Not enough messages")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
685
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
686 (defun mh-index-page-msg (arg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
687 "Scroll the displayed message upward ARG lines."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
688 (interactive "P")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
689 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
690 (let* ((show-buffer (cond ((eq major-mode 'mh-index-folder-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
691 mh-index-other-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
692 ((eq major-mode 'mh-index-show-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
693 (buffer-name (current-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
694 (t (error "Don't use mh-index-page-msg"))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
695 (window (get-buffer-window show-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
696 (current-window (selected-window)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
697 (when (window-live-p window)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
698 (select-window window)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
699 (unwind-protect (scroll-up arg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
700 (select-window current-window))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
701
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
702 (defun mh-index-previous-page (arg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
703 "Scroll the displayed message downward ARG lines."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
704 (interactive "P")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
705 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
706 (let* ((show-buffer (cond ((eq major-mode 'mh-index-folder-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
707 mh-index-other-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
708 ((eq major-mode 'mh-index-show-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
709 (buffer-name (current-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
710 (t (error "Don't use mh-index-previous-page"))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
711 (window (get-buffer-window show-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
712 (current-window (selected-window)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
713 (when (window-live-p window)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
714 (select-window window)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
715 (unwind-protect (scroll-down arg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
716 (select-window current-window))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
717
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
718 (defun mh-index-press-button ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
719 "Press index button."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
720 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
721 (let ((function (get-text-property (point) 'mh-callback)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
722 (when function
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
723 (funcall function))))
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 (defun mh-index-quit ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
726 "Quit the index folder.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
727 Restore the previous window configuration, if one exists.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
728 The value of `mh-before-quit-hook' is a list of functions to be called, with
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
729 no arguments, immediately upon entry to this function.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
730 The value of `mh-quit-hook' is a list of functions to be called, with no
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
731 arguments, upon exit of this function."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
732 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
733 (cond ((eq major-mode 'mh-index-show-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
734 (set-buffer mh-index-other-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
735 ((not (eq major-mode 'mh-index-folder-mode))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
736 (error "The function mh-index-quit shouldn't be called")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
737 (run-hooks 'mh-before-quit-hook)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
738 (let ((mh-index-buffer (buffer-name (current-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
739 (mh-index-show-buffer mh-index-other-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
740 (window-config mh-index-previous-window-configuration))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
741 (when (buffer-live-p (get-buffer mh-index-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
742 (bury-buffer (get-buffer mh-index-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
743 (when (buffer-live-p (get-buffer mh-index-show-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
744 (bury-buffer (get-buffer mh-index-show-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
745 (when window-config
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
746 (set-window-configuration window-config)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
747 (run-hooks 'mh-quit-hook))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
748
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
749 ;; Can't quite use mh-next-button... This buffer has no concept of
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
750 ;; folder-buffer or show-buffer. Maybe refactor mh-next-button?
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
751 (defun mh-index-next-button (&optional backward-flag)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
752 "Go to the next button.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
753 Advance point to the next button in the show buffer. If the end of buffer is
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
754 reached then the search wraps over to the start of the buffer. With optional
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
755 argument BACKWARD-FLAG the point will move to the previous button."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
756 (interactive current-prefix-arg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
757 (mh-goto-next-button backward-flag))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
758
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
759 (defun mh-index-prev-button ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
760 "Go to the next button.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
761 Move point to the previous button in the show buffer. If the beginning of
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
762 the buffer is reached then the search wraps over to the end."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
763 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
764 (mh-index-next-button t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
765
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
766
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
767
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
768 ;; Glimpse interface
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
769
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
770 (defvar mh-glimpse-binary (executable-find "glimpse"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
771 (defvar mh-glimpse-directory ".glimpse")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
772
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
773 (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
774 "Execute glimpse and read the results.
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 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
777 directory.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
778
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
779 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
780 /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
781
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
782 */.*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
783 */#*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
784 */,*
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 ^/home/user/Mail/.glimpse
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
787
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
788 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
789 following to .glimpse_exclude:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
790
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
791 ^/home/user/Mail/scripts
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
792
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
793 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
794 daily from cron:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
795
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
796 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
797
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
798 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
799 (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
800 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
801 (call-process mh-glimpse-binary nil '(t nil) nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
802 ;(format "-%s" fuzz)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
803 "-i" "-y"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
804 "-H" (format "%s%s" mh-user-path mh-glimpse-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
805 "-F" (format "^%s" folder-path)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
806 search-regexp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
807 (goto-char (point-min)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
808
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
809 (defun mh-glimpse-next-result ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
810 "Read the next result.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
811 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
812 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
813 'error."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
814 (prog1
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
815 (block nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
816 (when (eobp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
817 (return nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
818 (let ((eol-pos (line-end-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
819 (bol-pos (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
820 folder-start msg-end)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
821 (goto-char bol-pos)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
822 (unless (search-forward mh-user-path eol-pos t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
823 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
824 (setq folder-start (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
825 (unless (search-forward ": " eol-pos t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
826 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
827 (let ((match (buffer-substring-no-properties (point) eol-pos)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
828 (forward-char -2)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
829 (setq msg-end (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
830 (unless (search-backward "/" folder-start t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
831 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
832 (list (format "+%s" (buffer-substring-no-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
833 folder-start (point)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
834 (let ((val (ignore-errors (read-from-string
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
835 (buffer-substring-no-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
836 (1+ (point)) msg-end)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
837 (if (and (consp val) (integerp (car val)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
838 (car val)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
839 (return 'error)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
840 match))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
841 (forward-line)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
842
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
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
845 ;; Grep interface
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 (defvar mh-grep-binary (executable-find "grep"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
848
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
849 (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
850 "Execute grep and read the results.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
851 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
852 (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
853 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
854 (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
855 "-i" "-r" search-regexp folder-path)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
856 (goto-char (point-min)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
857
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
858 (defun mh-grep-next-result ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
859 "Read the next result.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
860 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
861 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
862 'error."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
863 (prog1
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
864 (block nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
865 (when (eobp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
866 (return nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
867 (let ((eol-pos (line-end-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
868 (bol-pos (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
869 folder-start msg-end)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
870 (goto-char bol-pos)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
871 (unless (search-forward mh-user-path eol-pos t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
872 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
873 (setq folder-start (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
874 (unless (search-forward ":" eol-pos t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
875 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
876 (let ((match (buffer-substring-no-properties (point) eol-pos)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
877 (forward-char -1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
878 (setq msg-end (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
879 (unless (search-backward "/" folder-start t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
880 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
881 (list (format "+%s" (buffer-substring-no-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
882 folder-start (point)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
883 (let ((val (ignore-errors (read-from-string
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
884 (buffer-substring-no-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
885 (1+ (point)) msg-end)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
886 (if (and (consp val) (integerp (car val)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
887 (car val)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
888 (return 'error)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
889 match))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
890 (forward-line)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
891
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
892
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
893
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
894 ;; Swish interface
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
895
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
896 (defvar mh-swish-binary (executable-find "swish-e"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
897 (defvar mh-swish-directory ".swish")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
898 (defvar mh-swish-folder nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
899
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
900 (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
901 "Execute swish-e and read the results.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
902
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
903 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
904 directory.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
905
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
906 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
907 /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
908
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
909 IndexDir /home/user/Mail
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
910 IndexFile /home/user/Mail/.swish/index
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
911 IndexName \"Mail Index\"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
912 IndexDescription \"Mail Index\"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
913 IndexPointer \"http://nowhere\"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
914 IndexAdmin \"nobody\"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
915 #MetaNames automatic
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
916 IndexReport 3
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
917 FollowSymLinks no
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
918 UseStemming no
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
919 IgnoreTotalWordCountWhenRanking yes
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
920 WordCharacters abcdefghijklmnopqrstuvwxyz0123456789-
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
921 BeginCharacters abcdefghijklmnopqrstuvwxyz
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
922 EndCharacters abcdefghijklmnopqrstuvwxyz0123456789
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
923 IgnoreLimit 50 1000
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
924 IndexComments 0
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
925 FileRules pathname contains /home/user/Mail/.swish
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
926 FileRules filename is index
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
927 FileRules filename is \..*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
928 FileRules filename is #.*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
929 FileRules filename is ,.*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
930 FileRules filename is .*~
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
931
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
932 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
933 following to config:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
934
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
935 FileRules pathname contains /home/user/Mail/scripts
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
936
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
937 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
938 daily from cron:
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 swish-e -c /home/user/Mail/.swish/config
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
941
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
942 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
943 (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
944 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
945 (unless mh-swish-binary
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
946 (error "Set mh-swish-binary appropriately"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
947 (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
948 "-w" search-regexp
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
949 "-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
950 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
951 (setq mh-swish-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
952 (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
953 (if (equal last-char "/")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
954 folder-path
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
955 (format "%s/" folder-path)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
956
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
957 (defun mh-swish-next-result ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
958 "Get the next result from swish output."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
959 (prog1
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
960 (block nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
961 (when (or (eobp) (equal (char-after (point)) ?.))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
962 (return nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
963 (when (equal (char-after (point)) ?#)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
964 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
965 (let* ((start (search-forward " " (line-end-position) t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
966 (end (search-forward " " (line-end-position) t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
967 (unless (and start end)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
968 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
969 (setq end (1- end))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
970 (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
971 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
972 (unless (search-backward "/" start t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
973 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
974 (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
975 (unless (string-match mh-swish-folder s)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
976 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
977 (if (string-match mh-user-path s)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
978 (format "+%s"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
979 (substring s (match-end 0) (1- (length s))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
980 (return 'error)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
981 (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
982 (val (ignore-errors (read-from-string s))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
983 (if (and (consp val) (numberp (car val)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
984 (car val)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
985 (return 'error)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
986 nil)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
987 (forward-line)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
988
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
989
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
990
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
991 ;; Swish++ interface
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
992
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
993 (defvar mh-swish++-binary (or (executable-find "search++")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
994 (executable-find "search")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
995 (defvar mh-swish++-directory ".swish++")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
996
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
997 (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
998 "Execute swish++ and read the results.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
999
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1000 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
1001 directory.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1002
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1003 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
1004 /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
1005
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1006 IncludeMeta Bcc Cc Comments Content-Description From Keywords
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1007 IncludeMeta Newsgroups Resent-To Subject To
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1008 IncludeFile Mail [0-9]*
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1009 IndexFile /home/user/Mail/.swish++/swish++.index
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1010
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1011 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
1012 daily from cron:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1013
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1014 index -c /home/user/Mail/.swish++/swish++.conf /home/user/Mail
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1015
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1016 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
1017
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1018 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
1019 (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
1020 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1021 (unless mh-swish++-binary
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1022 (error "Set mh-swish++-binary appropriately"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1023 (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
1024 "-m" "10000"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1025 (format "-i%s%s/swish++.index"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1026 mh-user-path mh-swish++-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1027 search-regexp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1028 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1029 (setq mh-swish-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1030 (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
1031 (if (equal last-char "/")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1032 folder-path
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1033 (format "%s/" folder-path)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1034
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1035 (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
1036
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1037
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1038
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1039 ;; Namazu interface
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1040
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1041 (defvar mh-namazu-binary (executable-find "namazu"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1042 (defvar mh-namazu-directory ".namazu")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1043 (defvar mh-namazu-folder nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1044
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1045 (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
1046 "Execute namazu and read the results.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1047
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1048 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
1049 directory.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1050
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1051 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
1052 /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
1053
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1054 package conf; # Don't remove this line!
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1055 $ADDRESS = 'user@localhost';
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1056 $ALLOW_FILE = \"[0-9]*\";
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1057
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1058 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
1059 daily from cron:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1060
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1061 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
1062 /home/user/Mail
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1063
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1064 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
1065 (let ((namazu-index-directory
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1066 (format "%s%s" mh-user-path mh-namazu-directory)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1067 (unless (file-exists-p namazu-index-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1068 (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
1069 (unless (executable-find mh-namazu-binary)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1070 (error "Set mh-namazu-binary appropriately"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1071 (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
1072 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1073 (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
1074 "-alR" search-regexp namazu-index-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1075 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1076 (setq mh-namazu-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1077 (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
1078 (if (equal last "/")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1079 folder-path
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1080 (format "%s/" folder-path))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1081
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1082 (defun mh-namazu-next-result ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1083 "Get the next result from namazu output."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1084 (prog1
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1085 (block nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1086 (when (eobp) (return nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1087 (let ((file-name (buffer-substring-no-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1088 (point) (line-end-position))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1089 (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
1090 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1091 (unless (file-exists-p file-name)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1092 (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1093 (string-match mh-user-path file-name)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1094 (let* ((folder/msg (substring file-name (match-end 0)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1095 (mark (search "/" folder/msg :from-end t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1096 (unless mark (return 'error))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1097 (list (format "+%s" (substring folder/msg 0 mark))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1098 (let ((n (ignore-errors (read-from-string
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1099 (substring folder/msg (1+ mark))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1100 (if (and (consp n) (numberp (car n)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1101 (car n)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1102 (return 'error)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1103 nil))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1104 (forward-line)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1105
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1106
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1107
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1108 (defun mh-index-choose ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1109 "Choose an indexing function.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1110 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
1111 `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
1112 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
1113 system."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1114 (block nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1115 ;; 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
1116 ;; 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
1117 ;; through the list.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1118 (let ((program-alist (cond (mh-index-program
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1119 (list
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1120 (assoc mh-index-program mh-indexer-choices)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1121 (mh-indexer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1122 (list (assoc mh-indexer mh-indexer-choices)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1123 (t mh-indexer-choices))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1124 (while program-alist
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1125 (let* ((current (pop program-alist))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1126 (executable (symbol-value (cadr current))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1127 (when executable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1128 (setq mh-indexer (car current))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1129 (setq mh-index-execute-search-function (caddr current))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1130 (setq mh-index-next-result-function (cadddr current))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1131 (return mh-indexer))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1132 nil)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1133
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1134
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1135
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1136 ;;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1137 ;;; Menus for folder mode: folder, message (in that order)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1138 ;;; folder-mode "Message" menu
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1139 (easy-menu-define
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1140 mh-index-folder-message-menu mh-index-folder-mode-keymap
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1141 "Menu for MH-E folder-message."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1142 '("Message"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1143 ["Show Message" mh-index-show (mh-get-msg-num nil)]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1144 ["Show Message with Header" mh-index-header-display (mh-get-msg-num nil)]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1145 ["Next Message" mh-index-next t]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1146 ["Previous Message" mh-index-prev t]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1147 "--"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1148 ["Compose a New Message" mh-send t]))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1149
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1150 ;;; folder-mode "Folder" menu
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1151 (easy-menu-define
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1152 mh-index-folder-folder-menu mh-index-folder-mode-keymap
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1153 "Menu for MH-E folder."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1154 '("Folder"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1155 ["Incorporate New Mail" mh-inc-folder t]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1156 "--"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1157 ["Visit a Folder..." mh-visit-folder t]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1158 ["Indexed Search..." mh-index-search-again t]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1159 "--"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1160 ["Quit Indexed Search" mh-index-quit t]))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1161
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1162
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1163
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1164 ;;; Support for emacs21 toolbar using gnus/message.el icons (and code).
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1165 (eval-when-compile (defvar tool-bar-map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1166 (defvar mh-index-folder-tool-bar-map nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1167 (when (fboundp 'tool-bar-add-item)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1168 (setq mh-index-folder-tool-bar-map
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1169 (let ((tool-bar-map (make-sparse-keymap)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1170 (tool-bar-add-item "mail" 'mh-inc-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1171 'mh-indexfoldertoolbar-inc-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1172 :help "Incorporate new mail in Inbox")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1173 (tool-bar-add-item "left_arrow" 'mh-index-prev
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1174 'mh-indexfoldertoolbar-prev :help "Previous message")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1175 (tool-bar-add-item "page-down" 'mh-index-page-msg
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1176 'mh-indexfoldertoolbar-page
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1177 :help "Page this message")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1178 (tool-bar-add-item "right_arrow" 'mh-index-next
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1179 'mh-indexfoldertoolbar-next :help "Next message")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1180
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1181 (tool-bar-add-item "mail_compose" 'mh-send 'mh-indexfoldertoolbar-compose
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1182 :help "Compose new message")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1183
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1184 (tool-bar-add-item "search"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1185 (lambda (&optional arg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1186 (interactive "P")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1187 (call-interactively mh-tool-bar-search-function))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1188 'mh-indexfoldertoolbar-search :help "Search")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1189 (tool-bar-add-item "fld_open" 'mh-visit-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1190 'mh-indexfoldertoolbar-visit
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1191 :help "Visit other folder")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1192
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1193 (tool-bar-add-item "preferences" (lambda ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1194 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1195 (customize-group "mh"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1196 'mh-indexfoldertoolbar-customize
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1197 :help "MH-E preferences")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1198 (tool-bar-add-item "help" (lambda ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1199 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1200 (Info-goto-node "(mh-e)Top"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1201 'mh-indexfoldertoolbar-help :help "Help")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1202 tool-bar-map)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1203
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1204 ;; Modes for mh-index
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1205 (define-derived-mode mh-index-folder-mode mh-folder-mode "MH-Index-Folder"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1206 "Major MH-E mode for displaying the results of searching.\\<mh-index-folder-mode-keymap>
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1207
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1208 You can display the message the cursor is pointing to and step through the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1209 messages.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1210
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1211 You can also jump to the folders narrowed to the search results by pressing
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1212 RET on the folder name. Many operations, such as replying to a message,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1213 require that you do this first.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1214
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1215 \\{mh-index-folder-mode-keymap}"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1216 (make-local-variable 'font-lock-defaults)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1217 (setq font-lock-defaults '(mh-index-font-lock-keywords t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1218 (use-local-map mh-index-folder-mode-keymap)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1219 (make-local-variable 'mh-help-messages)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1220 (easy-menu-add mh-index-folder-message-menu)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1221 (easy-menu-add mh-index-folder-folder-menu)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1222 (if (and (boundp 'tool-bar-mode) tool-bar-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1223 (set (make-local-variable 'tool-bar-map) mh-index-folder-tool-bar-map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1224 (setq mh-help-messages mh-index-folder-mode-help-messages))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1225
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1226 (define-derived-mode mh-index-show-mode mh-show-mode "MH-Index-Show"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1227 "Major mode for showing messages in MH-E index.\\<mh-index-folder-mode-keymap>
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1228 \\{mh-index-folder-mode-keymap}"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1229 (use-local-map mh-index-folder-mode-keymap)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1230 (setq mh-help-messages mh-index-folder-mode-help-messages))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1231
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1232 ;; Font lock support for mh-index-folder. This is the same as mh-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1233 ;; except that the folder line needs to be recognized and highlighted.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1234 (defvar mh-index-folder-face 'mh-index-folder-face
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1235 "Face for highlighting folders in MH-Index buffers.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1236 (defface mh-index-folder-face
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1237 '((((class color) (background light))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1238 (:foreground "dark green"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1239 (((class color) (background dark))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1240 (:foreground "indian red"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1241 (t
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1242 (:bold t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1243 "Face for highlighting folders in MH-Index buffers."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1244 :group 'mh)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1245
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1246 (eval-after-load "font-lock"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1247 '(progn
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1248 (defvar mh-index-folder-face 'mh-index-folder-face
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1249 "Face for highlighting folders in MH-Index buffers.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1250
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1251 (defvar mh-index-font-lock-keywords
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1252 (list
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1253 ;; Folder name
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1254 (list "^\\+.*" '(0 mh-index-folder-face))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1255 ;; Marked for deletion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1256 (list (concat mh-scan-deleted-msg-regexp ".*")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1257 '(0 mh-folder-deleted-face))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1258 ;; Marked for refile
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1259 (list (concat mh-scan-refiled-msg-regexp ".*")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1260 '(0 mh-folder-refiled-face))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1261 ;;after subj
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1262 (list mh-scan-body-regexp '(1 mh-folder-body-face nil t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1263 '(mh-folder-font-lock-subject
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1264 (1 mh-folder-followup-face append t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1265 (2 mh-folder-subject-face append t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1266 ;;current msg
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1267 (list mh-scan-cur-msg-number-regexp
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1268 '(1 mh-folder-cur-msg-number-face))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1269 (list mh-scan-good-msg-regexp
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1270 '(1 mh-folder-msg-number-face)) ;; Msg number
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1271 (list mh-scan-date-regexp '(1 mh-folder-date-face)) ;; Date
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1272 (list mh-scan-rcpt-regexp
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1273 '(1 mh-folder-to-face) ;; To:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1274 '(2 mh-folder-address-face)) ;; address
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1275 ;; scan font-lock name
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1276 (list mh-scan-format-regexp
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1277 '(1 mh-folder-date-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1278 '(3 mh-folder-scan-format-face))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1279 ;; Current message line
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1280 (list mh-scan-cur-msg-regexp
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1281 '(1 mh-folder-cur-msg-face prepend t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1282 "Regexp keywords used to fontify the MH-Index-Folder buffer.")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1283
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1284 (provide 'mh-index)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1285
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1286 ;;; Local Variables:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1287 ;;; sentence-end-double-space: nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1288 ;;; End:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1289
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1290 ;;; mh-index ends here