[comp.emacs] a mail header hook with zippy

rodney@sun.ipl.rpi.edu (Rodney Peck II) (07/07/89)

ok, I was bored and I haven't written much elisp to interact with emacs so
I decided to do this.

It's pretty simple, but cute and moderately annoying.

Throw this in .emacs or a file and load it with .emacs and it will put a
zippism in each outgoing piece of mail you send (with emacs).  
If you don't want it there, you can always just delete it from the list
of headers.

The header looks like this:
X-Zippy:  Yow!  Are you the self-frying president?


so, here it is:  questions, et. al. to me: rodney@ipl.rpi.edu

;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
;; zippy-mail.el
;; Author          : Rodney Peck II (rodney@ipl.rpi.edu)
;; Created On      : Fri Jul  7 10:09:03 1989
;; Last Modified By: Rodney Peck II
;; Last Modified On: Fri Jul  7 10:11:59 1989
;; Update Count    : 4
;; Status          : works.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun add-zippyism ()
  (save-excursion
X-Zippy:  ..  My pants just went on a wild rampage through
 a Long Island Bowling Alley!!
    (search-forward "--tex")
    (beginning-of-line)
    (insert "X-Zippy:  ")
    (insert (yow))
    (insert "\n")))

(or (memq 'add-zippyism mail-setup-hook)
    (setq mail-setup-hook (cons 'add-zippyism mail-setup-hook)))

;;(setq mail-setup-hook nil)
--
Rodney

rodney@sun.ipl.rpi.edu (Rodney Peck II) (07/07/89)

oops.  figures.  a really simple posting a it gets screwed up.

it seems that my add-zippism couldn't find the --tex in the header when i
demonstrated it but it did find it down in the function body!

Well, here's the new version:

note the addition of the begining of buffer and check for unbound hook.

this actually works.


;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
;; zippy-mail.el
;; Author          : Rodney Peck II (rodney@ipl.rpi.edu)
;; Created On      : Fri Jul  7 10:09:03 1989
;; Last Modified By: Rodney Peck II
;; Last Modified On: Fri Jul  7 11:22:05 1989
;; Update Count    : 6
;; Status          : works.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun add-zippyism ()
  (save-excursion
    (goto-char (point-min))  ;; begining of buffer
    (search-forward "--tex")
    (beginning-of-line)
    (insert "X-Zippy:  ")
    (insert (yow))
    (insert "\n")))

(or (and (not (boundp 'mail-setup-hook))
	 (setq mail-setup-hook '(add-zippyism)))
    (memq 'add-zippyism mail-setup-hook)
    (setq mail-setup-hook (cons 'add-zippyism mail-setup-hook)))

;;(setq mail-setup-hook nil)

--
Rodney

nate@hobbes.intel.com (Nate Hess) (07/08/89)

In article <RODNEY.89Jul7120332@sun.ipl.rpi.edu>, rodney@sun (Rodney Peck II) writes:
>(defun add-zippyism ()
>  (save-excursion
>    (goto-char (point-min))  ;; begining of buffer
>    (search-forward "--tex")

I would suggest that you use

	(search-forward mail-header-separator)

instead of hard-coding the default one in your function.

--woodstock
-- 
	   "What I like is when you're looking and thinking and looking
	   and thinking...and suddenly you wake up."   - Hobbes

woodstock@hobbes.intel.com   ...!{decwrl|hplabs!oliveb}!intelca!mipos3!nate 

rodney@taac.ipl.rpi.edu (Rodney Peck II) (07/08/89)

ok.  latest version with help from several people who will be
enumerated when I'm less tired.

Again, send comments to me.  I'm learning neat stuff.

;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
;; zippy-mail.el
;; Author          : Rodney Peck II (rodney@ipl.rpi.edu)
;; Created On      : Fri Jul  7 10:09:03 1989
;; Last Modified By: Rodney Peck II
;; Last Modified On: Fri Jul  7 13:12:50 1989
;; Update Count    : 10
;; Status          : works.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun add-zippyism ()
  "Add an X-Zippy: header line with a quote from the Pinhead."
  (interactive)
   (save-excursion
      (if (mail-position-on-field "X-Zippy")
	  (delete-region (point) (progn (search-backward ":")
					(forward-char 2)
					(point))))
      (insert (yow))))
;; sort of try to install zippyism.
(if (boundp 'mail-setup-hook)
    (message "mail-setup-hook already bound, not changed.")
    (setq mail-setup-hook 'add-zippism))

;;(setq mail-setup-hook nil)
--
Rodney