From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/2199 Path: news.gmane.org!not-for-mail From: Joe Fineman Newsgroups: gmane.emacs.gnus.user Subject: Re: Reading from fortune style file Date: 13 Mar 2003 17:48:08 -0500 Organization: The World : www.TheWorld.com : Since 1989 Message-ID: References: <873clrel5r.fsf@hotmail.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1138668717 14283 80.91.229.2 (31 Jan 2006 00:51:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 31 Jan 2006 00:51:57 +0000 (UTC) Original-X-From: nobody Tue Jan 17 17:30:20 2006 Original-Path: quimby.gnus.org!newsfeed1.e.nsc.no!nsc.no!nextra.com!bnewspeer00.bru.ops.eu.uu.net.MISMATCH!bnewspeer01.bru.ops.eu.uu.net!emea.uu.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!uunet!dca.uu.net!nntp.TheWorld.com!not-for-mail Original-Newsgroups: gnu.emacs.gnus Original-Sender: Default@OEMCOMPUTER Original-NNTP-Posting-Host: ppp0c022.std.com Original-X-Trace: pcls3.std.com 1047595655 21902 208.192.102.22 (13 Mar 2003 22:47:35 GMT) Original-X-Complaints-To: abuse@TheWorld.com Original-NNTP-Posting-Date: Thu, 13 Mar 2003 22:47:35 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Original-Xref: bridgekeeper.physik.uni-ulm.de gnus-emacs-gnus:2339 Original-Lines: 40 X-Gnus-Article-Number: 2339 Tue Jan 17 17:30:20 2006 Xref: news.gmane.org gmane.emacs.gnus.user:2199 Archived-At: Chris L 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. :||