2 ;;; signature.el --- a signature utility for GNU Emacs
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1994 .. 1996 MORIOKA Tomohiko
6 ;;; Copyright (C) 1994 OKABE Yasuo
7 ;;; Copyright (C) 1996 Artur Pioro
9 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
10 ;;; OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
11 ;;; Artur Pioro <artur@flugor.if.uj.edu.pl>
12 ;;; Created: 1994/7/11
14 ;;; $Id: signature.el,v 7.7 1996/03/14 13:39:57 morioka Exp $
15 ;;; Keywords: mail, news, signature
17 ;;; This file is part of tm (Tools for MIME).
19 ;;; This program is free software; you can redistribute it and/or
20 ;;; modify it under the terms of the GNU General Public License as
21 ;;; published by the Free Software Foundation; either version 2, or
22 ;;; (at your option) any later version.
24 ;;; This program is distributed in the hope that it will be useful,
25 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
26 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 ;;; General Public License for more details.
29 ;;; You should have received a copy of the GNU General Public License
30 ;;; along with This program. If not, write to the Free Software
31 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
37 (defvar signature-insert-at-eof nil
38 "*Insert signature at the end of file if non-nil. [signature.el]")
40 (defvar signature-delete-blank-lines-at-eof nil
41 "*Signature-insert-at-eof deletes blank lines at the end of file
42 if non-nil. [signature.el]")
44 (defvar signature-file-name "~/.signature"
45 "*Name of file containing the user's signature. [signature.el]")
47 (defvar signature-file-alist nil)
49 (defvar signature-file-prefix nil
50 "*String containing optional prefix for the signature file names")
55 ;;; (setq signature-file-alist
56 ;;; '((("To" . signature-check-in-bbdb) . nil)
57 ;;; (("Newsgroups" . "zxr") . "~/.signature-sun")
58 ;;; (("To" . "uramimi") . "~/.signature-sun")
59 ;;; (("Newsgroups" . "jokes") . "~/.signature-jokes")
60 ;;; (("To" . "tea") . "~/.signature-jokes")
61 ;;; (("To" . ("sim" "oku")) . "~/.signature-formal")
64 (autoload 'signature-check-in-bbdb "tm-bbdb")
66 (defun signature/get-signature-file-name ()
68 (let ((r signature-file-alist) cell b f)
74 (goto-char (point-min))
75 (if (re-search-forward
76 (concat "^" (regexp-quote mail-header-separator) "$")
84 (if (setq f (rfc822/get-field-body (car b)))
85 (cond ((listp (cdr b))
88 (if (string-match (car r) f)
91 signature-file-prefix (cdr cell)))
97 (if (string-match (cdr b) f)
100 signature-file-prefix (cdr cell)))
103 (let ((name (apply (cdr b) f (cdr cell))))
106 (concat signature-file-prefix name))
111 signature-file-name))))
113 (defun signature/insert-signature-at-point (&optional arg)
114 "Insert the file named by signature-file-name at the current point."
119 (read-file-name "Insert your signature: "
120 (concat signature-file-name "-")
123 (signature/get-signature-file-name)))))
124 (insert-file-contents signature)
125 (set-buffer-modified-p (buffer-modified-p)) ; force mode line update
128 (defun signature/insert-signature-at-eof (&optional arg)
129 "Insert the file named by signature-file-name at the end of file."
134 (read-file-name "Insert your signature: "
135 (concat signature-file-name "-")
138 (signature/get-signature-file-name)))))
139 (if (file-readable-p signature)
141 (goto-char (point-max))
144 (if signature-delete-blank-lines-at-eof (delete-blank-lines))
145 (insert-file-contents signature)
146 (set-buffer-modified-p (buffer-modified-p))
147 ; force mode line update
151 (defun insert-signature (&optional arg)
152 "Insert the file named by signature-file-name. It is inserted at the
153 end of file if signature-insert-at-eof in non-nil, and otherwise at
154 the current point. A prefix argument enables user to specify a file
155 named <signature-file-name>-DISTRIBUTION interactively."
157 (if signature-insert-at-eof
158 (call-interactively 'signature/insert-signature-at-eof)
159 (call-interactively 'signature/insert-signature-at-point)))
167 ;;; signature.el ends here