help-emacs-windows
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[h-e-w] mail-send-hook


From: Robert Mecklenburg
Subject: [h-e-w] mail-send-hook
Date: Mon, 19 Nov 2001 13:10:13 -0700

I have a function which copies some stuff from a *cvs* buffer into a
mail message buffer.  The template it inserts contains ellipsis which
should be edited by the user, so I install a hook to ensure the
ellipsis are removed before sending the mail.  This seemed to work
fine in emacs 20.7, but in emacs 21.1 mail-send-hook is not being set
as expected.  Any suggestions?

Here is the code (See the line marked <<<<<<<<):

(defun scan-for-ellipsis ()
  (interactive)
  (goto-char (point-min))
  (if (search-forward "..." nil t)
      (error "Please fill in ellipsis before sending this mail.")))

(defun append-to-checkin-message ()
  (interactive)
  (save-excursion
    (save-current-buffer
      (let (start (full-contents (buffer-substring-no-properties (point-min) 
(point-max))))

        (pop-to-buffer "checkin-msg")
        (make-local-hook 'mail-send-hook)
        (add-hook 'mail-send-hook 'scan-for-ellipsis nil t) ; <<<<<<< 

        (if (equal 0 (buffer-size))
            (progn
              (insert "To: address@hidden"
                      "Subject: Checkin: ...\n")
              (if (and (boundp 'mail-archive-file-name)          ; If bound
                       mail-archive-file-name                    ;  and not nil
                       (file-readable-p mail-archive-file-name)) ;  and readable
                  (insert "FCC: " mail-archive-file-name "\n"))
              (insert "--text follows this line--\n"
                      "Description:\n  ...\n\nBranch: trunk\n\nBugs: 
...\n\nFiles:\n")
              (if (file-readable-p "~/.signature")
                  (progn 
                    (insert "--\n")
                    (insert-file-contents "~/.signature")))
              (mail-mode)))
        (goto-char (point-min))
        (re-search-forward "^--$" (point-max) 'limit)
        (beginning-of-line)
        (setq start (point))
        (insert full-contents)
        (save-restriction
          (narrow-to-region start (point))
          (goto-char (point-min))
          (keep-lines "^\\(added\\|removed\\|committed\\)")
          (goto-char (point-max)))
        (insert "\n")
        (let ((message-buffer (first (cdr (assoc "message" 
cvs-buffer-name-alist)))))
          (insert-buffer-substring message-buffer))
        (insert "\n\n\n")
  ))))



Thanks,
-- 
Robert




reply via email to

[Prev in Thread] Current Thread [Next in Thread]