Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Joe Fineman <jcf@TheWorld.com>
Subject: Re: Reading from fortune style file
Date: 13 Mar 2003 17:48:08 -0500	[thread overview]
Message-ID: <wk65qmzxw7.fsf@TheWorld.com> (raw)
In-Reply-To: <873clrel5r.fsf@hotmail.com>

Chris L <chrisl_ak@hotmail.com> writes:

> Does anyone have a bit of lisp that will read from a fortune style
> file and return a random result? I would like something to hook into
> posting styles to create a custom signature by reading a random
> entry...

This isn't quite what you've asked for -- it takes the entries in the
file in order rather than randomly.  However, FWIW, mutatis mutandis,

(defun psig ()
  "Insert the signature for a personal posting, including a saying."
  (interactive)
  (goto-char (point-max))
  (or (= (char-after (- (point) 1)) ?\n)
      (newline 1))
  (insert "-- \n---  Joe Fineman    jcf@TheWorld.com\n")
  (let ((saying ""))
    (save-window-excursion
      (find-file "~/p/networks/world/gnus/Sayings")
      (goto-char (point-min))
      (search-forward "#")
      (delete-char -1)
      (setq fill-prefix nil)
      (mark-paragraph)
      (setq saying (buffer-substring (region-beginning) (region-end)))
      (exchange-point-and-mark)
      (if (eobp) (goto-char (1+ (point-min))))
      (insert "#")
      (save-buffer))
    (insert saying)
    ))

The Sayings file should have one saying per paragraph, and its first
line should be blank (except, at first, for a "#").
-- 
---  Joe Fineman    jcf@TheWorld.com

||:  Quantity for the young, quality for the middle-aged,  :||
||:  reliability for the old.                              :||


           reply	other threads:[~2003-03-13 22:48 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <873clrel5r.fsf@hotmail.com>]

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=wk65qmzxw7.fsf@TheWorld.com \
    --to=jcf@theworld.com \
    /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).