Gnus development mailing list
 help / color / mirror / Atom feed
From: Matt Simmons <simmonmt@acm.org>
Subject: Random signatures
Date: 03 Sep 1997 13:18:11 -0500	[thread overview]
Message-ID: <yfqiuwi1ct8.fsf@acm.org> (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)

                 reply	other threads:[~1997-09-03 18:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yfqiuwi1ct8.fsf@acm.org \
    --to=simmonmt@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).