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 7.1 1995/12/14 06:22:20 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)
46 (goto-char (point-min))
47 (if (re-search-forward
48 (concat "^" (regexp-quote mail-header-separator) "$")
56 (if (setq f (rfc822/get-field-body (car b)))
57 (cond ((listp (cdr b))
60 (if (string-match (car r) f)
61 (throw 'tag (cdr cell))
67 (if (string-match (cdr b) f)
68 (throw 'tag (cdr cell))
73 signature-file-name))))
75 (defun signature/insert-signature-at-point (&optional arg)
76 "Insert the file named by signature-file-name at the current point."
81 (read-file-name "Insert your signature: "
82 (concat signature-file-name "-")
85 (signature/get-signature-file-name)))))
86 (insert-file-contents signature)
87 (set-buffer-modified-p (buffer-modified-p)) ; force mode line update
90 (defun signature/insert-signature-at-eof (&optional arg)
91 "Insert the file named by signature-file-name at the end of file."
96 (read-file-name "Insert your signature: "
97 (concat signature-file-name "-")
100 (signature/get-signature-file-name)))))
101 (if (file-readable-p signature)
103 (goto-char (point-max))
106 ;;(delete-blank-lines)
107 (insert-file-contents signature)
108 (set-buffer-modified-p (buffer-modified-p))
109 ; force mode line update
113 (defun insert-signature (&optional arg)
114 "Insert the file named by signature-file-name. It is inserted at the
115 end of file if signature-insert-at-eof in non-nil, and otherwise at
116 the current point. A prefix argument enables user to specify a file
117 named <signature-file-name>-DISTRIBUTION interactively."
119 (if signature-insert-at-eof
120 (call-interactively 'signature/insert-signature-at-eof)
121 (call-interactively 'signature/insert-signature-at-point)))