annotate lisp/mail/mh-pick.el @ 49120:30c4902b654d

Upgraded to MH-E version 7.1.
author Bill Wohler <wohler@newt.com>
date Wed, 08 Jan 2003 23:21:16 +0000
parents 8aaba207e44b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1 ;;; mh-pick.el --- make a search pattern and search for a message in MH-E
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
2
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
3 ;; Copyright (C) 1993, 1995, 2001 Free Software Foundation, Inc.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
5 ;; Author: Bill Wohler <wohler@newt.com>
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
6 ;; Maintainer: Bill Wohler <wohler@newt.com>
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
7 ;; Keywords: mail
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
8 ;; See: mh-e.el
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 14169
diff changeset
10 ;; This file is part of GNU Emacs.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
11333
53174cfc29fa Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 11332
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; any later version.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
11333
53174cfc29fa Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 11332
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
25 ;; Boston, MA 02111-1307, USA.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
29 ;; Internal support for MH-E package.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
31 ;;; Change Log:
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
32
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
33 ;; $Id: mh-pick.el,v 1.25 2002/12/04 18:51:50 wohler Exp $
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
34
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;;; Code:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 (require 'mh-e)
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
38 (require 'easymenu)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
39 (require 'gnus-util)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
41 ;;; Internal variables:
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
42
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
43 (defvar mh-pick-mode-map (make-sparse-keymap)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
44 "Keymap for searching folder.")
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
45
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
46 (defvar mh-searching-folder nil) ;Folder this pick is searching.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
48 ;;;###mh-autoload
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (defun mh-search-folder (folder)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
50 "Search FOLDER for messages matching a pattern.
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
51 This function uses the MH command `pick' to do the work.
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
52 Add the messages found to the sequence named `search'."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (interactive (list (mh-prompt-for-folder "Search"
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
54 mh-current-folder
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
55 t)))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (switch-to-buffer-other-window "pick-pattern")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (if (or (zerop (buffer-size))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
58 (not (y-or-n-p "Reuse pattern? ")))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (mh-make-pick-template)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (message ""))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
61 (setq mh-searching-folder folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
62 (message "%s" (substitute-command-keys
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
63 (concat "Type \\[mh-do-pick-search] to search messages, "
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
64 "\\[mh-help] for help."))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (defun mh-make-pick-template ()
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
67 "Initialize the current buffer with a template for a pick pattern."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (insert "From: \n"
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
70 "To: \n"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
71 "Cc: \n"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
72 "Date: \n"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
73 "Subject: \n"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
74 "---------\n")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (mh-pick-mode)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (goto-char (point-min))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (end-of-line))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
79 ;;; 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: 47730
diff changeset
80 (easy-menu-define
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
81 mh-pick-menu mh-pick-mode-map "Menu for MH-E pick-mode"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
82 '("Pick"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
83 ["Execute the Search" mh-do-pick-search t]))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
84
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
85
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
86 ;;; Help Messages
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
87 ;;; Group messages logically, more or less.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
88 (defvar mh-pick-mode-help-messages
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
89 '((nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
90 "Search messages: \\[mh-do-pick-search]\n"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
91 "Move to a field by typing C-c C-f C-<field>\n"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
92 "where <field> is the first letter of the desired field."))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
93 "Key binding cheat sheet.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
94
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
95 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: 47730
diff changeset
96 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: 47730
diff changeset
97 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: 47730
diff changeset
98 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: 47730
diff changeset
99 non-prefixed commands.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
100
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
101 The substitutions described in `substitute-command-keys' are performed as
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
102 well.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
103
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (put 'mh-pick-mode 'mode-class 'special)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
106 (define-derived-mode mh-pick-mode fundamental-mode "MH-Pick"
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
107 "Mode for creating search templates in MH-E.\\<mh-pick-mode-map>
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
108
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
109 After each field name, enter the pattern to search for. If a field's
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
110 value does not matter for the search, leave it empty. To search the
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
111 entire message, supply the pattern in the \"body\" of the template.
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
112 Each non-empty field must be matched for a message to be selected.
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
113 To effect a logical \"or\", use \\[mh-search-folder] multiple times.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 When you have finished, type \\[mh-do-pick-search] to do the search.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
115
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
116 The value of `mh-pick-mode-hook' is a list of functions to be called,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
117 with no arguments, upon entry to this mode.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
118
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
119 \\{mh-pick-mode-map}"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
120
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (make-local-variable 'mh-searching-folder)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
122 (easy-menu-add mh-pick-menu)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
123 (make-local-variable 'mh-help-messages)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
124 (setq mh-help-messages mh-pick-mode-help-messages)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
125 (run-hooks 'mh-pick-mode-hook))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
127 ;;;###mh-autoload
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (defun mh-do-pick-search ()
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 "Find messages that match the qualifications in the current pattern buffer.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
130 Messages are searched for in the folder named in `mh-searching-folder'.
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
131 Add the messages found to the sequence named `search'."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (interactive)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (let ((pattern-buffer (buffer-name))
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
134 (searching-buffer mh-searching-folder)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
135 range
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
136 msgs
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
137 (pattern nil)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
138 (new-buffer nil))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (cond ((get-buffer searching-buffer)
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
141 (set-buffer searching-buffer)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
142 (setq range (list (format "%d-%d"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
143 mh-first-msg-num mh-last-msg-num))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
144 (t
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
145 (mh-make-folder searching-buffer)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
146 (setq range '("all"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
147 (setq new-buffer t))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (message "Searching...")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (goto-char (point-min))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
150 (while (and range
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
151 (setq pattern (mh-next-pick-field pattern-buffer)))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (setq msgs (mh-seq-from-command searching-buffer
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
153 'search
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
154 (mh-list-to-string
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
155 (list "pick" pattern searching-buffer
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
156 "-list"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
157 (mh-coalesce-msg-list range)))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
158 (setq range msgs)) ;restrict the pick range for next pass
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (message "Searching...done")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (if new-buffer
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
161 (mh-scan-folder searching-buffer msgs)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
162 (switch-to-buffer searching-buffer))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
163 (mh-add-msgs-to-seq msgs 'search)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
164 (delete-other-windows)))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
166 (defun mh-seq-from-command (folder seq command)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
167 "In FOLDER, make a sequence named SEQ by executing COMMAND.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
168 COMMAND is a list. The first element is a program name
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
169 and the subsequent elements are its arguments, all strings."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (let ((msg)
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
171 (msgs ())
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
172 (case-fold-search t))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (save-window-excursion
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
175 (if (eq 0 (apply 'mh-exec-cmd-quiet nil command))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
176 ;; "pick" outputs one number per line
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
177 (while (setq msg (car (mh-read-msg-list)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
178 (setq msgs (cons msg msgs))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
179 (forward-line 1))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (set-buffer folder)
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
181 (setq msgs (nreverse msgs)) ;put in ascending order
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 msgs)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (defun mh-next-pick-field (buffer)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
185 "Return the next piece of a pick argument extracted from BUFFER.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
186 Return a list like (\"--fieldname\" \"pattern\") or (\"-search\" \"bodypat\")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
187 or nil if no pieces remain."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (set-buffer buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (let ((case-fold-search t))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (cond ((eobp)
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
191 nil)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
192 ((re-search-forward "^\\([a-z][^: \t\n]*\\):[ \t]*\\([a-z0-9].*\\)$"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
193 nil t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
194 (let* ((component
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
195 (format "--%s"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
196 (downcase (buffer-substring (match-beginning 1)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
197 (match-end 1)))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
198 (pat (buffer-substring (match-beginning 2) (match-end 2))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
199 (forward-line 1)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
200 (list component pat)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
201 ((re-search-forward "^-*$" nil t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
202 (forward-char 1)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
203 (let ((body (buffer-substring (point) (point-max))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
204 (if (and (> (length body) 0) (not (equal body "\n")))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
205 (list "-search" body)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
206 nil)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
207 (t
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
208 nil))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
210
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
211
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 ;;; Build the pick-mode keymap:
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
213 ;;; If this changes, modify mh-pick-mode-help-messages accordingly, above.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
214 (gnus-define-keys mh-pick-mode-map
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
215 "\C-c?" mh-help
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
216 "\C-c\C-c" mh-do-pick-search
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
217 "\C-c\C-f\C-b" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
218 "\C-c\C-f\C-c" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
219 "\C-c\C-f\C-d" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
220 "\C-c\C-f\C-f" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
221 "\C-c\C-f\C-r" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
222 "\C-c\C-f\C-s" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
223 "\C-c\C-f\C-t" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
224 "\C-c\C-fb" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
225 "\C-c\C-fc" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
226 "\C-c\C-fd" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
227 "\C-c\C-ff" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
228 "\C-c\C-fr" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
229 "\C-c\C-fs" mh-to-field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
230 "\C-c\C-ft" mh-to-field)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
232 (provide 'mh-pick)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
233
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
234 ;;; Local Variables:
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents: 48595
diff changeset
235 ;;; indent-tabs-mode: nil
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
236 ;;; sentence-end-double-space: nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
237 ;;; End:
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 14169
diff changeset
238
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 14169
diff changeset
239 ;;; mh-pick.el ends here