Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* TINY signature randomizer
@ 2006-04-20 15:54 Giacomo Boffi
  2006-05-05 10:24 ` Giacomo Boffi
  0 siblings, 1 reply; 2+ messages in thread
From: Giacomo Boffi @ 2006-04-20 15:54 UTC (permalink / raw)


;; At present, it works with a "~/.signature" file, where (possibly
;; multiline) stuff is separated by a line containing ONLY a "%"
;;
;; Change the filename in expand-file-name and the separator in
;; split-string below as you feel appropriate, and drop in your
;; "~/.gnus"
;;
(defun sig_rand ()
  (with-temp-buffer
    (insert-file-contents-literally (expand-file-name "~/.signature"))
    (let ((lista (split-string (buffer-string (current-buffer)) "\n%\n")))
      (elt lista (random (length lista))))))
(setq message-signature 'sig_rand)
-- 
sapete contare fino a venticinque?
Olimpia Milano Jugoplastika Split Partizan Beograd
Roberto Premier Duska Ivanovic Zarko Paspalj

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: TINY signature randomizer
  2006-04-20 15:54 TINY signature randomizer Giacomo Boffi
@ 2006-05-05 10:24 ` Giacomo Boffi
  0 siblings, 0 replies; 2+ messages in thread
From: Giacomo Boffi @ 2006-05-05 10:24 UTC (permalink / raw)


Giacomo Boffi <giacomo.boffi@polimi.it> writes:

> ;; At present, it works with a "~/.signature" file, where (possibly
> ;; multiline) stuff is separated by a line containing ONLY a "%"
> ;;
> ;; Change the filename in expand-file-name and the separator in
> ;; split-string below as you feel appropriate, and drop in your
> ;; "~/.gnus"
> ;;
> (defun sig_rand ()
>   (with-temp-buffer
>     (insert-file-contents-literally (expand-file-name "~/.signature"))
>     (let ((lista (split-string (buffer-string (current-buffer)) "\n%\n")))
      (let ((lista (split-string (buffer-string                 ) "\n%\n")))
>       (elt lista (random (length lista))))))
> (setq message-signature 'sig_rand)

sorry, the original version is good for XEmacs, but does not run in
Emacs, where

,----
| buffer-string is a built-in function in `C source code'.
| (buffer-string)
| 
| Return the contents of the current buffer as a string.
| If narrowing is in effect, this function returns only the visible part
| of the buffer.
`----

the corrected version works in XEmacs too, as the BUFFER argument is
optional

-- 
Sarebbe essere un atto di pieta'. 
Contro i miei principi.                            -- whip,  in IFMdI

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-05-05 10:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-20 15:54 TINY signature randomizer Giacomo Boffi
2006-05-05 10:24 ` Giacomo Boffi

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).