* Random signatures
@ 1997-09-03 18:18 Matt Simmons
0 siblings, 0 replies; only message in thread
From: Matt Simmons @ 1997-09-03 18:18 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
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
[-- Attachment #2: random-sig.el --]
[-- Type: application/octet-stream, Size: 2774 bytes --]
;; 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 <simmonmt@acm.org>
;; 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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1997-09-03 18:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-09-03 18:18 Random signatures Matt Simmons
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).