2 ;;; signature.el --- signature utility for GNU Emacs
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
6 ;;; Copyright (C) 1994 OKABE Yasuo
8 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
9 ;;; OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp> (1994/08/01)
10 ;;; Created: 1994/7/11
12 ;;; $Id: signature.el,v 7.3 1995/12/25 05:29:00 morioka Exp $
13 ;;; Keywords: mail, news, signature
15 ;;; This file is part of tm (Tools for MIME).
17 ;;; This program is free software; you can redistribute it and/or
18 ;;; modify it under the terms of the GNU General Public License as
19 ;;; published by the Free Software Foundation; either version 2, or
20 ;;; (at your option) any later version.
22 ;;; This program is distributed in the hope that it will be useful,
23 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 ;;; General Public License for more details.
27 ;;; You should have received a copy of the GNU General Public License
28 ;;; along with This program. If not, write to the Free Software
29 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
35 (defvar signature-insert-at-eof nil
36 "*Insert signature at the end of file if non-nil. [signature.el]")
38 (defvar signature-delete-blank-lines-at-eof nil
39 "*Signature-insert-at-eof deletes blank lines at the end of file
40 if non-nil. [signature.el]")
42 (defvar signature-file-name "~/.signature"
43 "*Name of file containing the user's signature. [signature.el]")
45 (defvar signature-file-alist nil)
50 ;;; (setq signature-file-alist
51 ;;; '((("Newsgroups" . "zxr") . "~/.signature-sun")
52 ;;; (("To" . "uramimi") . "~/.signature-sun")
53 ;;; (("Newsgroups" . "jokes") . "~/.signature-jokes")
54 ;;; (("To" . "tea") . "~/.signature-jokes")
55 ;;; (("To" . ("sim" "oku")) . "~/.signature-formal")
58 (defun signature/get-signature-file-name ()
60 (let ((r signature-file-alist) cell b f)
66 (goto-char (point-min))
67 (if (re-search-forward
68 (concat "^" (regexp-quote mail-header-separator) "$")
76 (if (setq f (rfc822/get-field-body (car b)))
77 (cond ((listp (cdr b))
80 (if (string-match (car r) f)
81 (throw 'tag (cdr cell))
87 (if (string-match (cdr b) f)
88 (throw 'tag (cdr cell))
93 signature-file-name))))
95 (defun signature/insert-signature-at-point (&optional arg)
96 "Insert the file named by signature-file-name at the current point."
101 (read-file-name "Insert your signature: "
102 (concat signature-file-name "-")
105 (signature/get-signature-file-name)))))
106 (insert-file-contents signature)
107 (set-buffer-modified-p (buffer-modified-p)) ; force mode line update
110 (defun signature/insert-signature-at-eof (&optional arg)
111 "Insert the file named by signature-file-name at the end of file."
116 (read-file-name "Insert your signature: "
117 (concat signature-file-name "-")
120 (signature/get-signature-file-name)))))
121 (if (file-readable-p signature)
123 (goto-char (point-max))
126 (if signature-delete-blank-lines-at-eof (delete-blank-lines))
127 (insert-file-contents signature)
128 (set-buffer-modified-p (buffer-modified-p))
129 ; force mode line update
133 (defun insert-signature (&optional arg)
134 "Insert the file named by signature-file-name. It is inserted at the
135 end of file if signature-insert-at-eof in non-nil, and otherwise at
136 the current point. A prefix argument enables user to specify a file
137 named <signature-file-name>-DISTRIBUTION interactively."
139 (if signature-insert-at-eof
140 (call-interactively 'signature/insert-signature-at-eof)
141 (call-interactively 'signature/insert-signature-at-point)))