[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Customize Gnus: signature rotation
From: |
Stinky Wizzleteet |
Subject: |
Customize Gnus: signature rotation |
Date: |
Wed, 08 Dec 2010 15:44:41 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
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.
- Customize Gnus: signature rotation,
Stinky Wizzleteet <=