From e8da5161c2ceaa38c9cf9c13dd581db4c3abd459 Mon Sep 17 00:00:00 2001 From: morioka Date: Mon, 2 Mar 1998 13:30:28 +0000 Subject: [PATCH 1/1] tm4.7.0. --- signature.el | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 signature.el diff --git a/signature.el b/signature.el new file mode 100644 index 0000000..c1362d2 --- /dev/null +++ b/signature.el @@ -0,0 +1,98 @@ +;;; +;;; $Id: signature.el,v 1.6 1994/08/03 04:42:40 morioka Exp $ +;;; Modified by Yasuo OKABE 1994/08/01 +;;; + +(provide 'signature) + +(require 'tl-header) + +(defvar signature-insert-at-eof nil + "*Insert signature at the end of file if non-nil.") + +(defvar signature-file-name "~/.signature" + "*Name of file containing the user's signature.") + +(defvar signature-file-alist nil) + +;;; +;;; Example: +;;; +;;; (setq signature-file-alist +;;; '((("Newsgroups" . "zxr") . "~/.signature-sun") +;;; (("To" . "uramimi") . "~/.signature-sun") +;;; (("Newsgroups" . "jokes") . "~/.signature-jokes") +;;; (("To" . "tea") . "~/.signature-jokes") +;;; (("To" . ("sim" "oku")) . "~/.signature-formal") +;;; )) + +(defun signature/get-signature-file-name () + (catch 'tag + (let ((r signature-file-alist) cell b f) + (while r + (setq cell (car r)) + (setq b (car cell)) + (if (setq f (message/get-field-body (car b))) + (cond ((listp (cdr b)) + (let ((r (cdr b))) + (while r + (if (string-match (car r) f) + (throw 'tag (cdr cell)) + ) + (setq r (cdr r)) + )) + ) + ((stringp (cdr b)) + (if (string-match (cdr b) f) + (throw 'tag (cdr cell)) + )) + )) + (setq r (cdr r)) + )) + signature-file-name)) + +(defun signature/insert-signature-at-point (&optional arg) + "Insert the file named by signature-file-name at the current point." + (interactive "P") + (let ((signature + (expand-file-name + (if arg + (read-file-name "Insert your signature: " + (concat signature-file-name "-") + signature-file-name + nil) + (signature/get-signature-file-name))))) + (insert-file-contents signature) + (set-buffer-modified-p (buffer-modified-p)))) ; force mode line update + +(defun signature/insert-signature-at-eof (&optional arg) + "Insert the file named by signature-file-name at the end of file." + (interactive "P") + (let ((signature + (expand-file-name + (if arg + (read-file-name "Insert your signature: " + (concat signature-file-name "-") + signature-file-name + nil) + (signature/get-signature-file-name))))) + (save-excursion + (if (file-readable-p signature) + (progn + (goto-char (point-max)) + (if (not (bolp)) + (insert "\n")) + (delete-blank-lines) + (insert-file-contents signature) + (set-buffer-modified-p (buffer-modified-p)) ; force mode line update + ))))) + +(defun insert-signature (&optional arg) + "Insert the file named by signature-file-name. It is inserted at the +end of file if signature-insert-at-eof in non-nil, and otherwise at +the current point. A prefix argument enables user to specify a file +named -DISTRIBUTION interactively." + (interactive "P") + (if signature-insert-at-eof + (call-interactively 'signature/insert-signature-at-eof) + (call-interactively 'signature/insert-signature-at-point))) -- 1.7.10.4