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 "[email protected]")
    (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.
_______________________________________________
info-gnus-english mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/info-gnus-english

Reply via email to