X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fbb9d,724ff72050b2fe36,start X-Google-Attributes: gidfbb9d,public From: Kimmo.Ketolainen@utu.fi (Kimmo Ketolainen +358 40 500 2957) Subject: SOFTWARE: signature randomizer for Emacs Date: 1995/04/16 Message-ID: <3msgm9$cut@gagme.wwa.com>#1/1 X-Deja-AN: 100999581 approved: boba@wwa.com sender: boba@gagme.wwa.com organization: University of Turku newsgroups: rec.arts.ascii ;; Random signature selector ;; - selects signatures from one of two directories, overwrites ~/.sign= ature (defun selsig (which-sig) (setq real-buffer (current-buffer)) (setq sig-buffer (find-file-noselect which-sig)) (set-buffer sig-buffer) (write-file "~/.signature") (set-buffer real-buffer) (kill-buffer sig-buffer)) (defun randsig () "Choose random signature to be used" (interactive) ; Directory is chosen by the distribution field ;; (if (is-regexp-in-buf "^Distribution:.*world" "*post-news*") (if (call-buffer-searches-with-list sig-hillitty-regexps "*post-news*= ") (setq sig-directory sig-hillitty-directory) (setq sig-directory sig-estoton-directory)) (if (file-directory-p sig-directory) () (error (concat sig-directory " is not a directory"))) ; All files that do not begin with a letter or number are eligible (setq sig-files (directory-files sig-directory t "^[a-zA-Z0-9]")) (setq sig-random (random)) (if (< sig-random 0) (setq sig-random (- sig-random))) (setq sig-new (nth (% sig-random (length sig-files)) sig-files)) ; It's nice to know which signature will be used (message "Current signature is %s" sig-new) (selsig sig-new)) ;; Repeat regexp search in buffer for list ;; Return t if regexp found in buffer (defun call-buffer-searches-with-list (list buffer) (if (is-regexp-in-buf (car list) buffer) t (if (not (cdr list)) nil (call-buffer-searches-with-list (cdr list) buffer)))) ;; Do a regexp search for regexp in buffer buf ;; Return t if a match is found, else return nil (defun is-regexp-in-buf (regexp buf) (interactive) (save-excursion (set-buffer buf) (goto-char (point-min)) (if (re-search-forward regexp (point-max) t) t nil))) ;; Variables for signature selection (setq sig-estoton-directory "~/.signatures1") (setq sig-hillitty-directory "~/.signatures2") (setq sig-hillitty-regexps '("^Distribution:.*koete")) ;; Select the new signature _before_ the article is sent (setq news-inews-hook 'randsig) ;; EOF -- `,`,`, |=AF=AF=AF| `,`,`, =B7 +358 40 500 295= 7 `,`,`,`,`,`,`, `,`,`, |___| `,`,`, Studentbyn 84 A 10 =B7 FIN-20540 =C5bo =B7 Finland = `,`,`,`,`,`,`,