annotate lisp/mail/mh-utils.el @ 47759:b2674275598d

(keyremap): New struct. (read_key_sequence): Use it: globally replace keytran_foo with keytran.foo and fkey_foo with fkey.foo. Rename temp vars keytran_next and fkey_next to just `next'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 04 Oct 2002 21:49:47 +0000
parents 2568d5a27317
children 8aaba207e44b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; mh-utils.el --- mh-e code needed for both sending and reading
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
3 ;; Copyright (C) 1993, 1995, 1997, 2000, 2001, 2002 Free Software Foundation, Inc.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
4
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
5 ;; Author: Bill Wohler <wohler@newt.com>
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
6 ;; Maintainer: Bill Wohler <wohler@newt.com>
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
7 ;; Keywords: mail
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
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: 37178
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: 11331
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: 11331
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: 14118
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: 14118
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14118
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
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; Internal support for mh-e package.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
31 ;;; Change Log:
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
32
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
33 ;; $Id: mh-utils.el,v 1.79 2002/04/07 19:20:56 wohler Exp $
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
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
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
37 (load "executable" t t) ; Non-fatal dependency on
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
38 ; executable-find
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
39
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
40 ;;; Autoload mh-seq
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
41
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
42 (autoload 'mh-add-to-sequence "mh-seq")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
43 (autoload 'mh-notate-seq "mh-seq")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
44 (autoload 'mh-read-seq-default "mh-seq")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
45 (autoload 'mh-map-to-seq-msgs "mh-seq")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
46
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
47 ;;; Other Autoloads
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
48
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
49 (autoload 'mail-header-end "sendmail")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
50
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
51 ;;; Set for local environment:
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
52 ;;; mh-progs and mh-lib used to be set in paths.el, which tried to
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
53 ;;; figure out at build time which of several possible directories MH
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
54 ;;; was installed into. But if you installed MH after building Emacs,
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
55 ;;; this would almost certainly be wrong, so now we do it at run time.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
57 (defvar mh-progs nil
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
58 "Directory containing MH commands, such as inc, repl, and rmm.")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
60 (defvar mh-lib nil
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
61 "Directory containing the MH library.
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
62 This directory contains, among other things,
24420
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
63 the components file.")
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
64
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
65 (defvar mh-lib-progs nil
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
66 "Directory containing MH helper programs.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
67 This directory contains, among other things,
24420
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
68 the mhl program.")
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
69
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
70 (defvar mh-nmh-p nil
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
71 "Non-nil if nmh is installed on this system instead of MH.")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
73 ;;;###autoload
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
74 (put 'mh-progs 'risky-local-variable t)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
75 ;;;###autoload
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
76 (put 'mh-lib 'risky-local-variable t)
24420
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
77 ;;;###autoload
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
78 (put 'mh-lib-progs 'risky-local-variable t)
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
79 ;;;###autoload
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
80 (put 'mh-nmh-p 'risky-local-variable t)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
81
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
82 ;;; User preferences:
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
17426
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
84 (defgroup mh-buffer nil
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
85 "Layout of MH-E buffers"
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
86 :prefix "mh-"
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
87 :group 'mh)
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
88
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
89
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
90 (defcustom mh-auto-folder-collect t
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 "*Whether to start collecting MH folder names immediately in the background.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 Non-nil means start a background process collecting the names of all
17426
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
93 folders as soon as mh-e is loaded."
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
94 :type 'boolean
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
95 :group 'mh)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96
17426
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
97 (defcustom mh-recursive-folders nil
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
98 "*If non-nil, then commands which operate on folders do so recursively."
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
99 :type 'boolean
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
100 :group 'mh)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
102 (defcustom mh-clean-message-header t
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 "*Non-nil means clean headers of messages that are displayed or inserted.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 The variables `mh-visible-headers' and `mh-invisible-headers' control what
17426
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
105 is removed."
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
106 :type 'boolean
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
107 :group 'mh-buffer)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108
17426
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
109 (defcustom mh-visible-headers nil
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 "*If non-nil, contains a regexp specifying the headers to keep when cleaning.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 Only used if `mh-clean-message-header' is non-nil. Setting this variable
17426
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
112 overrides `mh-invisible-headers'."
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
113 :type '(choice (const nil) regexp)
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
114 :group 'mh-buffer)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (defvar mh-invisible-headers
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
117 (concat
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
118 "^"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
119 (let ((max-specpdl-size 1000)) ;workaround for insufficient default
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
120 (regexp-opt
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
121 '( ;; RFC 822
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
122 "Received: " "Message-Id: " "Return-Path: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
123 ;; RFC 2045
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
124 "Mime-Version" "Content-"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
125 ;; sendmail
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
126 "X-Authentication-Warning: " "X-MIME-Autoconverted: " "From "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
127 "Status: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
128 ;; X400
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
129 "X400-" "P1-Message-Id: " "Original-Encoded-Information-Types: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
130 "P1-Recipient: " "P1-Content-Type: " "Ua-Content-Id: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
131 ;; MH
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
132 "Resent" "Prev-Resent" "Forwarded: " "Replied: " "Delivery-Date: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
133 "In-Reply-To: " "Remailed-" "Via: " "Mail-from: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
134 ;; gnus
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
135 "X-Gnus-Mail-Source: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
136 ;; MS Outlook
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
137 "X-Priority: " "X-Msmail-" "X-MimeOLE: " "X-Apparently-From: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
138 "Importance: " "Sensitivity: " "X-MS-TNEF-Correlator: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
139 ;; Juno
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
140 "X-Juno-"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
141 ;; Hotmail
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
142 "X-OriginalArrivalTime: " "X-Originating-IP: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
143 ;; Netscape/Mozilla
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
144 "X-Accept-Language: " "X-Mozilla-Status: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
145 ;; NTMail
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
146 "X-Info: " "X-VSMLoop: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
147 ;; News
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
148 "NNTP-" "X-News: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
149 ;; Mailman mailing list manager
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
150 "List-" "X-Beenthere: " "X-Mailman-Version: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
151 ;; Egroups/yahoogroups mailing list manager
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
152 "X-eGroups-" "X-Apparently-To: " "Mailing-List: " "Delivered-To: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
153 ;; SourceForge mailing list manager
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
154 "X-Original-Date: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
155 ;; Unknown mailing list managers
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
156 "X-Mailing-List: " "X-Loop: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
157 "List-Subscribe: " "List-Unsubscribe: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
158 "X-List-Subscribe: " "X-List-Unsubscribe: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
159 "X-Listserver: " "List-" "X-List-Host: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
160 ;; Sieve filtering
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
161 "X-Sieve: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
162 ;; Worldtalk gateways
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
163 "X-Wss-Id: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
164 ;; User added
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
165 "X-Face: " "X-Qotd-"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
166 ;; Miscellaneous
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
167 "X-Sender: " "X-Ack: " "Errors-To: " "Precedence: " "X-Message-Id"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
168 "X-From-Line" "X-Cron-Env: " "Delivery: " "X-Delivered"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
169 "X-Received: " "X-Vms-To: " "Xref: " "X-Request-" "X-UIDL: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
170 "X-Orcl-Content-Type: " "X-Server-Uuid: " "X-Envelope-Sender: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
171 "X-Envelope-To: " "Encoding: " "Old-Return-Path: " "Path: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
172 "References: " "Lines: " "Autoforwarded: " "Bestservhost: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
173 "X-pgp: " "X-Accept-Language: " "Priority: " "User-Agent: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
174 "X-MIMETrack: " "X-Abuse-Info: " "X-Complaints-To: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
175 "X-No-Archive: " "X-Original-Complaints-To: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
176 "X-Original-Trace: " "X-Received-Date: " "X-Server-Date: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
177 "X-Trace: " "X-UserInfo1: " "X-submission-address: ")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
178 t)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
179 "*Regexp matching lines in a message header that are not to be shown.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 If `mh-visible-headers' is non-nil, it is used instead to specify what
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 to keep.")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
183 ;;; Additional header fields that might someday be added:
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
184 ;;; "Sender: " "Reply-to: "
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
185
17426
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
186 (defcustom mh-bury-show-buffer t
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
187 "*Non-nil means that the displayed show buffer for a folder is buried."
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
188 :type 'boolean
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
189 :group 'mh-buffer)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
191 (defcustom mh-summary-height (or (and (fboundp 'frame-height)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
192 (> (frame-height) 24)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
193 (min 10 (/ (frame-height) 6)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
194 4)
17426
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
195 "*Number of lines in MH-Folder window (including the mode line)."
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
196 :type 'integer
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
197 :group 'mh-buffer)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
199 ;; Use goto-addr if it was already loaded (which probably sets this
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
200 ;; variable to t), or if this variable is otherwise set to t.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
201 (defcustom mh-show-use-goto-addr (and (boundp 'goto-address-highlight-p)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
202 goto-address-highlight-p)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
203 "*Non-nil means URLs and e-mail addresses are highlighted using goto-addr while in mh-show-mode."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
204 :type 'boolean
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
205 :group 'mh-buffer)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
206
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
207 (defvar mh-scan-msg-number-regexp "^ *\\([0-9]+\\)"
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 "Regexp to find the number of a message in a scan line.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 The message's number must be surrounded with \\( \\)")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
211 (defvar mh-scan-msg-search-regexp "^[^0-9]*%d[^0-9]"
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 "Format string containing a regexp matching the scan listing for a message.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 The desired message's number will be an argument to format.")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
17426
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
215 (defcustom mhl-formfile nil
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 "*Name of format file to be used by mhl to show and print messages.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
217 A value of T means use the default format file.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
218 Nil means don't use mhl to format messages when showing; mhl is still used,
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 with the default format file, to format messages when printing them.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 The format used should specify a non-zero value for overflowoffset so
17426
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
221 the message continues to conform to RFC 822 and mh-e can parse the headers."
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
222 :type '(choice (const nil) (const t) string)
5c5fa38a1c79 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17243
diff changeset
223 :group 'mh)
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
224 (put 'mhl-formfile 'info-file "mh-e")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
226 (defvar mh-decode-quoted-printable-have-mimedecode
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
227 (not (null (and (fboundp 'executable-find)(executable-find "mimedecode"))))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
228 "Whether the mimedecode command is installed on the system.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
229 This sets the default value of variable `mh-decode-quoted-printable' to
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
230 determine whether quoted-printable MIME parts are decode when viewed in
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
231 `mh-show'. The source code for mimedecode can be obtained from
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
232 http://www.freesoft.org/CIE/FAQ/mimedeco.c")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
233
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
234 (defcustom mh-decode-quoted-printable
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
235 mh-decode-quoted-printable-have-mimedecode
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
236 "Whether to decode quoted-printable MIME parts in `mh-show'.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
237 This can only be done if the 'mimedecode' command is available in the
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
238 executable path on the system (the mh-decode-quoted-printable-have-mimedecode
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
239 variable is set if the command was found). That program is used as a helper
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
240 program to achieve this. The source code for mimedecode can usually be
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
241 obtained from http://www.freesoft.org/CIE/FAQ/mimedeco.c"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
242 :type 'boolean
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
243 :group 'mh-buffer)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
244
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
245 (defcustom mh-update-sequences-after-mh-show t
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
246 "Whether to call `mh-update-sequence' in `mh-show-mode'.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
247 If set, `mh-update-sequence' is run every time a message is shown, telling
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
248 MH or nmh that this is your current message. It's useful, for example, to
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
249 display MIME content using \"M-! mhshow RET\""
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
250 :type 'boolean
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
251 :group 'mh-buffer)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
252
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
253 (defcustom mh-highlight-citation-p 'gnus
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
254 "How to highlight citations in show buffers.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
255 The gnus method uses a different color for each indentation."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
256 :type '(choice (const :tag "Use gnus" gnus)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
257 (const :tag "Use font-lock" font-lock)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
258 (const :tag "Don't fontify" nil))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
259 :group 'mh-buffer)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
260
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
261 (defvar mh-default-folder-for-message-function nil
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
262 "Function to select a default folder for refiling or Fcc.
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
263 If set to a function, that function is called with no arguments by
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
264 `\\[mh-refile-msg]' and `\\[mh-to-fcc]' to get a default when
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
265 prompting the user for a folder. The function is called from within a
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
266 `save-excursion', with point at the start of the message. It should
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
267 return the folder to offer as the refile or Fcc folder, as a string
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
268 with a leading `+' sign. It can also return an empty string to use no
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
269 default, or NIL to calculate the default the usual way.
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
270 NOTE: This variable is not an ordinary hook;
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
271 It may not be a list of functions.")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
273 (defvar mh-find-path-hook nil
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
274 "Invoked by `mh-find-path' while reading the user's MH profile.")
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
275
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
276 (defvar mh-folder-list-change-hook nil
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
277 "Invoked whenever the cached folder list `mh-folder-list' is changed.")
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
278
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
279 (defvar mh-show-buffer-mode-line-buffer-id "{show-%s} %d"
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
280 "Format string to produce `mode-line-buffer-identification' for show buffers.
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
281 First argument is folder name. Second is message number.")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (defvar mh-cmd-note 4
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 "Offset to insert notation.")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
286 (defvar mh-note-seq "%"
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
287 "String whose first character is used to notate messages in a sequence.")
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
288
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
289 (defvar mh-mail-header-separator "--------"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
290 "*Line used by MH to separate headers from text in messages being composed.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
291 This variable should not be used directly in programs. Programs should use
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
292 `mail-header-separator' instead. `mail-header-separator' is initialized to
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
293 `mh-mail-header-separator' in `mh-letter-mode'; in other contexts, you may
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
294 have to perform this initialization yourself.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
295
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
296 Do not make this a regexp as it may be the argument to `insert' and it is
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
297 passed through `regexp-quote' before being used by functions like
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
298 `re-search-forward'.")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
299
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
300 (defun mh-in-header-p ()
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
301 ;; Return non-nil if the point is in the header of a draft message.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
302 (< (point) (mail-header-end)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
303
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
304 (defun mh-header-field-end ()
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
305 ;; Move to the end of the current header field.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
306 ;; Handles RFC 822 continuation lines.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
307 (forward-line 1)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
308 (while (looking-at "^[ \t]")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
309 (forward-line 1))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
310 (backward-char 1)) ;to end of previous line
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
311
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
312 (defun mh-letter-header-font-lock (limit)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
313 "Return the entire mail header to font-lock.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
314 Argument LIMIT limits search."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
315 (if (= (point) limit)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
316 nil
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
317 (let* ((mail-header-end (save-match-data (mail-header-end)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
318 (lesser-limit (if (< mail-header-end limit) mail-header-end limit)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
319 (when (mh-in-header-p)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
320 (set-match-data (list 1 lesser-limit))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
321 (goto-char lesser-limit)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
322 t))))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
323
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
324 (defun mh-header-field-font-lock (field limit)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
325 "Return the value of a header field FIELD to font-lock.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
326 Argument LIMIT limits search."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
327 (if (= (point) limit)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
328 nil
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
329 (let* ((mail-header-end (mail-header-end))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
330 (lesser-limit (if (< mail-header-end limit) mail-header-end limit))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
331 (case-fold-search t))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
332 (when (and (< (point) mail-header-end) ;Only within header
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
333 (re-search-forward (format "^%s" field) lesser-limit t))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
334 (let ((match-one-b (match-beginning 0))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
335 (match-one-e (match-end 0)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
336 (mh-header-field-end)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
337 (if (> (point) limit) ;Don't search for end beyond limit
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
338 (goto-char limit))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
339 (set-match-data (list match-one-b match-one-e
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
340 (1+ match-one-e) (point)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
341 t)))))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
342
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
343 (defun mh-header-to-font-lock (limit)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
344 (mh-header-field-font-lock "To:" limit))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
345
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
346 (defun mh-header-cc-font-lock (limit)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
347 (mh-header-field-font-lock "cc:" limit))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
348
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
349 (defun mh-header-subject-font-lock (limit)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
350 (mh-header-field-font-lock "Subject:" limit))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
351
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
352 (defvar mh-show-to-face 'mh-show-to-face
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
353 "Face for highlighting the To: header field.")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
354 (if (boundp 'facemenu-unlisted-faces)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
355 (add-to-list 'facemenu-unlisted-faces "^mh-show"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
356 (defface mh-show-to-face
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
357 '((((class grayscale) (background light))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
358 (:foreground "DimGray" :underline t))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
359 (((class grayscale) (background dark))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
360 (:foreground "LightGray" :underline t))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
361 (((class color) (background light)) (:foreground "SaddleBrown"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
362 (((class color) (background dark)) (:foreground "burlywood"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
363 (t (:underline t)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
364 "Face for highlighting the To: header field."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
365 :group 'mh-buffer)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
366
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
367 (defvar mh-show-from-face 'mh-show-from-face
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
368 "Face for highlighting the From: header field.")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
369 (defface mh-show-from-face
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
370 '((((class color) (background light))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
371 (:foreground "red3"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
372 (((class color) (background dark))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
373 (:foreground "cyan"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
374 (t
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
375 (:bold t)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
376 "Face for highlighting the From: header field."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
377 :group 'mh-buffer)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
378
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
379 (defvar mh-folder-subject-face 'mh-folder-subject-face
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
380 "Face for highlighting subject text in MH-Folder buffers.")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
381 (if (boundp 'facemenu-unlisted-faces)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
382 (add-to-list 'facemenu-unlisted-faces "^mh-folder"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
383 (defface mh-folder-subject-face
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
384 '((((class color) (background light))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
385 (:foreground "blue4"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
386 (((class color) (background dark))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
387 (:foreground "yellow"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
388 (t
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
389 (:bold t)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
390 "Face for highlighting subject text in MH-Folder buffers."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
391 :group 'mh)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
392 (defvar mh-show-subject-face 'mh-show-subject-face
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
393 "Face for highlighting the Subject header field.")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
394 (copy-face 'mh-folder-subject-face 'mh-show-subject-face)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
395
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
396 (eval-after-load "font-lock"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
397 '(progn
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
398 (defvar mh-show-cc-face 'mh-show-cc-face
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
399 "Face for highlighting cc header fields.")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
400 (copy-face 'font-lock-variable-name-face 'mh-show-cc-face)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
401 (defvar mh-show-date-face 'mh-show-date-face
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
402 "Face for highlighting the Date header field.")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
403 (copy-face 'font-lock-type-face 'mh-show-date-face)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
404 (defvar mh-show-header-face 'mh-show-header-face
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
405 "Face used to deemphasize unspecified header fields.")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
406 (copy-face 'font-lock-string-face 'mh-show-header-face)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
407
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
408 (defvar mh-show-font-lock-keywords
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
409 '(("^\\(From:\\|Sender:\\)\\(.*\\)"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
410 (1 'default) (2 mh-show-from-face))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
411 (mh-header-to-font-lock
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
412 (0 'default) (1 mh-show-to-face))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
413 (mh-header-cc-font-lock
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
414 (0 'default) (1 mh-show-cc-face))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
415 ("^\\(Reply-To:\\|Return-Path:\\)\\(.*\\)$"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
416 (1 'default) (2 mh-show-from-face))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
417 (mh-header-subject-font-lock
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
418 (0 'default) (1 mh-show-subject-face))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
419 ("^\\(Apparently-To:\\|Newsgroups:\\)\\(.*\\)"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
420 (1 'default) (2 mh-show-cc-face))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
421 ("^\\(In-reply-to\\|Date\\):\\(.*\\)$"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
422 (1 'default) (2 mh-show-date-face))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
423 (mh-letter-header-font-lock (0 mh-show-header-face append t)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
424 "Additional expressions to highlight in MH-show mode.")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
425
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
426 (defvar mh-show-font-lock-keywords-with-cite
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
427 (eval-when-compile
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
428 (let* ((cite-chars "[>|}]")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
429 (cite-prefix "A-Za-z")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
430 (cite-suffix (concat cite-prefix "0-9_.@-`'\"")))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
431 (append
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
432 mh-show-font-lock-keywords
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
433 (list
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
434 ;; Use MATCH-ANCHORED to effectively anchor the regexp left side.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
435 `(,cite-chars
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
436 (,(concat "\\=[ \t]*"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
437 "\\(\\([" cite-prefix "]+[" cite-suffix "]*\\)?"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
438 "\\(" cite-chars "[ \t]*\\)\\)+"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
439 "\\(.*\\)")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
440 (beginning-of-line) (end-of-line)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
441 (2 font-lock-constant-face nil t)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
442 (4 font-lock-comment-face nil t)))))))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
443 "Additional expressions to highlight in MH-show mode.")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
444 ))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
445
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
446 (defun mh-gnus-article-highlight-citation ()
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
447 "Highlight cited text in current buffer using gnus."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
448 (interactive)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
449 (require 'gnus-cite)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
450 (let ((modified (buffer-modified-p))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
451 (gnus-article-buffer (buffer-name))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
452 (gnus-cite-face-list
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
453 '(gnus-cite-face-2 gnus-cite-face-3 gnus-cite-face-4 gnus-cite-face-5
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
454 gnus-cite-face-6 gnus-cite-face-7 gnus-cite-face-8 gnus-cite-face-9
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
455 gnus-cite-face-10 gnus-cite-face-11 gnus-cite-face-1)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
456 (gnus-article-highlight-citation t)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
457 (set-buffer-modified-p modified)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
458
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
459 ;;; Internal bookkeeping variables:
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
461 ;; The value of `mh-folder-list-change-hook' is called whenever
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
462 ;; mh-folder-list variable is set.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
463 ;; List of folder names for completion.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
464 (defvar mh-folder-list nil)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
465
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
466 ;; Cached value of the `Path:' component in the user's MH profile.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
467 ;; User's mail folder directory.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
468 (defvar mh-user-path nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
470 ;; An mh-draft-folder of NIL means do not use a draft folder.
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
471 ;; Cached value of the `Draft-Folder:' component in the user's MH profile.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
472 ;; Name of folder containing draft messages.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
473 (defvar mh-draft-folder nil)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
474
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
475 ;; Cached value of the `Unseen-Sequence:' component in the user's MH profile.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
476 ;; Name of the Unseen sequence.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
477 (defvar mh-unseen-seq nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
479 ;; Cached value of the `Previous-Sequence:' component in the user's MH
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
480 ;; profile.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
481 ;; Name of the Previous sequence.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
482 (defvar mh-previous-seq nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
484 ;; Cached value of the `Inbox:' component in the user's MH profile,
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
485 ;; or "+inbox" if no such component.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
486 ;; Name of the Inbox folder.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
487 (defvar mh-inbox nil)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
488
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
489 ;; Name of mh-e scratch buffer.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
490 (defconst mh-temp-buffer " *mh-temp*")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
491
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
492 ;; Name of the mh-e folder list buffer.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
493 (defconst mh-temp-folders-buffer "*Folders*")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
495 ;; Name of the mh-e sequences list buffer.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
496 (defconst mh-temp-sequences-buffer "*Sequences*")
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
497
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
498 ;; Window configuration before mh-e command.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
499 (defvar mh-previous-window-config nil)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
500
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
501 ;;Non-nil means next SPC or whatever goes to next undeleted message.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
502 (defvar mh-page-to-next-msg-p nil)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
503
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
504 ;;; Internal variables local to a folder.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
506 ;; Name of current folder, a string.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
507 (defvar mh-current-folder nil)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
508
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
509 ;; Buffer that displays message for this folder.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
510 (defvar mh-show-buffer nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
512 ;; Full path of directory for this folder.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
513 (defvar mh-folder-filename nil)
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
514
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
515 ;;Number of msgs in buffer.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
516 (defvar mh-msg-count nil)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
517
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
518 ;; If non-nil, show the message in a separate window.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
519 (defvar mh-showing-mode nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
521 ;;; This holds a documentation string used by describe-mode.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
522 (defun mh-showing-mode (&optional arg)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
523 "Change whether messages should be displayed.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
524 With arg, display messages iff ARG is positive."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
525 (setq mh-showing-mode
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
526 (if (null arg)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
527 (not mh-showing-mode)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
528 (> (prefix-numeric-value arg) 0))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
530 ;; The sequences of this folder. An alist of (seq . msgs).
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
531 (defvar mh-seq-list nil)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
532
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
533 ;; List of displayed messages to be removed from the Unseen sequence.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
534 (defvar mh-seen-list nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
536 ;; If non-nil, show buffer contains message with all headers.
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
537 ;; If nil, show buffer contains message processed normally.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
538 ;; Showing message with headers or normally.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
539 (defvar mh-showing-with-headers nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
542 ;;; mh-e macros
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
543
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
544 (defmacro with-mh-folder-updating (save-modification-flag-p &rest body)
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
545 ;; Format is (with-mh-folder-updating (SAVE-MODIFICATION-FLAG-P) &body BODY).
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
546 ;; Execute BODY, which can modify the folder buffer without having to
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
547 ;; worry about file locking or the read-only flag, and return its result.
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
548 ;; If SAVE-MODIFICATION-FLAG-P is non-nil, the buffer's modification
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
549 ;; flag is unchanged, otherwise it is cleared.
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
550 (setq save-modification-flag-p (car save-modification-flag-p)) ; CL style
26455
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
551 `(prog1
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
552 (let ((mh-folder-updating-mod-flag (buffer-modified-p))
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
553 (buffer-read-only nil)
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
554 (buffer-file-name nil)) ;don't let the buffer get locked
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
555 (prog1
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
556 (progn
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
557 ,@body)
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
558 (mh-set-folder-modified-p mh-folder-updating-mod-flag)))
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
559 ,@(if (not save-modification-flag-p)
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
560 '((mh-set-folder-modified-p nil)))))
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
561
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
562 (put 'with-mh-folder-updating 'lisp-indent-hook 1)
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
563
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
564 (defmacro mh-in-show-buffer (show-buffer &rest body)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
565 ;; Format is (mh-in-show-buffer (SHOW-BUFFER) &body BODY).
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
566 ;; Display buffer SHOW-BUFFER in other window and execute BODY in it.
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
567 ;; Stronger than save-excursion, weaker than save-window-excursion.
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
568 (setq show-buffer (car show-buffer)) ; CL style
26455
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
569 `(let ((mh-in-show-buffer-saved-window (selected-window)))
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
570 (switch-to-buffer-other-window ,show-buffer)
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
571 (if mh-bury-show-buffer (bury-buffer (current-buffer)))
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
572 (unwind-protect
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
573 (progn
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
574 ,@body)
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25146
diff changeset
575 (select-window mh-in-show-buffer-saved-window))))
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
576
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
577 (put 'mh-in-show-buffer 'lisp-indent-hook 1)
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
578
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
579 (defmacro mh-make-seq (name msgs) (list 'cons name msgs))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
580
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
581 (defmacro mh-seq-name (pair) (list 'car pair))
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
582
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
583 (defmacro mh-seq-msgs (pair) (list 'cdr pair))
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
584
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
585
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 ;;; Ensure new buffers won't get this mode if default-major-mode is nil.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (put 'mh-show-mode 'mode-class 'special)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
589 (define-derived-mode mh-show-mode text-mode "MH-Show"
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 "Major mode for showing messages in mh-e.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
591 The value of `mh-show-mode-hook' is called when a new message is displayed."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
592 (set (make-local-variable 'mail-header-separator) mh-mail-header-separator)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
593 (mh-show-unquote-From)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
594 (when mh-show-use-goto-addr
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
595 (if (not (featurep 'goto-addr))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
596 (load "goto-addr" t t))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
597 (if (fboundp 'goto-address)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
598 (goto-address)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
599 (make-local-variable 'font-lock-defaults)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
600 (set (make-local-variable 'font-lock-support-mode) nil)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
601 (cond
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
602 ((equal mh-highlight-citation-p 'font-lock)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
603 (setq font-lock-defaults '(mh-show-font-lock-keywords-with-cite t)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
604 ((equal mh-highlight-citation-p 'gnus)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
605 (setq font-lock-defaults '(mh-show-font-lock-keywords t))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
606 (mh-gnus-article-highlight-citation))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
607 (t
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
608 (setq font-lock-defaults '(mh-show-font-lock-keywords t)))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (defun mh-maybe-show (&optional msg)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 ;; If in showing mode, then display the message pointed to by the cursor.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
612 (if mh-showing-mode (mh-show msg)))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
614 (defun mh-show (&optional message)
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
615 "Show MESSAGE (default: message at cursor).
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
616 Force a two-window display with the folder window on top (size
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
617 `mh-summary-height') and the show buffer below it.
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
618 If the message is already visible, display the start of the message.
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
619
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
620 Display of the message is controlled by setting the variables
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
621 `mh-clean-message-header' and `mhl-formfile'. The default behavior is
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
622 to scroll uninteresting headers off the top of the window.
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
623 Type \"\\[mh-header-display]\" to see the message with all its headers."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 (interactive)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 (and mh-showing-with-headers
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 (or mhl-formfile mh-clean-message-header)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 (mh-invalidate-show-buffer))
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
628 (mh-show-msg message))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
630 (defun mh-show-mouse (EVENT)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
631 "Move point to mouse EVENT and show message."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
632 (interactive "e")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
633 (mouse-set-point EVENT)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
634 (mh-show))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 (defun mh-show-msg (msg)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (if (not msg)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (setq msg (mh-get-msg-num t)))
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
639 (mh-showing-mode t)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
640 (setq mh-page-to-next-msg-p nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 (let ((folder mh-current-folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (clean-message-header mh-clean-message-header)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 (show-window (get-buffer-window mh-show-buffer)))
18926
e597d4b325df Change eql calls to eq.
Richard M. Stallman <rms@gnu.org>
parents: 18901
diff changeset
644 (if (not (eq (next-window (minibuffer-window)) (selected-window)))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 (delete-other-windows)) ; force ourself to the top window
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 (mh-in-show-buffer (mh-show-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (if (and show-window
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (equal (mh-msg-filename msg folder) buffer-file-name))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 (progn ;just back up to start
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (goto-char (point-min))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (if (not clean-message-header)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 (mh-start-of-uncleaned-message)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (mh-display-msg msg folder))))
42323
c86cd54b5c50 (mh-show-msg): Likewise.
Pavel Janík <Pavel@Janik.cz>
parents: 42205
diff changeset
654 (if (not (= (1+ (window-height)) (frame-height))) ;not horizontally split
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (shrink-window (- (window-height) mh-summary-height)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 (mh-recenter nil)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (if (not (memq msg mh-seen-list)) (setq mh-seen-list (cons msg mh-seen-list)))
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
658 (when mh-update-sequences-after-mh-show
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
659 (mh-update-sequences))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 (run-hooks 'mh-show-hook))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
663 (defun mh-decode-quoted-printable ()
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
664 ;; Run mimedecode commmand on current buffer, replacing it contents.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
665 (let ((case-fold-search t))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
666 (goto-char (point-min))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
667 (when (and (re-search-forward
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
668 "^content-transfer-encoding:[ \t]*quoted-printable"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
669 nil t)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
670 (search-forward "\n\n" nil t))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
671 (message "Converting quoted-printable characters...")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
672 (let ((modified (buffer-modified-p))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
673 (command "mimedecode"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
674 (shell-command-on-region (point-min) (point-max) command t t)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
675 (if (fboundp 'deactivate-mark)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
676 (deactivate-mark))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
677 (set-buffer-modified-p modified))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
678 (message "Converting quoted-printable characters... done."))))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
679
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
680
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
681 (defun mh-show-unquote-From ()
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
682 ;; Decode >From at beginning of lines for mh-show-mode
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
683 (save-excursion
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
684 (let ((modified (buffer-modified-p))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
685 (case-fold-search nil))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
686 (goto-char (mail-header-end))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
687 (while (re-search-forward "^>From" nil t)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
688 (replace-match "From"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
689 (set-buffer-modified-p modified))))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
690
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 (defun mh-display-msg (msg-num folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 ;; Display message NUMBER of FOLDER.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 ;; Sets the current buffer to the show buffer.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 (set-buffer folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 ;; Bind variables in folder buffer in case they are local
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (let ((formfile mhl-formfile)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 (clean-message-header mh-clean-message-header)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (invisible-headers mh-invisible-headers)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 (visible-headers mh-visible-headers)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (msg-filename (mh-msg-filename msg-num))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (show-buffer mh-show-buffer))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (if (not (file-exists-p msg-filename))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (error "Message %d does not exist" msg-num))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (set-buffer show-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (cond ((not (equal msg-filename buffer-file-name))
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
706 (mh-unvisit-file)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (erase-buffer)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
708 ;; Changing contents, so this hook needs to be reinitialized.
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
709 ;; pgp.el uses this.
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
710 (if (boundp 'write-contents-hooks) ;Emacs 19
14118
e7809b53da4d (mh-display-msg): Use kill-local-variable
Karl Heuer <kwzh@gnu.org>
parents: 13386
diff changeset
711 (kill-local-variable 'write-contents-hooks))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 (if formfile
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 (if (stringp formfile)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 (list "-form" formfile))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 msg-filename)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (insert-file-contents msg-filename))
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
718 (if mh-decode-quoted-printable
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
719 (mh-decode-quoted-printable))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (goto-char (point-min))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 (cond (clean-message-header
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 (mh-clean-msg-header (point-min)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 invisible-headers
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 visible-headers)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 (goto-char (point-min)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (t
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 (mh-start-of-uncleaned-message)))
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
728 ;; the parts of visiting we want to do (no locking)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 (or (eq buffer-undo-list t) ;don't save undo info for prev msgs
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 (setq buffer-undo-list nil))
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
731 (set-buffer-modified-p nil)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
732 (set-buffer-auto-saved)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
733 ;; the parts of set-visited-file-name we want to do (no locking)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 (setq buffer-file-name msg-filename)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
735 (setq buffer-backed-up nil)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
736 (auto-save-mode 1)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 (set-mark nil)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 (mh-show-mode)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (setq mode-line-buffer-identification
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 (list (format mh-show-buffer-mode-line-buffer-id
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 folder msg-num)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 (set-buffer folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (setq mh-showing-with-headers nil)))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 (defun mh-start-of-uncleaned-message ()
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 ;; position uninteresting headers off the top of the window
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 (let ((case-fold-search t))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 (re-search-forward
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
749 "^To:\\|^Cc:\\|^From:\\|^Subject:\\|^Date:" nil t)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 (beginning-of-line)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (mh-recenter 0)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 (defun mh-invalidate-show-buffer ()
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 ;; Invalidate the show buffer so we must update it to use it.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 (if (get-buffer mh-show-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (set-buffer mh-show-buffer)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
759 (mh-unvisit-file))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
762 (defun mh-unvisit-file ()
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
763 ;; Separate current buffer from the message file it was visiting.
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
764 (or (not (buffer-modified-p))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
765 (null buffer-file-name) ;we've been here before
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
766 (yes-or-no-p (format "Message %s modified; flush changes? "
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
767 (file-name-nondirectory buffer-file-name)))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
768 (error "Flushing changes not confirmed"))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
769 (clear-visited-file-modtime)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
770 (unlock-buffer)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
771 (setq buffer-file-name nil))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
772
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
773
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 (defun mh-get-msg-num (error-if-no-message)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 ;; Return the message number of the displayed message. If the argument
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 ;; ERROR-IF-NO-MESSAGE is non-nil, then complain if the cursor is not
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 ;; pointing to a message.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 (beginning-of-line)
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
780 (cond ((looking-at mh-scan-msg-number-regexp)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 (string-to-int (buffer-substring (match-beginning 1)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 (match-end 1))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 (error-if-no-message
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 (error "Cursor not pointing to message"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 (t nil))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 (defun mh-msg-filename (msg &optional folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 ;; Return the file name of MESSAGE in FOLDER (default current folder).
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 (expand-file-name (int-to-string msg)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 (if folder
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 (mh-expand-file-name folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 mh-folder-filename)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 (defun mh-clean-msg-header (start invisible-headers visible-headers)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 ;; Flush extraneous lines in a message header, from the given POINT to the
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 ;; end of the message header. If VISIBLE-HEADERS is non-nil, it contains a
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 ;; regular expression specifying the lines to display, otherwise
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 ;; INVISIBLE-HEADERS contains a regular expression specifying lines to
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 ;; delete from the header.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
802 (let ((case-fold-search t)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
803 (after-change-functions nil)) ;Work around emacs-20 font-lock bug
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
804 ;causing an endless loop.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 (save-restriction
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 (goto-char start)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 (if (search-forward "\n\n" nil 'move)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 (backward-char 1))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 (narrow-to-region start (point))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 (goto-char (point-min))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 (if visible-headers
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 (while (< (point) (point-max))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 (cond ((looking-at visible-headers)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (forward-line 1)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 (while (looking-at "[ \t]") (forward-line 1)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 (t
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 (mh-delete-line 1)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 (while (looking-at "[ \t]")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 (mh-delete-line 1)))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 (while (re-search-forward invisible-headers nil t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 (beginning-of-line)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 (mh-delete-line 1)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 (while (looking-at "[ \t]")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 (mh-delete-line 1))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 (unlock-buffer))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 (defun mh-recenter (arg)
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
829 ;; Like recenter but with two improvements:
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
830 ;; - only does anything if the current buffer is in the selected
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
831 ;; window. (Commands like save-some-buffers can make this false.)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
832 ;; - nil arg means recenter as with C-u prefix
18926
e597d4b325df Change eql calls to eq.
Richard M. Stallman <rms@gnu.org>
parents: 18901
diff changeset
833 (if (eq (get-buffer-window (current-buffer))
e597d4b325df Change eql calls to eq.
Richard M. Stallman <rms@gnu.org>
parents: 18901
diff changeset
834 (selected-window))
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
835 ;; '(4) is the same as C-u prefix argument.
40298
b4bc55a74924 (mh-recenter): Call recenter with arg `(4)'.
Gerd Moellmann <gerd@gnu.org>
parents: 40216
diff changeset
836 (recenter (if arg arg '(4)))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 (defun mh-delete-line (lines)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 ;; Delete version of kill-line.
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
841 (delete-region (point) (progn (forward-line lines) (point))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 (defun mh-notate (msg notation offset)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 ;; Marks MESSAGE with the character NOTATION at position OFFSET.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 ;; Null MESSAGE means the message that the cursor points to.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 (if (or (null msg)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 (mh-goto-msg msg t t))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 (with-mh-folder-updating (t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 (beginning-of-line)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 (forward-char offset)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 (delete-char 1)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 (insert notation)))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
856 (defun mh-find-msg-get-num (step)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
857 ;; Return the message number of the message on the current scan line
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
858 ;; or one nearby. Jumps over non-message lines, such as inc errors.
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
859 ;; STEP tells whether to search forward or backward if we have to search.
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
860 (or (mh-get-msg-num nil)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
861 (let ((msg-num nil)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
862 (nreverses 0))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
863 (while (and (not msg-num)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
864 (< nreverses 2))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
865 (cond ((eobp)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
866 (setq step -1)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
867 (setq nreverses (1+ nreverses)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
868 ((bobp)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
869 (setq step 1)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
870 (setq nreverses (1+ nreverses))))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
871 (forward-line step)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
872 (setq msg-num (mh-get-msg-num nil)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
873 msg-num)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
874
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 (defun mh-goto-msg (number &optional no-error-if-no-message dont-show)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 "Position the cursor at message NUMBER.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
877 Optional non-nil second argument NO-ERROR-IF-NO-MESSAGE means return nil
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
878 instead of signaling an error if message does not exist; in this case, the
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
879 cursor is positioned near where the message would have been.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
880 Non-nil third argument DONT-SHOW means not to show the message."
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
881 (interactive "NGo to message: ")
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
882 (setq number (prefix-numeric-value number)) ;Emacs 19
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
883 ;; This basic routine tries to be as fast as possible,
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
884 ;; using a binary search and minimal regexps.
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
885 (let ((cur-msg (mh-find-msg-get-num -1))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
886 (jump-size mh-msg-count))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
887 (while (and (> jump-size 1)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
888 cur-msg
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
889 (not (eq cur-msg number)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
890 (cond ((< cur-msg number)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
891 (setq jump-size (min (- number cur-msg)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
892 (ash (1+ jump-size) -1)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
893 (forward-line jump-size)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
894 (setq cur-msg (mh-find-msg-get-num 1)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
895 (t
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
896 (setq jump-size (min (- cur-msg number)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
897 (ash (1+ jump-size) -1)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
898 (forward-line (- jump-size))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
899 (setq cur-msg (mh-find-msg-get-num -1)))))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
900 (if (eq cur-msg number)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
901 (progn
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
902 (beginning-of-line)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
903 (or dont-show
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
904 (mh-maybe-show number)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
905 t))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
906 (if (not no-error-if-no-message)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
907 (error "No message %d" number)))))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
908
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 (defun mh-msg-search-pat (n)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 ;; Return a search pattern for message N in the scan listing.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
912 (format mh-scan-msg-search-regexp n))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
915 (defun mh-get-profile-field (field)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
916 ;; Find and return the value of FIELD in the current buffer.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
917 ;; Returns NIL if the field is not in the buffer.
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
918 (let ((case-fold-search t))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
919 (goto-char (point-min))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
920 (cond ((not (re-search-forward (format "^%s" field) nil t)) nil)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
921 ((looking-at "[\t ]*$") nil)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
922 (t
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
923 (re-search-forward "[\t ]*\\([^\t \n].*\\)$" nil t)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
924 (let ((start (match-beginning 1)))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
925 (end-of-line)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
926 (buffer-substring start (point)))))))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
927
25146
1fa062857a8d (mh-find-path-run): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24587
diff changeset
928 (defvar mail-user-agent)
34599
9266023b321c (mh-find-path): Set read-mail-command.
Gerd Moellmann <gerd@gnu.org>
parents: 27525
diff changeset
929 (defvar read-mail-command)
25146
1fa062857a8d (mh-find-path-run): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24587
diff changeset
930
1fa062857a8d (mh-find-path-run): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24587
diff changeset
931 (defvar mh-find-path-run nil
1fa062857a8d (mh-find-path-run): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24587
diff changeset
932 "Non-nil if `mh-find-path' has been run already.")
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
933
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 (defun mh-find-path ()
24420
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
935 ;; Set mh-progs, mh-lib, and mh-libs-progs
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 ;; (This step is necessary if MH was installed after this Emacs was dumped.)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
937 ;; From profile file, set mh-user-path, mh-draft-folder,
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
938 ;; mh-unseen-seq, mh-previous-seq, mh-inbox.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 (mh-find-progs)
25146
1fa062857a8d (mh-find-path-run): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24587
diff changeset
940 (unless mh-find-path-run
1fa062857a8d (mh-find-path-run): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24587
diff changeset
941 (setq mh-find-path-run t)
34599
9266023b321c (mh-find-path): Set read-mail-command.
Gerd Moellmann <gerd@gnu.org>
parents: 27525
diff changeset
942 (setq read-mail-command 'mh-rmail)
25146
1fa062857a8d (mh-find-path-run): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24587
diff changeset
943 (setq mail-user-agent 'mh-e-user-agent))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 ;; Be sure profile is fully expanded before switching buffers
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 (let ((profile (expand-file-name (or (getenv "MH") "~/.mh_profile"))))
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
947 (set-buffer (get-buffer-create mh-temp-buffer))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (setq buffer-offer-save nil) ;for people who set default to t
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 (condition-case err
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 (insert-file-contents profile)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 (file-error
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 (mh-install profile err)))
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
954 (setq mh-user-path (mh-get-profile-field "Path:"))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
955 (if (not mh-user-path)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 (setq mh-user-path "Mail"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 (setq mh-user-path
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 (file-name-as-directory
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 (expand-file-name mh-user-path (expand-file-name "~"))))
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
960 (setq mh-draft-folder (mh-get-profile-field "Draft-Folder:"))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
961 (if mh-draft-folder
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
962 (progn
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
963 (if (not (mh-folder-name-p mh-draft-folder))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
964 (setq mh-draft-folder (format "+%s" mh-draft-folder)))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
965 (if (not (file-exists-p (mh-expand-file-name mh-draft-folder)))
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37178
diff changeset
966 (error "Draft folder \"%s\" not found. Create it and try again"
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
967 (mh-expand-file-name mh-draft-folder)))))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
968 (setq mh-inbox (mh-get-profile-field "Inbox:"))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
969 (cond ((not mh-inbox)
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
970 (setq mh-inbox "+inbox"))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
971 ((not (mh-folder-name-p mh-inbox))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
972 (setq mh-inbox (format "+%s" mh-inbox))))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
973 (setq mh-unseen-seq (mh-get-profile-field "Unseen-Sequence:"))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
974 (if mh-unseen-seq
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
975 (setq mh-unseen-seq (intern mh-unseen-seq))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
976 (setq mh-unseen-seq 'unseen)) ;old MH default?
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
977 (setq mh-previous-seq (mh-get-profile-field "Previous-Sequence:"))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
978 (if mh-previous-seq
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
979 (setq mh-previous-seq (intern mh-previous-seq)))
18901
b9b03935853a (mh-make-folder-list-background):
Richard M. Stallman <rms@gnu.org>
parents: 18889
diff changeset
980 (run-hooks 'mh-find-path-hook)))
b9b03935853a (mh-make-folder-list-background):
Richard M. Stallman <rms@gnu.org>
parents: 18889
diff changeset
981 (and mh-auto-folder-collect
b9b03935853a (mh-make-folder-list-background):
Richard M. Stallman <rms@gnu.org>
parents: 18889
diff changeset
982 (let ((mh-no-install t)) ;only get folders if MH installed
b9b03935853a (mh-make-folder-list-background):
Richard M. Stallman <rms@gnu.org>
parents: 18889
diff changeset
983 (condition-case err
b9b03935853a (mh-make-folder-list-background):
Richard M. Stallman <rms@gnu.org>
parents: 18889
diff changeset
984 (mh-make-folder-list-background)
b9b03935853a (mh-make-folder-list-background):
Richard M. Stallman <rms@gnu.org>
parents: 18889
diff changeset
985 (file-error))))) ;so don't complain if not installed
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986
17893
ad5fda4d4c36 (mh-file-command-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17426
diff changeset
987 (defun mh-file-command-p (file)
ad5fda4d4c36 (mh-file-command-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17426
diff changeset
988 "Return t if file FILE is the name of a executable regular file."
ad5fda4d4c36 (mh-file-command-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17426
diff changeset
989 (and (file-regular-p file) (file-executable-p file)))
ad5fda4d4c36 (mh-file-command-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17426
diff changeset
990
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 (defun mh-find-progs ()
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
992 "Find the directories for the installed MH/nmh binaries and config files.
24420
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
993 Set the `mh-progs' and `mh-lib', and `mh-lib-progs' variables to the
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
994 directory names and set `mh-nmh-p' if we detect nmh instead of MH."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
995 (let ((path (or (mh-path-search exec-path "mhparam")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
996 (mh-path-search '("/usr/local/nmh/bin" ; nmh default
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
997 "/usr/local/bin/mh/"
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
998 "/usr/local/mh/"
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
999 "/usr/bin/mh/" ;Ultrix 4.2
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 "/usr/new/mh/" ;Ultrix <4.2
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1001 "/usr/contrib/mh/bin/" ;BSDI
24420
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
1002 "/usr/pkg/bin/" ; NetBSD
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1003 "/usr/local/bin/"
6856
396254137b30 (mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents: 6365
diff changeset
1004 )
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1005 "mhparam"))))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1006 (if (not path)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1007 (error "Unable to find the `mhparam' command"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1008 (save-excursion
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1009 (let ((tmp-buffer (get-buffer-create mh-temp-buffer)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1010 (set-buffer tmp-buffer)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1011 (unwind-protect
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1012 (progn
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1013 (call-process (expand-file-name "mhparam" path)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1014 nil '(t nil) nil "libdir" "etcdir")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1015 (goto-char (point-min))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1016 (if (search-forward-regexp "^libdir:\\s-\\(\\S-+\\)\\s-*$" nil t)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1017 (setq mh-lib-progs (match-string 1)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1018 mh-lib mh-lib-progs
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1019 mh-progs path))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1020 (goto-char (point-min))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1021 (if (search-forward-regexp "^etcdir:\\s-\\(\\S-+\\)\\s-*$" nil t)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1022 (setq mh-lib (match-string 1)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1023 mh-nmh-p t)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1024 (kill-buffer tmp-buffer))))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1025 (unless (and mh-progs mh-lib mh-lib-progs)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1026 (error "Unable to determine paths from `mhparam' command"))))
22637
030c40f7d202 (mh-find-progs): Avoid WTA error
Richard M. Stallman <rms@gnu.org>
parents: 21164
diff changeset
1027
24420
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
1028 (defun mh-path-search (path file &optional func-p)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 ;; Search PATH, a list of directory names, for FILE.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 ;; Returns the element of PATH that contains FILE, or nil if not found.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 (while (and path
24420
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
1032 (not (funcall (or func-p 'mh-file-command-p)
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
1033 (expand-file-name file (car path)))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 (setq path (cdr path)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035 (car path))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1037 (defvar mh-no-install nil) ;do not run install-mh
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1038
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 (defun mh-install (profile error-val)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 ;; Called to do error recovery if we fail to read the profile file.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 ;; If possible, initialize the MH environment.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 (if (or (getenv "MH")
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1043 (file-exists-p profile)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1044 mh-no-install)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1045 (signal (car error-val)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1046 (list (format "Cannot read MH profile \"%s\"" profile)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1047 (car (cdr (cdr error-val))))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 ;; The "install-mh" command will output a short note which
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 ;; mh-exec-cmd will display to the user.
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1050 ;; The MH 5 version of install-mh might try prompt the user
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1051 ;; for information, which would fail here.
24420
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
1052 (mh-exec-cmd (expand-file-name "install-mh" mh-lib-progs) "-auto")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053 ;; now try again to read the profile file
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 (condition-case err
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 (insert-file-contents profile)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 (file-error
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1058 (signal (car err) ;re-signal with more specific msg
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1059 (list (format "Cannot read MH profile \"%s\"" profile)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1060 (car (cdr (cdr err))))))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 (defun mh-set-folder-modified-p (flag)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1064 ;; Mark current folder as modified or unmodified according to FLAG.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 (set-buffer-modified-p flag))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 (defun mh-find-seq (name) (assoc name mh-seq-list))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 (defun mh-seq-to-msgs (seq)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1071 ;; Return a list of the messages in SEQUENCE.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072 (mh-seq-msgs (mh-find-seq seq)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1074
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 (defun mh-add-msgs-to-seq (msgs seq &optional internal-flag)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076 ;; Add MESSAGE(s) to the SEQUENCE. If optional FLAG is non-nil, do not mark
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077 ;; the message in the scan listing or inform MH of the addition.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 (let ((entry (mh-find-seq seq)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079 (if (and msgs (atom msgs)) (setq msgs (list msgs)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 (if (null entry)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081 (setq mh-seq-list (cons (mh-make-seq seq msgs) mh-seq-list))
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1082 (if msgs (setcdr entry (append msgs (mh-seq-msgs entry)))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 (cond ((not internal-flag)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 (mh-add-to-sequence seq msgs)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1085 (mh-notate-seq seq mh-note-seq (1+ mh-cmd-note))))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086
37178
3dab3c3ae5ee (mh-folder-hist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34599
diff changeset
1087 (defvar mh-folder-hist nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089 (defun mh-prompt-for-folder (prompt default can-create)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090 ;; Prompt for a folder name with PROMPT. Returns the folder's name as a
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091 ;; string. DEFAULT is used if the folder exists and the user types return.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 ;; If the CAN-CREATE flag is t, then a non-existent folder is made.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 (if (null default)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 (setq default ""))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 (let* ((prompt (format "%s folder%s" prompt
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 (if (equal "" default)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 "? "
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 (format " [%s]? " default))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 read-name folder-name)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 (if (null mh-folder-list)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 (mh-set-folder-list))
37178
3dab3c3ae5ee (mh-folder-hist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34599
diff changeset
1102 (while (and (setq read-name (completing-read prompt mh-folder-list nil nil
3dab3c3ae5ee (mh-folder-hist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34599
diff changeset
1103 "+" 'mh-folder-hist default))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 (equal read-name "")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 (equal default "")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 (cond ((or (equal read-name "") (equal read-name "+"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 (setq read-name default))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 ((not (mh-folder-name-p read-name))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 (setq read-name (format "+%s" read-name))))
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1110 (if (or (not read-name) (equal "" read-name))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1111 (error "No folder specified"))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 (setq folder-name read-name)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 (cond ((and (> (length folder-name) 0)
18926
e597d4b325df Change eql calls to eq.
Richard M. Stallman <rms@gnu.org>
parents: 18901
diff changeset
1114 (eq (aref folder-name (1- (length folder-name))) ?/))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 (setq folder-name (substring folder-name 0 -1))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116 (let ((new-file-p (not (file-exists-p (mh-expand-file-name folder-name)))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 (cond ((and new-file-p
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 (y-or-n-p
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 (format "Folder %s does not exist. Create it? " folder-name)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 (message "Creating %s" folder-name)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 (call-process "mkdir" nil nil nil (mh-expand-file-name folder-name))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 (message "Creating %s...done" folder-name)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1123 (setq mh-folder-list (cons (list read-name) mh-folder-list))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1124 (run-hooks 'mh-folder-list-change-hook))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 (new-file-p
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 (error "Folder %s is not created" folder-name))
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1127 ((not (file-directory-p (mh-expand-file-name folder-name)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1128 (error "\"%s\" is not a directory"
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1129 (mh-expand-file-name folder-name)))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 ((and (null (assoc read-name mh-folder-list))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 (null (assoc (concat read-name "/") mh-folder-list)))
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1132 (setq mh-folder-list (cons (list read-name) mh-folder-list))
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1133 (run-hooks 'mh-folder-list-change-hook))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134 folder-name))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1137 (defvar mh-make-folder-list-process nil) ;The background process collecting the folder list.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1139 (defvar mh-folder-list-temp nil) ;mh-folder-list as it is being built.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1141 (defvar mh-folder-list-partial-line "") ;Start of last incomplete line from folder process.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 (defun mh-set-folder-list ()
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1144 ;; Sets mh-folder-list correctly.
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1145 ;; A useful function for the command line or for when you need to
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1146 ;; sync by hand. Format is in a form suitable for completing read.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 (message "Collecting folder names...")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148 (if (not mh-make-folder-list-process)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 (mh-make-folder-list-background))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 (while (eq (process-status mh-make-folder-list-process) 'run)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 (accept-process-output mh-make-folder-list-process))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 (setq mh-folder-list mh-folder-list-temp)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1153 (run-hooks 'mh-folder-list-change-hook)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 (setq mh-folder-list-temp nil)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 (delete-process mh-make-folder-list-process)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156 (setq mh-make-folder-list-process nil)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 (message "Collecting folder names...done"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159 (defun mh-make-folder-list-background ()
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1160 ;; Start a background process to compute a list of the user's folders.
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1161 ;; Call mh-set-folder-list to wait for the result.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 (cond
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163 ((not mh-make-folder-list-process)
18901
b9b03935853a (mh-make-folder-list-background):
Richard M. Stallman <rms@gnu.org>
parents: 18889
diff changeset
1164 (unless mh-inbox
b9b03935853a (mh-make-folder-list-background):
Richard M. Stallman <rms@gnu.org>
parents: 18889
diff changeset
1165 (mh-find-path))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 (let ((process-connection-type nil))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 (setq mh-make-folder-list-process
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 (start-process "folders" nil (expand-file-name "folders" mh-progs)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169 "-fast"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170 (if mh-recursive-folders
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 "-recurse"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 "-norecurse")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 (set-process-filter mh-make-folder-list-process
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 'mh-make-folder-list-filter)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 (process-kill-without-query mh-make-folder-list-process)))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 (defun mh-make-folder-list-filter (process output)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 ;; parse output from "folders -fast"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 (let ((position 0)
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1180 line-end
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1181 new-folder
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1182 (prevailing-match-data (match-data)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1183 (unwind-protect
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1184 ;; make sure got complete line
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1185 (while (setq line-end (string-match "\n" output position))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1186 (setq new-folder (format "+%s%s"
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1187 mh-folder-list-partial-line
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1188 (substring output position line-end)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1189 (setq mh-folder-list-partial-line "")
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1190 ;; is new folder a subfolder of previous?
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1191 (if (and mh-folder-list-temp
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1192 (string-match
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1193 (regexp-quote
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1194 (concat (car (car mh-folder-list-temp)) "/"))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1195 new-folder))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1196 ;; append slash to parent folder for better completion
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1197 ;; (undone by mh-prompt-for-folder)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1198 (setq mh-folder-list-temp
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1199 (cons
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1200 (list new-folder)
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1201 (cons
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1202 (list (concat (car (car mh-folder-list-temp)) "/"))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1203 (cdr mh-folder-list-temp))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 (setq mh-folder-list-temp
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 (cons (list new-folder)
13386
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1206 mh-folder-list-temp)))
78c7ebcbd9fe (mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents: 11576
diff changeset
1207 (setq position (1+ line-end)))
21164
966308b754da (mh-make-folder-list-filter): store-match-data => set-match-data.
Richard M. Stallman <rms@gnu.org>
parents: 18926
diff changeset
1208 (set-match-data prevailing-match-data))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 (setq mh-folder-list-partial-line (substring output position))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 (defun mh-folder-name-p (name)
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1213 ;; Return non-NIL if NAME is possibly the name of a folder.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 ;; A name (a string or symbol) can be a folder name if it begins with "+".
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215 (if (symbolp name)
18926
e597d4b325df Change eql calls to eq.
Richard M. Stallman <rms@gnu.org>
parents: 18901
diff changeset
1216 (eq (aref (symbol-name name) 0) ?+)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217 (and (> (length name) 0)
18926
e597d4b325df Change eql calls to eq.
Richard M. Stallman <rms@gnu.org>
parents: 18901
diff changeset
1218 (eq (aref name 0) ?+))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 ;;; Issue commands to MH.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 (defun mh-exec-cmd (command &rest args)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 ;; Execute mh-command COMMAND with ARGS.
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1226 ;; The side effects are what is desired.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 ;; Any output is assumed to be an error and is shown to the user.
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1228 ;; The output is not read or parsed by mh-e.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229 (save-excursion
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1230 (set-buffer (get-buffer-create mh-temp-buffer))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 (apply 'call-process
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 (expand-file-name command mh-progs) nil t nil
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 (mh-list-to-string args))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 (if (> (buffer-size) 0)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 (save-window-excursion
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1237 (switch-to-buffer-other-window mh-temp-buffer)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 (sit-for 5)))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 (defun mh-exec-cmd-error (env command &rest args)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 ;; In environment ENV, execute mh-command COMMAND with args ARGS.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243 ;; ENV is nil or a string of space-separated "var=value" elements.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 ;; Signals an error if process does not complete successfully.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245 (save-excursion
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1246 (set-buffer (get-buffer-create mh-temp-buffer))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 (let ((status
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 (if env
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 ;; the shell hacks necessary here shows just how broken Unix is
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 (apply 'call-process "/bin/sh" nil t nil "-c"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252 (format "%s %s ${1+\"$@\"}"
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 42323
diff changeset
1253 env
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254 (expand-file-name command mh-progs))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 command
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 (mh-list-to-string args))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257 (apply 'call-process
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 (expand-file-name command mh-progs) nil t nil
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 (mh-list-to-string args)))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260 (mh-handle-process-error command status))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1263 (defun mh-exec-cmd-daemon (command &rest args)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1264 ;; Execute MH command COMMAND with ARGS in the background.
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1265 ;; Any output from command is displayed in an asynchronous pop-up window.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 (save-excursion
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1267 (set-buffer (get-buffer-create mh-temp-buffer))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268 (erase-buffer))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269 (let* ((process-connection-type nil)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 (process (apply 'start-process
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271 command nil
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272 (expand-file-name command mh-progs)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 (mh-list-to-string args))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 (set-process-filter process 'mh-process-daemon)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 (defun mh-process-daemon (process output)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 ;; Process daemon that puts output into a temporary buffer.
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1278 (set-buffer (get-buffer-create mh-temp-buffer))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279 (insert-before-markers output)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1280 (display-buffer mh-temp-buffer))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 (defun mh-exec-cmd-quiet (raise-error command &rest args)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 ;; Args are RAISE-ERROR, COMMANDS, ARGS....
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285 ;; Execute MH command COMMAND with ARGS. ARGS is a list of strings.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286 ;; Return at start of mh-temp buffer, where output can be parsed and used.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 ;; Returns value of call-process, which is 0 for success,
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1288 ;; unless RAISE-ERROR is non-nil, in which case an error is signaled
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1289 ;; if call-process returns non-0.
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1290 (set-buffer (get-buffer-create mh-temp-buffer))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 (let ((value
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 (apply 'call-process
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294 (expand-file-name command mh-progs) nil t nil
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295 args)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1296 (goto-char (point-min))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1297 (if raise-error
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298 (mh-handle-process-error command value)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 value)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1302 (defun mh-exec-cmd-output (command display &rest args)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1303 ;; Execute MH command COMMAND with DISPLAY flag and ARGS.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304 ;; Put the output into buffer after point. Set mark after inserted text.
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1305 ;; Output is expected to be shown to user, not parsed by mh-e.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1306 (push-mark (point) t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307 (apply 'call-process
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308 (expand-file-name command mh-progs) nil t display
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309 (mh-list-to-string args))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1310 (exchange-point-and-mark))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1311
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1313 (defun mh-exec-lib-cmd-output (command &rest args)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 ;; Execute MH library command COMMAND with ARGS.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315 ;; Put the output into buffer after point. Set mark after inserted text.
24420
8532b00fb743 (mh-lib): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22637
diff changeset
1316 (apply 'mh-exec-cmd-output (expand-file-name command mh-lib-progs) nil args))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1317
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1318
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319 (defun mh-handle-process-error (command status)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1320 ;; Raise error if COMMAND returned non-0 STATUS, otherwise return STATUS.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321 ;; STATUS is return value from call-process.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1322 ;; Program output is in current buffer.
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1323 ;; If output is too long to include in error message, display the buffer.
18926
e597d4b325df Change eql calls to eq.
Richard M. Stallman <rms@gnu.org>
parents: 18901
diff changeset
1324 (cond ((eq status 0) ;success
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 status)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1326 ((stringp status) ;kill string
14426
9f18c1b097ce (mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
1327 (error "%s: %s" command status))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 (t ;exit code
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 (cond
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1330 ((= (buffer-size) 0) ;program produced no error message
14426
9f18c1b097ce (mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
1331 (error "%s: exit code %d" command status))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332 (t
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1333 ;; will error message fit on one line?
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1334 (goto-line 2)
42323
c86cd54b5c50 (mh-show-msg): Likewise.
Pavel Janík <Pavel@Janik.cz>
parents: 42205
diff changeset
1335 (if (and (< (buffer-size) (frame-width))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1336 (eobp))
14426
9f18c1b097ce (mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
1337 (error "%s"
9f18c1b097ce (mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
1338 (buffer-substring 1 (progn (goto-char 1)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1339 (end-of-line)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1340 (point))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341 (display-buffer (current-buffer))
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37178
diff changeset
1342 (error "%s failed with status %d. See error message in other window"
14426
9f18c1b097ce (mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
1343 command status)))))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1344
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1345
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 (defun mh-expand-file-name (filename &optional default)
11331
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1347 ;; Just like `expand-file-name', but also handles MH folder names.
730a7c669a73 New version from author
Karl Heuer <kwzh@gnu.org>
parents: 6856
diff changeset
1348 ;; Assumes that any filename that starts with '+' is a folder name.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 (if (mh-folder-name-p filename)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350 (expand-file-name (substring filename 1) mh-user-path)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 (expand-file-name filename default)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1352
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 (defun mh-list-to-string (l)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 ;; Flattens the list L and makes every element of the new list into a string.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356 (nreverse (mh-list-to-string-1 l)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1358 (defun mh-list-to-string-1 (l)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1359 (let ((new-list nil))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360 (while l
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 (cond ((null (car l)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362 ((symbolp (car l))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 (setq new-list (cons (symbol-name (car l)) new-list)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364 ((numberp (car l))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365 (setq new-list (cons (int-to-string (car l)) new-list)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 ((equal (car l) ""))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367 ((stringp (car l)) (setq new-list (cons (car l) new-list)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368 ((listp (car l))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 (setq new-list (nconc (mh-list-to-string-1 (car l))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370 new-list)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1371 (t (error "Bad element in mh-list-to-string: %s" (car l))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 (setq l (cdr l)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 new-list))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1374
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 (provide 'mh-utils)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377 ;;; mh-utils.el ends here