annotate lisp/mh-e/mh-letter.el @ 77447:9ce8bfb2f686

* display.texi (Highlight Interactively): Correct description of hi-lock-file-patterns-policy.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 23 Apr 2007 14:39:16 +0000
parents e3694f1cb928
children 800dd75c042b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1 ;;; mh-letter.el --- MH-Letter mode
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
2
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
3 ;; Copyright (C) 1993, 1995, 1997,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 70214
diff changeset
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
5
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
6 ;; Author: Bill Wohler <wohler@newt.com>
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
7 ;; Maintainer: Bill Wohler <wohler@newt.com>
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
8 ;; Keywords: mail
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
9 ;; See: mh-e.el
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
10
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
12
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
16 ;; any later version.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
17
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
21 ;; GNU General Public License for more details.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
22
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
26 ;; Boston, MA 02110-1301, USA.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
27
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
28 ;;; Commentary:
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
29
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
30 ;; Mode for composing and sending a draft message.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
31
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
32 ;; Functions that would ordinarily be in here that are needed by
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
33 ;; mh-show.el should be placed in the Message Utilities section in
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
34 ;; mh-utils.el. That will help prevent the loading of this file until
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
35 ;; a message is actually composed.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
36
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
37 ;;; Change Log:
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
38
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
39 ;;; Code:
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
40
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
41 (require 'mh-e)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
42
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
43 (require 'gnus-util)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
44
69245
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 68529
diff changeset
45 ;; Dynamically-created functions not found in mh-loaddefs.el.
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
46 (autoload 'mh-tool-bar-letter-buttons-init "mh-tool-bar")
69245
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 68529
diff changeset
47 (autoload 'mh-tool-bar-init "mh-tool-bar")
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
48
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
49 (autoload 'mml-insert-tag "mml")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
50
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
51 ;;; Variables
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
52
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
53 (defvar mh-letter-complete-function-alist
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
54 '((bcc . mh-alias-letter-expand-alias)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
55 (cc . mh-alias-letter-expand-alias)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
56 (dcc . mh-alias-letter-expand-alias)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
57 (fcc . mh-folder-expand-at-point)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
58 (from . mh-alias-letter-expand-alias)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
59 (mail-followup-to . mh-alias-letter-expand-alias)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
60 (mail-reply-to . mh-alias-letter-expand-alias)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
61 (reply-to . mh-alias-letter-expand-alias)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
62 (to . mh-alias-letter-expand-alias))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
63 "Alist of header fields and completion functions to use.")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
64
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
65 (defvar mh-yank-hooks nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
66 "Obsolete hook for modifying a citation just inserted in the mail buffer.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
67
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
68 Each hook function can find the citation between point and mark.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
69 And each hook function should leave point and mark around the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
70 citation text as modified.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
71
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
72 This is a normal hook, misnamed for historical reasons. It is
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
73 semi-obsolete and is only used if `mail-citation-hook' is nil.")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
74
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
75
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
76
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
77 ;;; Letter Menu
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
78
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
79 (easy-menu-define
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
80 mh-letter-menu mh-letter-mode-map "Menu for MH-E letter mode."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
81 '("Letter"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
82 ["Send This Draft" mh-send-letter t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
83 ["Split Current Line" mh-open-line t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
84 ["Check Recipient" mh-check-whom t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
85 ["Yank Current Message" mh-yank-cur-msg t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
86 ["Insert a Message..." mh-insert-letter t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
87 ["Insert Signature" mh-insert-signature t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
88 ("Encrypt/Sign Message"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
89 ["Sign Message"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
90 mh-mml-secure-message-sign mh-pgp-support-flag]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
91 ["Encrypt Message"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
92 mh-mml-secure-message-encrypt mh-pgp-support-flag]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
93 ["Sign+Encrypt Message"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
94 mh-mml-secure-message-signencrypt mh-pgp-support-flag]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
95 ["Disable Security"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
96 mh-mml-unsecure-message mh-pgp-support-flag]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
97 "--"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
98 "Security Method"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
99 ["PGP (MIME)" (setq mh-mml-method-default "pgpmime")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
100 :style radio
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
101 :selected (equal mh-mml-method-default "pgpmime")]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
102 ["PGP" (setq mh-mml-method-default "pgp")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
103 :style radio
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
104 :selected (equal mh-mml-method-default "pgp")]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
105 ["S/MIME" (setq mh-mml-method-default "smime")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
106 :style radio
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
107 :selected (equal mh-mml-method-default "smime")]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
108 "--"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
109 ["Save Method as Default"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
110 (customize-save-variable 'mh-mml-method-default mh-mml-method-default) t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
111 )
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
112 ["Compose Insertion..." mh-compose-insertion t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
113 ["Compose Compressed tar (MH)..."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
114 mh-mh-compose-external-compressed-tar t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
115 ["Compose Get File (MH)..." mh-mh-compose-anon-ftp t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
116 ["Compose Forward..." mh-compose-forward t]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
117 ;; The next two will have to be merged. But I also need to make sure the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
118 ;; user can't mix tags of both types.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
119 ["Pull in All Compositions (MH)"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
120 mh-mh-to-mime (mh-mh-directive-present-p)]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
121 ["Pull in All Compositions (MML)"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
122 mh-mml-to-mime (mh-mml-tag-present-p)]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
123 ["Revert to Non-MIME Edit (MH)"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
124 mh-mh-to-mime-undo (equal mh-compose-insertion 'mh)]
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
125 ["Kill This Draft" mh-fully-kill-draft t]))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
126
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
127
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
128
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
129 ;;; MH-Letter Keys
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
130
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
131 ;; If this changes, modify mh-letter-mode-help-messages accordingly, above.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
132 (gnus-define-keys mh-letter-mode-map
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
133 " " mh-letter-complete-or-space
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
134 "," mh-letter-confirm-address
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
135 "\C-c?" mh-help
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
136 "\C-c\C-\\" mh-fully-kill-draft ;if no C-q
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
137 "\C-c\C-^" mh-insert-signature ;if no C-s
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
138 "\C-c\C-c" mh-send-letter
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
139 "\C-c\C-d" mh-insert-identity
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
140 "\C-c\C-e" mh-mh-to-mime
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
141 "\C-c\C-f\C-a" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
142 "\C-c\C-f\C-b" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
143 "\C-c\C-f\C-c" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
144 "\C-c\C-f\C-d" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
145 "\C-c\C-f\C-f" mh-to-fcc
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
146 "\C-c\C-f\C-l" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
147 "\C-c\C-f\C-m" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
148 "\C-c\C-f\C-r" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
149 "\C-c\C-f\C-s" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
150 "\C-c\C-f\C-t" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
151 "\C-c\C-fa" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
152 "\C-c\C-fb" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
153 "\C-c\C-fc" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
154 "\C-c\C-fd" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
155 "\C-c\C-ff" mh-to-fcc
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
156 "\C-c\C-fl" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
157 "\C-c\C-fm" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
158 "\C-c\C-fr" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
159 "\C-c\C-fs" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
160 "\C-c\C-ft" mh-to-field
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
161 "\C-c\C-i" mh-insert-letter
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
162 "\C-c\C-m\C-e" mh-mml-secure-message-encrypt
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
163 "\C-c\C-m\C-f" mh-compose-forward
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
164 "\C-c\C-m\C-g" mh-mh-compose-anon-ftp
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
165 "\C-c\C-m\C-i" mh-compose-insertion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
166 "\C-c\C-m\C-m" mh-mml-to-mime
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
167 "\C-c\C-m\C-n" mh-mml-unsecure-message
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
168 "\C-c\C-m\C-s" mh-mml-secure-message-sign
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
169 "\C-c\C-m\C-t" mh-mh-compose-external-compressed-tar
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
170 "\C-c\C-m\C-u" mh-mh-to-mime-undo
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
171 "\C-c\C-m\C-x" mh-mh-compose-external-type
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
172 "\C-c\C-mee" mh-mml-secure-message-encrypt
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
173 "\C-c\C-mes" mh-mml-secure-message-signencrypt
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
174 "\C-c\C-mf" mh-compose-forward
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
175 "\C-c\C-mg" mh-mh-compose-anon-ftp
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
176 "\C-c\C-mi" mh-compose-insertion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
177 "\C-c\C-mm" mh-mml-to-mime
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
178 "\C-c\C-mn" mh-mml-unsecure-message
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
179 "\C-c\C-mse" mh-mml-secure-message-signencrypt
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
180 "\C-c\C-mss" mh-mml-secure-message-sign
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
181 "\C-c\C-mt" mh-mh-compose-external-compressed-tar
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
182 "\C-c\C-mu" mh-mh-to-mime-undo
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
183 "\C-c\C-mx" mh-mh-compose-external-type
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
184 "\C-c\C-o" mh-open-line
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
185 "\C-c\C-q" mh-fully-kill-draft
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
186 "\C-c\C-s" mh-insert-signature
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
187 "\C-c\C-t" mh-letter-toggle-header-field-display
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
188 "\C-c\C-w" mh-check-whom
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
189 "\C-c\C-y" mh-yank-cur-msg
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
190 "\C-c\M-d" mh-insert-auto-fields
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
191 "\M-\t" mh-letter-complete
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
192 "\t" mh-letter-next-header-field-or-indent
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
193 [backtab] mh-letter-previous-header-field)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
194
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
195 ;; "C-c /" prefix is used in mh-letter-mode by pgp.el and mailcrypt.el.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
196
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
197
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
198
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
199 ;;; MH-Letter Help Messages
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
200
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
201 ;; Group messages logically, more or less.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
202 (defvar mh-letter-mode-help-messages
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
203 '((nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
204 "Send letter: \\[mh-send-letter] "
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
205 "Open line: \\[mh-open-line]\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
206 "Kill letter: \\[mh-fully-kill-draft] "
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
207 "Check recipients: \\[mh-check-whom]\n\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
208 "Insert:\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
209 " Current message: \\[mh-yank-cur-msg]\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
210 " Attachment: \\[mh-compose-insertion]\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
211 " Message to forward: \\[mh-compose-forward]\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
212 " Signature: \\[mh-insert-signature]\n\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
213 "Security:\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
214 " Encrypt message: \\[mh-mml-secure-message-encrypt]\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
215 " Sign message: \\[mh-mml-secure-message-sign]\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
216 " Sign+Encrypt message: \\[mh-mml-secure-message-signencrypt]"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
217 "Key binding cheat sheet.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
218
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
219 This is an associative array which is used to show the most
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
220 common commands. The key is a prefix char. The value is one or
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
221 more strings which are concatenated together and displayed in the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
222 minibuffer if ? is pressed after the prefix character. The
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
223 special key nil is used to display the non-prefixed commands.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
224
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
225 The substitutions described in `substitute-command-keys' are
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
226 performed as well.")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
227
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
228
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
229
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
230 ;;; MH-Letter Font Lock
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
231
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
232 (defvar mh-letter-font-lock-keywords
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
233 `(,@(mh-show-font-lock-keywords-with-cite)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
234 (mh-font-lock-field-data
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
235 (1 'mh-letter-header-field prepend t)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
236 "Additional expressions to highlight in MH-Letter buffers.")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
237
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
238 (defun mh-font-lock-field-data (limit)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
239 "Find header field region between point and LIMIT."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
240 (and (< (point) (mh-letter-header-end))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
241 (< (point) limit)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
242 (let ((end (min limit (mh-letter-header-end)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
243 (point (point))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
244 data-end data-begin field)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
245 (end-of-line)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
246 (setq data-end (if (re-search-forward "^[^ \t]" end t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
247 (match-beginning 0)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
248 end))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
249 (goto-char (1- data-end))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
250 (if (not (re-search-backward "\\(^[^ \t][^:]*\\):[ \t]*" nil t))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
251 (setq data-begin (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
252 (setq data-begin (match-end 0))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
253 (setq field (match-string 1)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
254 (setq data-begin (max point data-begin))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
255 (goto-char (if (equal point data-end) (1+ data-end) data-end))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
256 (cond ((and field (mh-letter-skipped-header-field-p field))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
257 (set-match-data nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
258 nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
259 (t (set-match-data
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
260 (list data-begin data-end data-begin data-end))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
261 t)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
262
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
263 (defun mh-letter-header-end ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
264 "Find the end of the message header.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
265 This function is to be used only for font locking. It works by
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
266 searching for `mh-mail-header-separator' in the buffer."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
267 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
268 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
269 (cond ((equal mh-mail-header-separator "") (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
270 ((search-forward (format "\n%s\n" mh-mail-header-separator) nil t)
68529
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68519
diff changeset
271 (mh-line-beginning-position 0))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
272 (t (point-min)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
273
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
274
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
275
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
276 ;;; MH-Letter Mode
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
277
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
278 ;; Shush compiler.
70028
d81780942bb8 * mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents: 69492
diff changeset
279 (defvar font-lock-defaults) ; XEmacs
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
280
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
281 ;; Ensure new buffers won't get this mode if default-major-mode is nil.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
282 (put 'mh-letter-mode 'mode-class 'special)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
283
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
284 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
285 (define-derived-mode mh-letter-mode mail-mode "MH-Letter"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
286 "Mode for composing letters in MH-E\\<mh-letter-mode-map>.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
287
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
288 When you have finished composing, type \\[mh-send-letter] to send
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
289 the message using the MH mail handling system.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
290
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
291 There are two types of tags used by MH-E when composing MIME
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
292 messages: MML and MH. The option `mh-compose-insertion' controls
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
293 what type of tags are inserted by MH-E commands. These tags can
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
294 be converted to MIME body parts by running \\[mh-mh-to-mime] for
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
295 MH-style directives or \\[mh-mml-to-mime] for MML tags.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
296
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
297 Options that control this mode can be changed with
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
298 \\[customize-group]; specify the \"mh-compose\" group.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
299
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
300 When a message is composed, the hooks `text-mode-hook',
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
301 `mail-mode-hook', and `mh-letter-mode-hook' are run (in that
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
302 order).
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
303
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
304 \\{mh-letter-mode-map}"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
305 (mh-find-path)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
306 (make-local-variable 'mh-send-args)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
307 (make-local-variable 'mh-annotate-char)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
308 (make-local-variable 'mh-annotate-field)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
309 (make-local-variable 'mh-previous-window-config)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
310 (make-local-variable 'mh-sent-from-folder)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
311 (make-local-variable 'mh-sent-from-msg)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
312 (mh-do-in-gnu-emacs
70145
00cb3fe5fed5 * mh-tool-bar.el (image-load-path): Define to shush compiler.
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
313 (unless mh-letter-tool-bar-map
00cb3fe5fed5 * mh-tool-bar.el (image-load-path): Define to shush compiler.
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
314 (mh-tool-bar-letter-buttons-init))
69245
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 68529
diff changeset
315 (set (make-local-variable 'tool-bar-map) mh-letter-tool-bar-map))
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 68529
diff changeset
316 (mh-do-in-xemacs
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 68529
diff changeset
317 (mh-tool-bar-init :letter))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
318 ;; Set the local value of mh-mail-header-separator according to what is
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
319 ;; present in the buffer...
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
320 (set (make-local-variable 'mh-mail-header-separator)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
321 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
322 (goto-char (mh-mail-header-end))
68529
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68519
diff changeset
323 (buffer-substring-no-properties (point) (mh-line-end-position))))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
324 (make-local-variable 'mail-header-separator)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
325 (setq mail-header-separator mh-mail-header-separator) ;override sendmail.el
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
326 (mh-set-help mh-letter-mode-help-messages)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
327 (setq buffer-invisibility-spec '((vanish . t) t))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
328 (set (make-local-variable 'line-move-ignore-invisible) t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
329
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
330 ;; Enable undo since a show-mode buffer might have been reused.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
331 (buffer-enable-undo)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
332 (make-local-variable 'font-lock-defaults)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
333 (cond
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
334 ((or (equal mh-highlight-citation-style 'font-lock)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
335 (equal mh-highlight-citation-style 'gnus))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
336 ;; Let's use font-lock even if gnus is used in show-mode. The reason
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
337 ;; is that gnus uses static text properties which are not appropriate
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
338 ;; for a buffer that will be edited. So the choice here is either fontify
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
339 ;; the citations and header...
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
340 (setq font-lock-defaults '(mh-letter-font-lock-keywords t)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
341 (t
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
342 ;; ...or the header only
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
343 (setq font-lock-defaults '((mh-show-font-lock-keywords) t))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
344 (easy-menu-add mh-letter-menu)
68473
e238dd02cdad (mh-letter-menu): Remove. Defvar no longer needed to shush compiler.
Bill Wohler <wohler@newt.com>
parents: 68470
diff changeset
345 ;; Maybe we want to use the existing Mail menu from mail-mode in
e238dd02cdad (mh-letter-menu): Remove. Defvar no longer needed to shush compiler.
Bill Wohler <wohler@newt.com>
parents: 68470
diff changeset
346 ;; 9.0; in the mean time, let's remove it since the redundancy will
e238dd02cdad (mh-letter-menu): Remove. Defvar no longer needed to shush compiler.
Bill Wohler <wohler@newt.com>
parents: 68470
diff changeset
347 ;; only produce confusion.
e238dd02cdad (mh-letter-menu): Remove. Defvar no longer needed to shush compiler.
Bill Wohler <wohler@newt.com>
parents: 68470
diff changeset
348 (define-key mh-letter-mode-map [menu-bar mail] 'undefined)
e238dd02cdad (mh-letter-menu): Remove. Defvar no longer needed to shush compiler.
Bill Wohler <wohler@newt.com>
parents: 68470
diff changeset
349 (mh-do-in-xemacs (easy-menu-remove mail-menubar-menu))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
350 (setq fill-column mh-letter-fill-column)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
351 ;; If text-mode-hook turned on auto-fill, tune it for messages
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
352 (when auto-fill-function
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
353 (make-local-variable 'auto-fill-function)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
354 (setq auto-fill-function 'mh-auto-fill-for-letter)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
355
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
356
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
357
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
358 ;;; MH-Letter Commands
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
359
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
360 ;; Alphabetical.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
361 ;; See also mh-comp.el and mh-mime.el.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
362
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
363 (defun mh-check-whom ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
364 "Verify recipients, showing expansion of any aliases.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
365
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
366 This command expands aliases so you can check the actual address(es)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
367 in the alias. A new buffer named \"*MH-E Recipients*\" is created with
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
368 the output of \"whom\"."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
369 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
370 (let ((file-name buffer-file-name))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
371 (save-buffer)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
372 (message "Checking recipients...")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
373 (mh-in-show-buffer (mh-recipients-buffer)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
374 (bury-buffer (current-buffer))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
375 (erase-buffer)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
376 (mh-exec-cmd-output "whom" t file-name))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
377 (message "Checking recipients...done")))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
378
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
379 (defun mh-insert-letter (folder message verbatim)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
380 "Insert a message.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
381
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
382 This command prompts you for the FOLDER and MESSAGE number, which
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
383 defaults to the current message in that folder. It then inserts
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
384 the message, indented by `mh-ins-buf-prefix' (\"> \") unless
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
385 `mh-yank-behavior' is set to one of the supercite flavors in
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
386 which case supercite is used to format the message. Certain
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
387 undesirable header fields (see
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
388 `mh-invisible-header-fields-compiled') are removed before
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
389 insertion.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
390
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
391 If given a prefix argument VERBATIM, the header is left intact, the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
392 message is not indented, and \"> \" is not inserted before each line.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
393 This command leaves the mark before the letter and point after it."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
394 (interactive
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
395 (let* ((folder
70169
10be49d855c4 (mh-insert-letter): If a message number isn't given, throw an error
Bill Wohler <wohler@newt.com>
parents: 70145
diff changeset
396 (mh-prompt-for-folder "Message from" mh-sent-from-folder nil))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
397 (default
70169
10be49d855c4 (mh-insert-letter): If a message number isn't given, throw an error
Bill Wohler <wohler@newt.com>
parents: 70145
diff changeset
398 (if (equal folder mh-sent-from-folder)
10be49d855c4 (mh-insert-letter): If a message number isn't given, throw an error
Bill Wohler <wohler@newt.com>
parents: 70145
diff changeset
399 (or mh-sent-from-msg (nth 0 (mh-translate-range folder "cur")))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
400 (nth 0 (mh-translate-range folder "cur"))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
401 (message
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
402 (read-string (concat "Message number"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
403 (or (and default
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
404 (format " (default %d): " default))
70169
10be49d855c4 (mh-insert-letter): If a message number isn't given, throw an error
Bill Wohler <wohler@newt.com>
parents: 70145
diff changeset
405 ": "))
10be49d855c4 (mh-insert-letter): If a message number isn't given, throw an error
Bill Wohler <wohler@newt.com>
parents: 70145
diff changeset
406 nil nil
10be49d855c4 (mh-insert-letter): If a message number isn't given, throw an error
Bill Wohler <wohler@newt.com>
parents: 70145
diff changeset
407 (if (numberp default)
10be49d855c4 (mh-insert-letter): If a message number isn't given, throw an error
Bill Wohler <wohler@newt.com>
parents: 70145
diff changeset
408 (int-to-string default)
10be49d855c4 (mh-insert-letter): If a message number isn't given, throw an error
Bill Wohler <wohler@newt.com>
parents: 70145
diff changeset
409 default))))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
410 (list folder message current-prefix-arg)))
70169
10be49d855c4 (mh-insert-letter): If a message number isn't given, throw an error
Bill Wohler <wohler@newt.com>
parents: 70145
diff changeset
411 (if (equal message "")
10be49d855c4 (mh-insert-letter): If a message number isn't given, throw an error
Bill Wohler <wohler@newt.com>
parents: 70145
diff changeset
412 (error "No message number given"))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
413 (save-restriction
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
414 (narrow-to-region (point) (point))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
415 (let ((start (point-min)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
416 (insert-file-contents
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
417 (expand-file-name message (mh-expand-file-name folder)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
418 (when (not verbatim)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
419 (mh-clean-msg-header start mh-invisible-header-fields-compiled nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
420 (goto-char (point-max)) ;Needed for sc-cite-original
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
421 (push-mark) ;Needed for sc-cite-original
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
422 (goto-char (point-min)) ;Needed for sc-cite-original
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
423 (mh-insert-prefix-string mh-ins-buf-prefix)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
424
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
425 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
426 (defun mh-insert-signature (&optional file)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
427 "Insert signature in message.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
428
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
429 This command inserts your signature at the current cursor location.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
430
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
431 By default, the text of your signature is taken from the file
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
432 \"~/.signature\". You can read from other sources by changing the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
433 option `mh-signature-file-name'.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
434
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
435 A signature separator (\"-- \") will be added if the signature block
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
436 does not contain one and `mh-signature-separator-flag' is on.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
437
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
438 The hook `mh-insert-signature-hook' is run after the signature is
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
439 inserted. Hook functions may access the actual name of the file or the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
440 function used to insert the signature with `mh-signature-file-name'.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
441
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
442 The signature can also be inserted using Identities (see
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
443 `mh-identity-list').
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
444
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
445 In a program, you can pass in a signature FILE."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
446 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
447 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
448 (insert "\n")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
449 (let ((mh-signature-file-name (or file mh-signature-file-name))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
450 (mh-mh-p (mh-mh-directive-present-p))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
451 (mh-mml-p (mh-mml-tag-present-p)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
452 (save-restriction
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
453 (narrow-to-region (point) (point))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
454 (cond
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
455 ((mh-file-is-vcard-p mh-signature-file-name)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
456 (if (equal mh-compose-insertion 'mml)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
457 (insert "<#part type=\"text/x-vcard\" filename=\""
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
458 mh-signature-file-name
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
459 "\" disposition=inline description=VCard>\n<#/part>")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
460 (insert "#text/x-vcard; name=\""
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
461 (file-name-nondirectory mh-signature-file-name)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
462 "\" [VCard] " (expand-file-name mh-signature-file-name))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
463 (t
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
464 (cond
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
465 (mh-mh-p
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
466 (insert "#\n" "Content-Description: Signature\n"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
467 (mh-mml-p
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
468 (mml-insert-tag 'part 'type "text/plain" 'disposition "inline"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
469 'description "Signature")))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
470 (cond ((null mh-signature-file-name))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
471 ((and (stringp mh-signature-file-name)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
472 (file-readable-p mh-signature-file-name))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
473 (insert-file-contents mh-signature-file-name))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
474 ((functionp mh-signature-file-name)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
475 (funcall mh-signature-file-name)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
476 (save-restriction
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
477 (widen)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
478 (run-hooks 'mh-insert-signature-hook))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
479 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
480 (when (and (not (mh-file-is-vcard-p mh-signature-file-name))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
481 mh-signature-separator-flag
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
482 (> (point-max) (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
483 (not (mh-signature-separator-p)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
484 (cond (mh-mh-p
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
485 (forward-line 2))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
486 (mh-mml-p
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
487 (forward-line 1)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
488 (insert mh-signature-separator))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
489 (if (not (> (point-max) (point-min)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
490 (message "No signature found")))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
491 (force-mode-line-update))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
492
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
493 (defun mh-letter-complete (arg)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
494 "Perform completion on header field or word preceding point.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
495
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
496 If the field contains addresses (for example, \"To:\" or \"Cc:\")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
497 or folders (for example, \"Fcc:\") then this command will provide
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
498 alias completion. In the body of the message, this command runs
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
499 `mh-letter-complete-function' instead, which is set to
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
500 `ispell-complete-word' by default. This command takes a prefix
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
501 argument ARG that is passed to the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
502 `mh-letter-complete-function'."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
503 (interactive "P")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
504 (let ((func nil))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
505 (cond ((not (mh-in-header-p))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
506 (funcall mh-letter-complete-function arg))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
507 ((setq func (cdr (assoc (mh-letter-header-field-at-point)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
508 mh-letter-complete-function-alist)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
509 (funcall func))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
510 (t (funcall mh-letter-complete-function arg)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
511
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
512 (defun mh-letter-complete-or-space (arg)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
513 "Perform completion or insert space.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
514
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
515 Turn on the option `mh-compose-space-does-completion-flag' to use
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
516 this command to perform completion in the header. Otherwise, a
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
517 space is inserted; use a prefix argument ARG to specify more than
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
518 one space."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
519 (interactive "p")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
520 (let ((func nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
521 (end-of-prev (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
522 (goto-char (mh-beginning-of-word))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
523 (mh-beginning-of-word -1))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
524 (cond ((not mh-compose-space-does-completion-flag)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
525 (self-insert-command arg))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
526 ((not (mh-in-header-p)) (self-insert-command arg))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
527 ((> (point) end-of-prev) (self-insert-command arg))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
528 ((setq func (cdr (assoc (mh-letter-header-field-at-point)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
529 mh-letter-complete-function-alist)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
530 (funcall func))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
531 (t (self-insert-command arg)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
532
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
533 (defun mh-letter-confirm-address ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
534 "Flash alias expansion.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
535
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
536 Addresses are separated by a comma\; when you press the comma,
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
537 this command flashes the alias expansion in the minibuffer if
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
538 `mh-alias-flash-on-comma' is turned on."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
539 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
540 (cond ((not (mh-in-header-p)) (self-insert-command 1))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
541 ((eq (cdr (assoc (mh-letter-header-field-at-point)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
542 mh-letter-complete-function-alist))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
543 'mh-alias-letter-expand-alias)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
544 (mh-alias-reload-maybe)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
545 (mh-alias-minibuffer-confirm-address))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
546 (t (self-insert-command 1))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
547
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
548 (defun mh-letter-next-header-field-or-indent (arg)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
549 "Cycle to next field.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
550
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
551 Within the header of the message, this command moves between
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
552 fields that are highlighted with the face
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
553 `mh-letter-header-field', skipping those fields listed in
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
554 `mh-compose-skipped-header-fields'. After the last field, this
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
555 command then moves point to the message body before cycling back
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
556 to the first field. If point is already past the first line of
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
557 the message body, then this command indents by calling
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
558 `indent-relative' with the given prefix argument ARG."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
559 (interactive "P")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
560 (let ((header-end (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
561 (goto-char (mh-mail-header-end))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
562 (forward-line)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
563 (point))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
564 (if (> (point) header-end)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
565 (indent-relative arg)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
566 (mh-letter-next-header-field))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
567
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
568 (defun mh-letter-previous-header-field ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
569 "Cycle to the previous header field.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
570
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
571 This command moves backwards between the fields and cycles to the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
572 body of the message after the first field. Unlike the command
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
573 \\[mh-letter-next-header-field-or-indent], it will always take
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
574 point to the last field from anywhere in the body."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
575 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
576 (let ((header-end (mh-mail-header-end)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
577 (if (>= (point) header-end)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
578 (goto-char header-end)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
579 (mh-header-field-beginning))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
580 (cond ((re-search-backward mh-letter-header-field-regexp nil t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
581 (if (mh-letter-skipped-header-field-p (match-string 1))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
582 (mh-letter-previous-header-field)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
583 (goto-char (match-end 0))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
584 (mh-letter-skip-leading-whitespace-in-header-field)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
585 (t (goto-char header-end)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
586 (forward-line)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
587
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
588 (defun mh-open-line ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
589 "Insert a newline and leave point before it.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
590
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
591 This command is similar to the command \\[open-line] in that it
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
592 inserts a newline after point. It differs in that it also inserts
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
593 the right number of quoting characters and spaces so that the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
594 next line begins in the same column as it was. This is useful
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
595 when breaking up paragraphs in replies."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
596 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
597 (let ((column (current-column))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
598 (prefix (mh-current-fill-prefix)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
599 (if (> (length prefix) column)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
600 (message "Sorry, point seems to be within the line prefix")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
601 (newline 2)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
602 (insert prefix)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
603 (while (> column (current-column))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
604 (insert " "))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
605 (forward-line -1))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
606
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
607 (defun mh-to-fcc (&optional folder)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
608 "Move to \"Fcc:\" header field.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
609
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
610 This command will prompt you for the FOLDER name in which to file
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
611 a copy of the draft."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
612 (interactive (list (mh-prompt-for-folder
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
613 "Fcc"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
614 (or (and mh-default-folder-for-message-function
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
615 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
616 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
617 (funcall
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
618 mh-default-folder-for-message-function)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
619 "")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
620 t)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
621 (let ((last-input-char ?\C-f))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
622 (expand-abbrev)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
623 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
624 (mh-to-field)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
625 (insert (if (mh-folder-name-p folder)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
626 (substring folder 1)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
627 folder)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
628
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
629 (defvar mh-to-field-choices '(("a" . "Mail-Reply-To:")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
630 ("b" . "Bcc:")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
631 ("c" . "Cc:")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
632 ("d" . "Dcc:")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
633 ("f" . "Fcc:")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
634 ("l" . "Mail-Followup-To:")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
635 ("m" . "From:")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
636 ("r" . "Reply-To:")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
637 ("s" . "Subject:")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
638 ("t" . "To:"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
639 "Alist of (final-character . field-name) choices for `mh-to-field'.")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
640
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
641 (defun mh-to-field ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
642 "Move to specified header field.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
643
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
644 The field is indicated by the previous keystroke (the last
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
645 keystroke of the command) according to the list in the variable
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
646 `mh-to-field-choices'.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
647 Create the field if it does not exist.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
648 Set the mark to point before moving."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
649 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
650 (expand-abbrev)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
651 (let ((target (cdr (or (assoc (char-to-string (logior last-input-char ?`))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
652 mh-to-field-choices)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
653 ;; also look for a char for version 4 compat
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
654 (assoc (logior last-input-char ?`)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
655 mh-to-field-choices))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
656 (case-fold-search t))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
657 (push-mark)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
658 (cond ((mh-position-on-field target)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
659 (let ((eol (point)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
660 (skip-chars-backward " \t")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
661 (delete-region (point) eol))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
662 (if (and (not (eq (logior last-input-char ?`) ?s))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
663 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
664 (backward-char 1)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
665 (not (looking-at "[:,]"))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
666 (insert ", ")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
667 (insert " ")))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
668 (t
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
669 (if (mh-position-on-field "To:")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
670 (forward-line 1))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
671 (insert (format "%s \n" target))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
672 (backward-char 1)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
673
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
674 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
675 (defun mh-yank-cur-msg ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
676 "Insert the current message into the draft buffer.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
677
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
678 It is often useful to insert a snippet of text from a letter that
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
679 someone mailed to provide some context for your reply. This
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
680 command does this by adding an attribution, yanking a portion of
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
681 text from the message to which you're replying, and inserting
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
682 `mh-ins-buf-prefix' (`> ') before each line.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
683
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
684 The attribution consists of the sender's name and email address
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
685 followed by the content of the option
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
686 `mh-extract-from-attribution-verb'.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
687
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
688 You can also turn on the option
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
689 `mh-delete-yanked-msg-window-flag' to delete the window
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
690 containing the original message after yanking it to make more
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
691 room on your screen for your reply.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
692
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
693 You can control how the message to which you are replying is
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
694 yanked into your reply using `mh-yank-behavior'.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
695
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
696 If this isn't enough, you can gain full control over the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
697 appearance of the included text by setting `mail-citation-hook'
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
698 to a function that modifies it. For example, if you set this hook
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
699 to `trivial-cite' (which is NOT part of Emacs), set
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
700 `mh-yank-behavior' to \"Body and Header\" (see URL
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
701 `http://shasta.cs.uiuc.edu/~lrclause/tc.html').
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
702
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
703 Note that if `mail-citation-hook' is set, `mh-ins-buf-prefix' is
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
704 not inserted. If the option `mh-yank-behavior' is set to one of
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
705 the supercite flavors, the hook `mail-citation-hook' is ignored
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
706 and `mh-ins-buf-prefix' is not inserted."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
707 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
708 (if (and mh-sent-from-folder
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
709 (save-excursion (set-buffer mh-sent-from-folder) mh-show-buffer)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
710 (save-excursion (set-buffer mh-sent-from-folder)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
711 (get-buffer mh-show-buffer))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
712 mh-sent-from-msg)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
713 (let ((to-point (point))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
714 (to-buffer (current-buffer)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
715 (set-buffer mh-sent-from-folder)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
716 (if mh-delete-yanked-msg-window-flag
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
717 (delete-windows-on mh-show-buffer))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
718 (set-buffer mh-show-buffer) ; Find displayed message
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
719 (let* ((from-attr (mh-extract-from-attribution))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
720 (yank-region (mh-mark-active-p nil))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
721 (mh-ins-str
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
722 (cond ((and yank-region
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
723 (or (eq 'supercite mh-yank-behavior)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
724 (eq 'autosupercite mh-yank-behavior)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
725 (eq t mh-yank-behavior)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
726 ;; supercite needs the full header
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
727 (concat
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
728 (buffer-substring (point-min) (mh-mail-header-end))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
729 "\n"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
730 (buffer-substring (region-beginning) (region-end))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
731 (yank-region
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
732 (buffer-substring (region-beginning) (region-end)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
733 ((or (eq 'body mh-yank-behavior)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
734 (eq 'attribution mh-yank-behavior)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
735 (eq 'autoattrib mh-yank-behavior))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
736 (buffer-substring
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
737 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
738 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
739 (mh-goto-header-end 1)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
740 (point))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
741 (point-max)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
742 ((or (eq 'supercite mh-yank-behavior)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
743 (eq 'autosupercite mh-yank-behavior)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
744 (eq t mh-yank-behavior))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
745 (buffer-substring (point-min) (point-max)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
746 (t
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
747 (buffer-substring (point) (point-max))))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
748 (set-buffer to-buffer)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
749 (save-restriction
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
750 (narrow-to-region to-point to-point)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
751 (insert (mh-filter-out-non-text mh-ins-str))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
752 (goto-char (point-max)) ;Needed for sc-cite-original
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
753 (push-mark) ;Needed for sc-cite-original
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
754 (goto-char (point-min)) ;Needed for sc-cite-original
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
755 (mh-insert-prefix-string mh-ins-buf-prefix)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
756 (when (or (eq 'attribution mh-yank-behavior)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
757 (eq 'autoattrib mh-yank-behavior))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
758 (insert from-attr)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
759 (mh-identity-insert-attribution-verb nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
760 (insert "\n\n"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
761 ;; If the user has selected a region, he has already "edited" the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
762 ;; text, so leave the cursor at the end of the yanked text. In
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
763 ;; either case, leave a mark at the opposite end of the included
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
764 ;; text to make it easy to jump or delete to the other end of the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
765 ;; text.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
766 (push-mark)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
767 (goto-char (point-max))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
768 (if (null yank-region)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
769 (mh-exchange-point-and-mark-preserving-active-mark)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
770 (error "There is no current message")))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
771
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
772
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
773
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
774 ;;; Support Routines
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
775
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
776 (defun mh-auto-fill-for-letter ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
777 "Perform auto-fill for message.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
778 Header is treated specially by inserting a tab before continuation
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
779 lines."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
780 (if (mh-in-header-p)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
781 (let ((fill-prefix "\t"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
782 (do-auto-fill))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
783 (do-auto-fill)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
784
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
785 (defun mh-filter-out-non-text (string)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
786 "Return STRING but without adornments such as MIME buttons and smileys."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
787 (with-temp-buffer
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
788 ;; Insert the string to filter
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
789 (insert string)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
790 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
791
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
792 ;; Remove the MIME buttons
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
793 (let ((can-move-forward t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
794 (in-button nil))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
795 (while can-move-forward
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
796 (cond ((and (not (get-text-property (point) 'mh-data))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
797 in-button)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
798 (delete-region (1- (point)) (point))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
799 (setq in-button nil))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
800 ((get-text-property (point) 'mh-data)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
801 (delete-region (point)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
802 (save-excursion (forward-line) (point)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
803 (setq in-button t))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
804 (t (setq can-move-forward (= (forward-line) 0))))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
805
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
806 ;; Return the contents without properties... This gets rid of emphasis
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
807 ;; and smileys
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
808 (buffer-substring-no-properties (point-min) (point-max))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
809
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
810 (defun mh-current-fill-prefix ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
811 "Return the `fill-prefix' on the current line as a string."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
812 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
813 (beginning-of-line)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
814 ;; This assumes that the major-mode sets up adaptive-fill-regexp
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
815 ;; correctly such as mh-letter-mode or sendmail.el's mail-mode. But
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
816 ;; perhaps I should use the variable and simply inserts its value here,
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
817 ;; and set it locally in a let scope. --psg
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
818 (if (re-search-forward adaptive-fill-regexp nil t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
819 (match-string 0)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
820 "")))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
821
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
822 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
823 (defun mh-letter-next-header-field ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
824 "Cycle to the next header field.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
825 If we are at the last header field go to the start of the message
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
826 body."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
827 (let ((header-end (mh-mail-header-end)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
828 (cond ((>= (point) header-end) (goto-char (point-min)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
829 ((< (point) (progn
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
830 (beginning-of-line)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
831 (re-search-forward mh-letter-header-field-regexp
68529
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68519
diff changeset
832 (mh-line-end-position) t)
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
833 (point)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
834 (beginning-of-line))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
835 (t (end-of-line)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
836 (cond ((re-search-forward mh-letter-header-field-regexp header-end t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
837 (if (mh-letter-skipped-header-field-p (match-string 1))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
838 (mh-letter-next-header-field)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
839 (mh-letter-skip-leading-whitespace-in-header-field)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
840 (t (goto-char header-end)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
841 (forward-line)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
842
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
843 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
844 (defun mh-position-on-field (field &optional ignored)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
845 "Move to the end of the FIELD in the header.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
846 Move to end of entire header if FIELD not found.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
847 Returns non-nil iff FIELD was found.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
848 The optional second arg is for pre-version 4 compatibility and is
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
849 IGNORED."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
850 (cond ((mh-goto-header-field field)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
851 (mh-header-field-end)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
852 t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
853 ((mh-goto-header-end 0)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
854 nil)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
855
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
856 (defun mh-letter-header-field-at-point ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
857 "Return the header field name at point.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
858 A symbol is returned whose name is the string obtained by
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
859 downcasing the field name."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
860 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
861 (end-of-line)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
862 (and (re-search-backward mh-letter-header-field-regexp nil t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
863 (intern (downcase (match-string 1))))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
864
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
865 (defun mh-folder-expand-at-point ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
866 "Do folder name completion in Fcc header field."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
867 (let* ((end (point))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
868 (beg (mh-beginning-of-word))
70214
da7bc97733d6 (mh-folder-expand-at-point): Fix folder completion. Folders returned
Bill Wohler <wohler@newt.com>
parents: 70169
diff changeset
869 (folder (buffer-substring-no-properties beg end))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
870 (leading-plus (and (> (length folder) 0) (equal (aref folder 0) ?+)))
70214
da7bc97733d6 (mh-folder-expand-at-point): Fix folder completion. Folders returned
Bill Wohler <wohler@newt.com>
parents: 70169
diff changeset
871 (choices (mapcar (lambda (x) (list x))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
872 (mh-folder-completion-function folder nil t))))
70214
da7bc97733d6 (mh-folder-expand-at-point): Fix folder completion. Folders returned
Bill Wohler <wohler@newt.com>
parents: 70169
diff changeset
873 (unless leading-plus
da7bc97733d6 (mh-folder-expand-at-point): Fix folder completion. Folders returned
Bill Wohler <wohler@newt.com>
parents: 70169
diff changeset
874 (setq folder (concat "+" folder)))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
875 (mh-complete-word folder choices beg end)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
876
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
877 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
878 (defun mh-complete-word (word choices begin end)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
879 "Complete WORD at from CHOICES.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
880 Any match found replaces the text from BEGIN to END."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
881 (let ((completion (try-completion word choices))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
882 (completions-buffer "*Completions*"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
883 (cond ((eq completion t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
884 (ignore-errors
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
885 (kill-buffer completions-buffer))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
886 (message "Completed: %s" word))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
887 ((null completion)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
888 (ignore-errors
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
889 (kill-buffer completions-buffer))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
890 (message "No completion for %s" word))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
891 ((stringp completion)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
892 (if (equal word completion)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
893 (with-output-to-temp-buffer completions-buffer
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
894 (mh-display-completion-list (all-completions word choices)
68519
bf46ace1ce4e (mh-complete-word): Fix bug in call to mh-display-completion-list.
Bill Wohler <wohler@newt.com>
parents: 68477
diff changeset
895 word))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
896 (ignore-errors
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
897 (kill-buffer completions-buffer))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
898 (delete-region begin end)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
899 (insert completion))))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
900
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
901 (defun mh-file-is-vcard-p (file)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
902 "Return t if FILE is a .vcf vcard."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
903 (let ((case-fold-search t))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
904 (and (stringp file)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
905 (file-exists-p file)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
906 (or (and (not (mh-have-file-command))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
907 (not (null (string-match "\.vcf$" file))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
908 (string-equal "text/x-vcard" (mh-file-mime-type file))))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
909
68477
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68473
diff changeset
910 ;;;###mh-autoload
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
911 (defun mh-letter-toggle-header-field-display-button (event)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
912 "Toggle header field display at location of EVENT.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
913 This function does the same thing as
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
914 `mh-letter-toggle-header-field-display' except that it is
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
915 callable from a mouse button."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
916 (interactive "e")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
917 (mh-do-at-event-location event
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
918 (mh-letter-toggle-header-field-display nil)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
919
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
920 (defun mh-extract-from-attribution ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
921 "Extract phrase or comment from From header field."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
922 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
923 (if (not (mh-goto-header-field "From: "))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
924 nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
925 (skip-chars-forward " ")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
926 (cond
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
927 ((looking-at "\"\\([^\"\n]+\\)\" \\(<.+>\\)")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
928 (format "%s %s " (match-string 1)(match-string 2)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
929 ((looking-at "\\([^<\n]+<.+>\\)$")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
930 (format "%s " (match-string 1)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
931 ((looking-at "\\([^ ]+@[^ ]+\\) +(\\(.+\\))$")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
932 (format "%s <%s> " (match-string 2)(match-string 1)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
933 ((looking-at " *\\(.+\\)$")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
934 (format "%s " (match-string 1)))))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
935
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
936 (defun mh-insert-prefix-string (mh-ins-string)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
937 "Insert prefix string before each line in buffer.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
938 The inserted letter is cited using `sc-cite-original' if
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
939 `mh-yank-behavior' is one of 'supercite or 'autosupercite.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
940 Otherwise, simply insert MH-INS-STRING before each line."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
941 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
942 (cond ((or (eq mh-yank-behavior 'supercite)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
943 (eq mh-yank-behavior 'autosupercite))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
944 (sc-cite-original))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
945 (mail-citation-hook
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
946 (run-hooks 'mail-citation-hook))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
947 (mh-yank-hooks ;old hook name
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
948 (run-hooks 'mh-yank-hooks))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
949 (t
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
950 (or (bolp) (forward-line 1))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
951 (while (< (point) (point-max))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
952 (insert mh-ins-string)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
953 (forward-line 1))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
954 (goto-char (point-min))))) ;leave point like sc-cite-original
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
955
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
956 (provide 'mh-letter)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
957
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
958 ;; Local Variables:
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
959 ;; indent-tabs-mode: nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
960 ;; sentence-end-double-space: nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
961 ;; End:
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
962
68470
4bd450a8dbe2 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 68465
diff changeset
963 ;; arch-tag: 0548632c-aadb-4e3b-bb80-bbd62ff90bf3
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents:
diff changeset
964 ;;; mh-letter.el ends here