annotate lisp/mail/mh-identity.el @ 49130:9313ae7d2d5b

*** empty log message ***
author John Wiegley <johnw@newartisans.com>
date Fri, 10 Jan 2003 07:00:59 +0000
parents 30c4902b654d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49120
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1 ;;; mh-identity.el --- Multiple Identify support for MH-E.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
2
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
3 ;; Copyright (C) 2002 Free Software Foundation, Inc.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
4
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
5 ;; Author: Peter S. Galbraith <psg@debian.org>
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
6 ;; Maintainer: Bill Wohler <wohler@newt.com>
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
7 ;; Keywords: mail
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
8 ;; See: mh-e.el
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
9
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
11
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
15 ;; any later version.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
16
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
21
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
26
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
27 ;;; Commentary:
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
28
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
29 ;; Multiple identity support for MH-E.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
30 ;;
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
31 ;; Used to easily set different fields such as From and Organization, as
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
32 ;; well as different signature files.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
33 ;;
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
34 ;; Customize the variable `mh-identity-list' and an Identity menu will
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
35 ;; appear in mh-letter-mode. The command 'mh-insert-identity can be used
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
36 ;; from the command line.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
37
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
38 ;;; Change Log:
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
39
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
40 ;; $Id: mh-identity.el,v 1.17 2002/12/03 15:54:27 psg Exp $
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
41
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
42 ;;; Code:
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
43
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
44
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
45 (require 'cl)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
46
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
47 (eval-when (compile load eval)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
48 (defvar mh-comp-loaded nil)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
49 (unless mh-comp-loaded
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
50 (setq mh-comp-loaded t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
51 (require 'mh-comp))) ;Since we do this on sending
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
52
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
53 (autoload 'mml-insert-tag "mml")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
54
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
55 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
56 (defun mh-identity-make-menu ()
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
57 "Build (or rebuild) the Identity menu (e.g. after the list is modified)."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
58 (when (and mh-identity-list (boundp 'mh-letter-mode-map))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
59 (easy-menu-define mh-identity-menu mh-letter-mode-map
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
60 "mh-e identity menu"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
61 (append
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
62 '("Identity")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
63 ;; Dynamically render :type corresponding to `mh-identity-list'
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
64 ;; e.g.:
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
65 ;; ["home" (mh-insert-identity "home")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
66 ;; :style radio :active (not (equal mh-identity-local "home"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
67 ;; :selected (equal mh-identity-local "home")]
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
68 (mapcar (function
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
69 (lambda (arg)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
70 `[,arg (mh-insert-identity ,arg) :style radio
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
71 :active (not (equal mh-identity-local ,arg))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
72 :selected (equal mh-identity-local ,arg)]))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
73 (mapcar 'car mh-identity-list))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
74 '("--"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
75 ["none" (mh-insert-identity "none") mh-identity-local]
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
76 ["Set Default for Session"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
77 (setq mh-identity-default mh-identity-local) t]
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
78 ["Save as Default"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
79 (customize-save-variable
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
80 'mh-identity-default mh-identity-local) t]
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
81 )))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
82
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
83 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
84 (defun mh-identity-list-set (symbol value)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
85 "Update the `mh-identity-list' variable, and rebuild the menu.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
86 Sets the default for SYMBOL (e.g. `mh-identity-list') to VALUE (as set in
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
87 customization). This is called after 'customize is used to alter
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
88 `mh-identity-list'."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
89 (set-default symbol value)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
90 (mh-identity-make-menu))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
91
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
92 (defvar mh-identity-local nil
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
93 "Buffer-local variable holding the identity currently in use.")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
94 (make-variable-buffer-local 'mh-identity-local)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
95
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
96 (defun mh-header-field-delete (field value-only)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
97 "Delete FIELD in the mail header, or only its value if VALUE-ONLY is t.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
98 Return t if anything is deleted."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
99 (when (mh-goto-header-field field)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
100 (if (not value-only)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
101 (beginning-of-line)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
102 (forward-char))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
103 (delete-region (point)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
104 (progn (mh-header-field-end)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
105 (if (not value-only) (forward-char 1))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
106 (point)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
107 t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
108
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
109 (defvar mh-identity-signature-start nil
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
110 "Marker for the beginning of a signature inserted by `mh-insert-identity'.")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
111 (defvar mh-identity-signature-end nil
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
112 "Marker for the end of a signature inserted by `mh-insert-identity'.")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
113
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
114 ;;;###mh-autoload
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
115 (defun mh-insert-identity (identity)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
116 "Insert proper fields for given IDENTITY.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
117 Edit the `mh-identity-list' variable to define identity."
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
118 (interactive
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
119 (list (completing-read
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
120 "Identity: "
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
121 (if mh-identity-local
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
122 (cons '("none")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
123 (mapcar 'list (mapcar 'car mh-identity-list)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
124 (mapcar 'list (mapcar 'car mh-identity-list)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
125 nil t)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
126 (save-excursion
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
127 ;;First remove old settings, if any.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
128 (when mh-identity-local
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
129 (let ((pers-list (cadr (assoc mh-identity-local mh-identity-list))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
130 (while pers-list
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
131 (let ((field (concat (caar pers-list) ":")))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
132 (cond
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
133 ((string-equal "signature:" field)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
134 (when (and (boundp 'mh-identity-signature-start)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
135 (markerp mh-identity-signature-start))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
136 (goto-char mh-identity-signature-start)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
137 (forward-char -1)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
138 (delete-region (point) mh-identity-signature-end)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
139 ((mh-header-field-delete field nil))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
140 (setq pers-list (cdr pers-list)))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
141 ;; Then insert the replacement
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
142 (when (not (equal "none" identity))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
143 (let ((pers-list (cadr (assoc identity mh-identity-list))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
144 (while pers-list
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
145 (let ((field (concat (caar pers-list) ":"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
146 (value (cdar pers-list)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
147 (cond
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
148 ;; No value, remove field
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
149 ((or (not value)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
150 (string= value ""))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
151 (mh-header-field-delete field nil))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
152 ;; Existing field, replace
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
153 ((mh-header-field-delete field t)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
154 (insert value))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
155 ;; Handle "signature" special case. Insert file or call function.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
156 ((and (string-equal "signature:" field)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
157 (or (and (stringp value)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
158 (file-readable-p value))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
159 (fboundp value)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
160 (goto-char (point-max))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
161 (if (not (looking-at "^$"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
162 (insert "\n"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
163 (insert "\n")
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
164 (save-restriction
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
165 (narrow-to-region (point) (point))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
166 (set (make-local-variable 'mh-identity-signature-start)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
167 (make-marker))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
168 (set-marker mh-identity-signature-start (point))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
169 (cond
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
170 ;; If MIME composition done, insert signature at the end as
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
171 ;; an inline MIME part.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
172 ((and (boundp 'mh-mhn-compose-insert-flag)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
173 mh-mhn-compose-insert-flag)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
174 (insert "#\n" "Content-Description: Signature\n"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
175 ((and (boundp 'mh-mml-compose-insert-flag)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
176 mh-mml-compose-insert-flag)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
177 (mml-insert-tag 'part 'type "text/plain"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
178 'disposition "inline"
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
179 'description "Signature")))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
180 (if (stringp value)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
181 (insert-file-contents value)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
182 (funcall value))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
183 (goto-char (point-min))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
184 (when (not (re-search-forward "^--" nil t))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
185 (if (and (boundp 'mh-mhn-compose-insert-flag)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
186 mh-mhn-compose-insert-flag)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
187 (forward-line 2))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
188 (if (and (boundp 'mh-mml-compose-insert-flag)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
189 mh-mml-compose-insert-flag)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
190 (forward-line 1))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
191 (insert "-- \n"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
192 (set (make-local-variable 'mh-identity-signature-end)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
193 (make-marker))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
194 (set-marker mh-identity-signature-end (point-max))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
195 ;; Handle "From" field differently, adding it at the beginning.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
196 ((string-equal "From:" field)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
197 (goto-char (point-min))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
198 (insert "From: " value "\n"))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
199 ;; Skip empty signature (Can't remove what we don't know)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
200 ((string-equal "signature:" field))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
201 ;; Other field, add at end
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
202 (t ;Otherwise, add the end.
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
203 (goto-char (point-min))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
204 (mh-goto-header-end 0)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
205 (mh-insert-fields field value))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
206 (setq pers-list (cdr pers-list))))))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
207 ;; Remember what is in use in this buffer
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
208 (if (equal "none" identity)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
209 (setq mh-identity-local nil)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
210 (setq mh-identity-local identity)))
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
211
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
212 (provide 'mh-identity)
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
213
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
214 ;;; Local Variables:
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
215 ;;; indent-tabs-mode: nil
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
216 ;;; sentence-end-double-space: nil
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
217 ;;; End:
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
218
30c4902b654d Upgraded to MH-E version 7.1.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
219 ;;; mh-identity.el ends here