comparison lisp/mh-e/mh-identity.el @ 67758:6b063593fdad

Follow Emacs coding conventions. Use default setting of emacs-lisp-docstring-fill-column which is 65.
author Bill Wohler <wohler@newt.com>
date Fri, 23 Dec 2005 07:40:40 +0000
parents 3a8785724cca
children 9c3504ae6060
comparison
equal deleted inserted replaced
67757:488b4dbc7482 67758:6b063593fdad
45 45
46 (autoload 'mml-insert-tag "mml") 46 (autoload 'mml-insert-tag "mml")
47 47
48 (defvar mh-identity-pgg-default-user-id nil 48 (defvar mh-identity-pgg-default-user-id nil
49 "Holds the GPG key ID to be used by pgg.el. 49 "Holds the GPG key ID to be used by pgg.el.
50 This is normally set as part of an Identity in `mh-identity-list'.") 50 This is normally set as part of an Identity in
51 `mh-identity-list'.")
51 (make-variable-buffer-local 'mh-identity-pgg-default-user-id) 52 (make-variable-buffer-local 'mh-identity-pgg-default-user-id)
52 53
53 ;;;###mh-autoload 54 ;;;###mh-autoload
54 (defun mh-identity-make-menu () 55 (defun mh-identity-make-menu ()
55 "Build the Identity menu. 56 "Build the Identity menu.
56 This should be called any time `mh-identity-list' or `mh-auto-fields-list' 57 This should be called any time `mh-identity-list' or
57 change." 58 `mh-auto-fields-list' change."
58 (easy-menu-define mh-identity-menu mh-letter-mode-map 59 (easy-menu-define mh-identity-menu mh-letter-mode-map
59 "MH-E identity menu" 60 "MH-E identity menu"
60 (append 61 (append
61 '("Identity") 62 '("Identity")
62 ;; Dynamically render :type corresponding to `mh-identity-list' 63 ;; Dynamically render :type corresponding to `mh-identity-list'
85 )))) 86 ))))
86 87
87 ;;;###mh-autoload 88 ;;;###mh-autoload
88 (defun mh-identity-list-set (symbol value) 89 (defun mh-identity-list-set (symbol value)
89 "Update the `mh-identity-list' variable, and rebuild the menu. 90 "Update the `mh-identity-list' variable, and rebuild the menu.
90 Sets the default for SYMBOL (for example, `mh-identity-list') to VALUE (as set 91 Sets the default for SYMBOL (for example, `mh-identity-list') to
91 in customization). This is called after 'customize is used to alter 92 VALUE (as set in customization). This is called after 'customize
92 `mh-identity-list'." 93 is used to alter `mh-identity-list'."
93 (set-default symbol value) 94 (set-default symbol value)
94 (mh-identity-make-menu)) 95 (mh-identity-make-menu))
95 96
96 (defvar mh-identity-local nil 97 (defvar mh-identity-local nil
97 "Buffer-local variable that holds the identity currently in use.") 98 "Buffer-local variable that holds the identity currently in use.")
118 (defvar mh-identity-signature-end nil 119 (defvar mh-identity-signature-end nil
119 "Marker for the end of a signature inserted by `mh-insert-identity'.") 120 "Marker for the end of a signature inserted by `mh-insert-identity'.")
120 121
121 (defun mh-identity-field-handler (field) 122 (defun mh-identity-field-handler (field)
122 "Return the handler for header FIELD or nil if none set. 123 "Return the handler for header FIELD or nil if none set.
123 The field name is downcased. If the FIELD begins with the character 124 The field name is downcased. If the FIELD begins with the
124 `:', then it must have a special handler defined in 125 character `:', then it must have a special handler defined in
125 `mh-identity-handlers', else return an error since it is not a valid 126 `mh-identity-handlers', else return an error since it is not a
126 header field." 127 valid header field."
127 (or (cdr (mh-assoc-ignore-case field mh-identity-handlers)) 128 (or (cdr (mh-assoc-ignore-case field mh-identity-handlers))
128 (and (eq (aref field 0) ?:) 129 (and (eq (aref field 0) ?:)
129 (error "Field %s - unknown mh-identity-handler" field)) 130 (error "Field %s - unknown mh-identity-handler" field))
130 (cdr (assoc ":default" mh-identity-handlers)) 131 (cdr (assoc ":default" mh-identity-handlers))
131 'mh-identity-handler-default)) 132 'mh-identity-handler-default))
167 168
168 ;;;###mh-autoload 169 ;;;###mh-autoload
169 (defun mh-identity-handler-gpg-identity (field action &optional value) 170 (defun mh-identity-handler-gpg-identity (field action &optional value)
170 "Process header FIELD \":pgg-default-user-id\". 171 "Process header FIELD \":pgg-default-user-id\".
171 The ACTION is one of 'remove or 'add. If 'add, the VALUE is added. 172 The ACTION is one of 'remove or 'add. If 'add, the VALUE is added.
172 The buffer-local variable `mh-identity-pgg-default-user-id' is set to VALUE 173 The buffer-local variable `mh-identity-pgg-default-user-id' is set to
173 when action 'add is selected." 174 VALUE when action 'add is selected."
174 (cond 175 (cond
175 ((or (equal action 'remove) 176 ((or (equal action 'remove)
176 (not value) 177 (not value)
177 (string= value "")) 178 (string= value ""))
178 (setq mh-identity-pgg-default-user-id nil)) 179 (setq mh-identity-pgg-default-user-id nil))
180 (setq mh-identity-pgg-default-user-id value)))) 181 (setq mh-identity-pgg-default-user-id value))))
181 182
182 ;;;###mh-autoload 183 ;;;###mh-autoload
183 (defun mh-identity-handler-signature (field action &optional value) 184 (defun mh-identity-handler-signature (field action &optional value)
184 "Process header FIELD \":signature\". 185 "Process header FIELD \":signature\".
185 The ACTION is one of 'remove or 'add. If 'add, the VALUE is added." 186 The ACTION is one of 'remove or 'add. If 'add, the VALUE is
187 added."
186 (cond 188 (cond
187 ((equal action 'remove) 189 ((equal action 'remove)
188 (when (and (markerp mh-identity-signature-start) 190 (when (and (markerp mh-identity-signature-start)
189 (markerp mh-identity-signature-end)) 191 (markerp mh-identity-signature-end))
190 (delete-region mh-identity-signature-start 192 (delete-region mh-identity-signature-start
210 "Marker for the end of the attribution verb.") 212 "Marker for the end of the attribution verb.")
211 213
212 ;;;###mh-autoload 214 ;;;###mh-autoload
213 (defun mh-identity-handler-attribution-verb (field action &optional value) 215 (defun mh-identity-handler-attribution-verb (field action &optional value)
214 "Process header FIELD \":attribution-verb\". 216 "Process header FIELD \":attribution-verb\".
215 The ACTION is one of 'remove or 'add. If 'add, the VALUE is added." 217 The ACTION is one of 'remove or 'add. If 'add, the VALUE is
218 added."
216 (when (and (markerp mh-identity-attribution-verb-start) 219 (when (and (markerp mh-identity-attribution-verb-start)
217 (markerp mh-identity-attribution-verb-end)) 220 (markerp mh-identity-attribution-verb-end))
218 (delete-region mh-identity-attribution-verb-start 221 (delete-region mh-identity-attribution-verb-start
219 mh-identity-attribution-verb-end) 222 mh-identity-attribution-verb-end)
220 (goto-char mh-identity-attribution-verb-start) 223 (goto-char mh-identity-attribution-verb-start)
239 (set (make-local-variable 'mh-identity-attribution-verb-end) 242 (set (make-local-variable 'mh-identity-attribution-verb-end)
240 (point-max-marker)))) 243 (point-max-marker))))
241 244
242 (defun mh-identity-handler-default (field action top &optional value) 245 (defun mh-identity-handler-default (field action top &optional value)
243 "Process header FIELD. 246 "Process header FIELD.
244 The ACTION is one of 'remove or 'add. If TOP is non-nil, add the field and its 247 The ACTION is one of 'remove or 'add. If TOP is non-nil, add the
245 VALUE at the top of the header, else add it at the bottom of the header. If 248 field and its VALUE at the top of the header, else add it at the
246 action is 'add, the VALUE is added." 249 bottom of the header. If action is 'add, the VALUE is added."
247 (let ((field-colon (if (string-match "^.*:$" field) 250 (let ((field-colon (if (string-match "^.*:$" field)
248 field 251 field
249 (concat field ":")))) 252 (concat field ":"))))
250 (cond 253 (cond
251 ((equal action 'remove) 254 ((equal action 'remove)
267 (insert field-colon " " value "\n"))))))) 270 (insert field-colon " " value "\n")))))))
268 271
269 ;;;###mh-autoload 272 ;;;###mh-autoload
270 (defun mh-identity-handler-top (field action &optional value) 273 (defun mh-identity-handler-top (field action &optional value)
271 "Process header FIELD. 274 "Process header FIELD.
272 The ACTION is one of 'remove or 'add. If 'add, the VALUE is added. 275 The ACTION is one of 'remove or 'add. If 'add, the VALUE is
273 If the field wasn't present, it is added to the top of the header." 276 added. If the field wasn't present, it is added to the top of the
277 header."
274 (mh-identity-handler-default field action t value)) 278 (mh-identity-handler-default field action t value))
275 279
276 ;;;###mh-autoload 280 ;;;###mh-autoload
277 (defun mh-identity-handler-bottom (field action &optional value) 281 (defun mh-identity-handler-bottom (field action &optional value)
278 "Process header FIELD. 282 "Process header FIELD.
279 The ACTION is one of 'remove or 'add. If 'add, the VALUE is added. 283 The ACTION is one of 'remove or 'add. If 'add, the VALUE is
280 If the field wasn't present, it is added to the bottom of the header." 284 added. If the field wasn't present, it is added to the bottom of
285 the header."
281 (mh-identity-handler-default field action nil value)) 286 (mh-identity-handler-default field action nil value))
282 287
283 (provide 'mh-identity) 288 (provide 'mh-identity)
284 289
285 ;; Local Variables: 290 ;; Local Variables: