* Re: Reading from fortune style file
[not found] <873clrel5r.fsf@hotmail.com>
@ 2003-03-13 22:48 ` Joe Fineman
0 siblings, 0 replies; only message in thread
From: Joe Fineman @ 2003-03-13 22:48 UTC (permalink / raw)
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. :||
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-03-13 22:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <873clrel5r.fsf@hotmail.com>
2003-03-13 22:48 ` Reading from fortune style file Joe Fineman
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).