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)
11 ;;; $Id: signature.el,v 2.0 1995/10/05 11:24:45 morioka Exp $
12 ;;; Keywords: mail, news, signature
14 ;;; This file is part of tm (Tools for MIME).
19 (defvar signature-insert-at-eof nil
20 "*Insert signature at the end of file if non-nil.")
22 (defvar signature-file-name "~/.signature"
23 "*Name of file containing the user's signature.")
25 (defvar signature-file-alist nil)
30 ;;; (setq signature-file-alist
31 ;;; '((("Newsgroups" . "zxr") . "~/.signature-sun")
32 ;;; (("To" . "uramimi") . "~/.signature-sun")
33 ;;; (("Newsgroups" . "jokes") . "~/.signature-jokes")
34 ;;; (("To" . "tea") . "~/.signature-jokes")
35 ;;; (("To" . ("sim" "oku")) . "~/.signature-formal")
38 (defun signature/get-signature-file-name ()
40 (let ((r signature-file-alist) cell b f)
44 (if (setq f (rfc822/get-field-body (car b)))
45 (cond ((listp (cdr b))
48 (if (string-match (car r) f)
49 (throw 'tag (cdr cell))
55 (if (string-match (cdr b) f)
56 (throw 'tag (cdr cell))
63 (defun signature/insert-signature-at-point (&optional arg)
64 "Insert the file named by signature-file-name at the current point."
69 (read-file-name "Insert your signature: "
70 (concat signature-file-name "-")
73 (signature/get-signature-file-name)))))
74 (insert-file-contents signature)
75 (set-buffer-modified-p (buffer-modified-p)))) ; force mode line update
77 (defun signature/insert-signature-at-eof (&optional arg)
78 "Insert the file named by signature-file-name at the end of file."
83 (read-file-name "Insert your signature: "
84 (concat signature-file-name "-")
87 (signature/get-signature-file-name)))))
89 (if (file-readable-p signature)
91 (goto-char (point-max))
95 (insert-file-contents signature)
96 (set-buffer-modified-p (buffer-modified-p))
97 ; force mode line update
100 (defun insert-signature (&optional arg)
101 "Insert the file named by signature-file-name. It is inserted at the
102 end of file if signature-insert-at-eof in non-nil, and otherwise at
103 the current point. A prefix argument enables user to specify a file
104 named <signature-file-name>-DISTRIBUTION interactively."
106 (if signature-insert-at-eof
107 (call-interactively 'signature/insert-signature-at-eof)
108 (call-interactively 'signature/insert-signature-at-point)))