annotate lisp/mail/mh-pick.el @ 48595:8aaba207e44b

Upgraded to MH-E version 7.0.
author Bill Wohler <wohler@newt.com>
date Fri, 29 Nov 2002 18:15:21 +0000
parents 2568d5a27317
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: 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
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
33 ;; $Id: mh-pick.el,v 1.21 2002/11/05 21:43:16 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
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
41 ;;; Hooks
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
42
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
43 (defcustom mh-pick-mode-hook nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
44 "Invoked upon entry to `mh-pick-mode'."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
45 :type 'hook
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
46 :group 'mh-hook)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
48 ;;; Internal variables:
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
49
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
50 (defvar mh-pick-mode-map (make-sparse-keymap)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
51 "Keymap for searching folder.")
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
52
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
53 (defvar mh-searching-folder nil) ;Folder this pick is searching.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (defun mh-search-folder (folder)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
56 "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
57 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
58 Add the messages found to the sequence named `search'."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (interactive (list (mh-prompt-for-folder "Search"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 mh-current-folder
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 t)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (switch-to-buffer-other-window "pick-pattern")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (if (or (zerop (buffer-size))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (not (y-or-n-p "Reuse pattern? ")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (mh-make-pick-template)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (message ""))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
67 (setq mh-searching-folder folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
68 (message "%s" (substitute-command-keys
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
69 (concat "Type \\[mh-do-pick-search] to search messages, "
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
70 "\\[mh-help] for help."))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (defun mh-make-pick-template ()
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
73 "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
74 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (insert "From: \n"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 "To: \n"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 "Cc: \n"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 "Date: \n"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 "Subject: \n"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 "---------\n")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (mh-pick-mode)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (goto-char (point-min))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (end-of-line))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
85 ;;; 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
86 (easy-menu-define
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
87 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
88 '("Pick"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
89 ["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
90
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
91
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
92 ;;; Help Messages
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
93 ;;; Group messages logically, more or less.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
94 (defvar mh-pick-mode-help-messages
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
95 '((nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
96 "Search messages: \\[mh-do-pick-search]\n"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
97 "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
98 "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
99 "Key binding cheat sheet.
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 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
102 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
103 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
104 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
105 non-prefixed commands.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
106
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
107 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
108 well.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
109
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (put 'mh-pick-mode 'mode-class 'special)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
112 (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
113 "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
114
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
115 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
116 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
117 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
118 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
119 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
120 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
121
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
122 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
123 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
124
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
125 \\{mh-pick-mode-map}"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
126
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (make-local-variable 'mh-searching-folder)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
128 (easy-menu-add mh-pick-menu)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
129 (make-local-variable 'mh-help-messages)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
130 (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
131 (run-hooks 'mh-pick-mode-hook))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (defun mh-do-pick-search ()
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 "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
135 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
136 Add the messages found to the sequence named `search'."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (interactive)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (let ((pattern-buffer (buffer-name))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (searching-buffer mh-searching-folder)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
140 range
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
141 msgs
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (pattern nil)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (new-buffer nil))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (cond ((get-buffer searching-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (set-buffer searching-buffer)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
147 (setq range (list (format "%d-%d"
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
148 mh-first-msg-num mh-last-msg-num))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (t
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (mh-make-folder searching-buffer)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
151 (setq range '("all"))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (setq new-buffer t))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (message "Searching...")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (goto-char (point-min))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
155 (while (and range
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
156 (setq pattern (mh-next-pick-field pattern-buffer)))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (setq msgs (mh-seq-from-command searching-buffer
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 'search
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
159 (mh-list-to-string
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
160 (list "pick" pattern searching-buffer
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
161 "-list"
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
162 (mh-coalesce-msg-list range)))))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
163 (setq range msgs)) ;restrict the pick range for next pass
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (message "Searching...done")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (if new-buffer
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (mh-scan-folder searching-buffer msgs)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (switch-to-buffer searching-buffer))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
168 (mh-add-msgs-to-seq msgs 'search)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
169 (delete-other-windows)))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
171 (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
172 "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
173 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
174 and the subsequent elements are its arguments, all strings."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (let ((msg)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (msgs ())
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (case-fold-search t))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (save-window-excursion
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
180 (if (eq 0 (apply 'mh-exec-cmd-quiet nil command))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
181 ;; "pick" outputs one number per line
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (while (setq msg (car (mh-read-msg-list)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (setq msgs (cons msg msgs))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (forward-line 1))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (set-buffer folder)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
186 (setq msgs (nreverse msgs)) ;put in ascending order
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 msgs)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (defun mh-next-pick-field (buffer)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
190 "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
191 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
192 or nil if no pieces remain."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (set-buffer buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (let ((case-fold-search t))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (cond ((eobp)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 nil)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
197 ((re-search-forward "^\\([a-z][^: \t\n]*\\):[ \t]*\\([a-z0-9].*\\)$"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
198 nil t)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (let* ((component
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (format "--%s"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (downcase (buffer-substring (match-beginning 1)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (match-end 1)))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (pat (buffer-substring (match-beginning 2) (match-end 2))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (forward-line 1)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (list component pat)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 ((re-search-forward "^-*$" nil t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (forward-char 1)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (let ((body (buffer-substring (point) (point-max))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (if (and (> (length body) 0) (not (equal body "\n")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (list "-search" body)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 nil)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (t
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 nil))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
215
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
216
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 ;;; Build the pick-mode keymap:
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
218 ;;; 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
219 (gnus-define-keys mh-pick-mode-map
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
220 "\C-c?" mh-help
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
221 "\C-c\C-c" mh-do-pick-search
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
222 "\C-c\C-f\C-b" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
223 "\C-c\C-f\C-c" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
224 "\C-c\C-f\C-d" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
225 "\C-c\C-f\C-f" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
226 "\C-c\C-f\C-r" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
227 "\C-c\C-f\C-s" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
228 "\C-c\C-f\C-t" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
229 "\C-c\C-fb" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
230 "\C-c\C-fc" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
231 "\C-c\C-fd" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
232 "\C-c\C-ff" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
233 "\C-c\C-fr" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
234 "\C-c\C-fs" mh-to-field
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42206
diff changeset
235 "\C-c\C-ft" mh-to-field)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
237 (provide 'mh-pick)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
238
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
239 ;;; Local Variables:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
240 ;;; sentence-end-double-space: nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
241 ;;; End:
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 14169
diff changeset
242
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 14169
diff changeset
243 ;;; mh-pick.el ends here