* Customize Gnus: signature rotation
@ 2010-08-11 9:02 Stinky Wizzleteet
[not found] ` <87fwyll90j.fsf@topper.koldfront.dk>
0 siblings, 1 reply; 2+ messages in thread
From: Stinky Wizzleteet @ 2010-08-11 9:02 UTC (permalink / raw)
To: info-gnus-english
Hi,
I'm tweaking my signature to be generated by a custom fortune and it's
working swimmingly.
I noticed Adam Sjøgren put his in a table, that's looking really neat !
Dear adam, could you please enlighten me (us ?) on how you did that ?
I took a script from Bill Clementson's blog (see below) to read my own
fortune file, so it's more or less emacsen independant and I can add my
own little gems. For now I just copied /usr/share/games/fortunes/fortunes to ~/.emacs.d/misc/fortune.txt
(.emacs.d is svn controlled, to keep everythig in sync)
This is what I did:
in .gnus:
;;;;;;;;;;;;;;;;;;;;;;;; start
(setq
gnus-posting-styles
'(
((message-news-p)
(name "Stinky Wizzleteet")
(address "wizzleteet@hotmail.com")
(signature (concat "Stinky Wizzleteet thinks: \n"(myfortune)))
)))
;;;;;;;;;;;;;;;;;;;;;;;; stop
I tweaked the script from Bill Clementson blog
http://bc.tech.coop/blog/071226.html
to not conflict with emacs' fortune
in .emacs (or, in my case in ~/.emacs.d/site-start.d/92-Fortune.el, this
is different trick):
;;;;;;;;;;;;;;;;;;;;;;;; start
(defvar myfortune-file "~/.emacs.d/misc/fortune.txt"
"The file that fortunes come from.")
(defvar myfortune-strings nil
"The fortunes in the fortune file.")
(defun open-myfortune-file (file)
(find-file file)
(if (null myfortune-strings)
(let ((strings nil)
(prev 1))
(goto-char (point-min))
(while (re-search-forward "^%$" (point-max) t)
(push (buffer-substring-no-properties prev (- (point) 1))
strings)
(setq prev (1+ (point))))
(push (buffer-substring-no-properties prev (point-max)) strings)
(setq myfortune-strings (apply 'vector strings)))))
(defun myfortune ()
"Get a fortune to display."
(interactive)
(when (null myfortune-strings)
(open-myfortune-file myfortune-file)
(kill-buffer (current-buffer)))
(let* ((n (random (length myfortune-strings)))
(string (aref myfortune-strings n)))
(if (interactive-p)
(message (format "%s" string))
string)))
;; Override standard startup message
(defun startup-echo-area-message ()
(myfortune))
;;;;;;;;;;;;;;;;;;;;;;;; stop
This is what it gives:
--
Stinky Wizzleteet thinks:
You will stop at nothing to reach your objective, but only because your
brakes are defective.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-08-11 18:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-11 9:02 Customize Gnus: signature rotation Stinky Wizzleteet
[not found] ` <87fwyll90j.fsf@topper.koldfront.dk>
[not found] ` <877hjxtkh4.fsf@mauc.nl>
[not found] ` <7jbp99jqgd.fsf@rapun.sel.cam.ac.uk>
2010-08-11 18:32 ` Stinky Wizzleteet
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).