From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/11967 Path: main.gmane.org!not-for-mail From: Matt Simmons Newsgroups: gmane.emacs.gnus.general Subject: Random signatures Date: 03 Sep 1997 13:18:11 -0500 Message-ID: Reply-To: simmonmt@acm.org NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: multipart/mixed; boundary="Multipart_Wed_Sep__3_13:18:11_1997-1" Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1035151589 1137 80.91.224.250 (20 Oct 2002 22:06:29 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 22:06:29 +0000 (UTC) Return-Path: Original-Received: from xemacs.org (xemacs.cs.uiuc.edu [128.174.252.16]) by altair.xemacs.org (8.8.7/8.8.7) with ESMTP id MAA14075 for ; Wed, 3 Sep 1997 12:34:56 -0700 Original-Received: from ifi.uio.no (0@ifi.uio.no [129.240.64.2]) by xemacs.org (8.8.5/8.8.5) with SMTP id OAA17726 for ; Wed, 3 Sep 1997 14:30:48 -0500 (CDT) Original-Received: from claymore.vcinet.com (claymore.vcinet.com [208.205.12.23]) by ifi.uio.no with SMTP (8.6.11/ifi2.4) id for ; Wed, 3 Sep 1997 20:21:20 +0200 Original-Received: (qmail 5100 invoked by uid 504); 3 Sep 1997 18:21:19 -0000 Original-Received: (qmail 5097 invoked from network); 3 Sep 1997 18:21:17 -0000 Original-Received: from chi-il4-03.ix.netcom.com (HELO aurora.matt.cs.purdue.edu) (root@199.35.203.131) by claymore.vcinet.com with SMTP; 3 Sep 1997 18:21:16 -0000 Original-Received: (from simmonmt@localhost) by aurora.matt.cs.purdue.edu (8.8.7/8.8.7) id NAA01225; Wed, 3 Sep 1997 13:18:12 -0500 (CDT) Original-To: ding@gnus.org Original-Lines: 94 X-Mailer: Gnus v5.4.65/XEmacs 20.2 Xref: main.gmane.org gmane.emacs.gnus.general:11967 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:11967 --Multipart_Wed_Sep__3_13:18:11_1997-1 Content-Type: text/plain; charset=US-ASCII I didn't see anything about being able to do random signatures in the gnus manual, so I wrote something to do it. It's rather short, so I'll append it below. This is my first crack at elisp coding - any comments, critiques, "you shouldn't use this function - use this one instead"s, etc would be appeciated. Thanks Matt -- Matt Simmons - simmonmt@acm.org - http://www.netcom.com/~simmonmt One of the greatest labour-saving inventions of today is tomorrow. --Vincent T. Foss --Multipart_Wed_Sep__3_13:18:11_1997-1 Content-Type: application/octet-stream; type=emacs-lisp Content-Disposition: attachment; filename="random-sig.el" Content-Transfer-Encoding: 7bit ;; random-sig.el - A random signature inserter for message-mode ;; ;; The function in this file will, given valid values in ;; `random-signature-head' and `random-signature-dir', build a random ;; signature for you. `random-signature-head' is intended to be a static ;; file - you should put things that won't change between sigs in it ;; (your email address, URL, etc). `random-signature-dir' is the name of ;; a directory that contains signature fragments to be appended to the ;; text contained in `random-signature-head'. One of these fragments will ;; be picked at random. ;; ;; NOTE: `random-signature-head' CAN be placed in `random-signature-dir'. ;; The function checks to make sure that the fragment that it has ;; picked for appending is not `random-signature-head'. ;; ;; Please report bugs, make suggestions, etc to: ;; Matt Simmons ;; http://www.netcom.com/~simmonmt ;; ;; $Id: random-sig.el,v 1.1 1997/09/03 17:57:32 simmonmt Exp $ ;; ;; $Log: random-sig.el,v $ ;; Revision 1.1 1997/09/03 17:57:32 simmonmt ;; Initial revision ;; ;; (defvar random-signature-head (expand-file-name "~/.sigs/sighead") "*The file used as a sig header in `random-signature-fun'. Set to nil if the header is not to be used") (defvar random-signature-dir (expand-file-name "~/.sigs") "*The directory from which the random signature files are extracted") (defun random-signature-fun () "Insert a random signature. The signature is built as follows: `random-signature-head' is included, followed by a random file from `random-signature-dir'. Note: A check is made to ensure that the random file picked from `random-signature-dir' is not `random-signature-head', so you can safely put `random-signature-head' in `random-signature-dir'." (interactive) ;; Set up message buffer for signature insertion (goto-char (point-max)) (unless (bolp) (insert "\n")) (insert "\n-- \n") ;; Get the header (if necessary) (if random-signature-head (if (file-readable-p random-signature-head) (insert-file-contents random-signature-head) (insert-string (concat "*** Unable to insert header file '" random-signature-head "' ***\n")))) ;; Get the random body (goto-char (point-max)) (if (file-directory-p random-signature-dir) (let ((sig-files (directory-files random-signature-dir t nil nil t)) (sig-num nil)) (while (not sig-num) (setq sig-num (random (length sig-files))) (if (string-equal (nth sig-num sig-files) random-signature-head) (setq sig-num nil))) (insert-file-contents (nth sig-num sig-files))) (insert-string (concat "*** Unable to find body directory '" random-signature-dir "' ***\n")))) (provide 'random-sig) --Multipart_Wed_Sep__3_13:18:11_1997-1--