Subject: Re: send-pr.el and smtpmail.el
To: None <netbsd-help@netbsd.org>
From: Aleksey Cheusov <cheusov@tut.by>
List: netbsd-help
Date: 04/09/2006 22:36:41
> I'm about sending PRs from Emacs i'm using every day.
> Has anybody a patch that causes send-pr function declared in send-pr.el
> to use functions from smtpmail.el?
Ok. I hope the following patch will be useful for someone.
I initialize send-pr.el like this
~/.emacs:
(let* ((path "/usr/share/gnats"); NetBSD path for send-pr.el
(file (concat path "/send-pr.el")))
(if (file-exists-p file)
(let ((load-path (cons path load-path)))
(require 'send-pr)
(setq gnats::use-mail-send-and-exit t)
(setq gnats::mail-send-and-exit-arg nil))))
%%%%%%%%%%%%%%%%%%%%%%%%%%% patch %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Index: gnu/usr.bin/send-pr/send-pr-el.in
===================================================================
RCS file: /cvsroot/src/gnu/usr.bin/send-pr/send-pr-el.in,v
retrieving revision 1.5
diff -u -r1.5 send-pr-el.in
--- gnu/usr.bin/send-pr/send-pr-el.in 7 Sep 1995 00:21:14 -0000 1.5
+++ gnu/usr.bin/send-pr/send-pr-el.in 9 Apr 2006 19:25:24 -0000
@@ -41,10 +41,11 @@
;;;;---------------------------------------------------------------------------
(provide 'send-pr)
+(require 'smtpmail)
;;;;---------------------------------------------------------------------------
;;;; Customization: put the following forms into your default.el file
-;;;; (or into your .emacs)
+;;;; (or into your .emacs) and/or initialize the described below variables
;;;;---------------------------------------------------------------------------
;(autoload 'send-pr-mode "send-pr"
@@ -53,6 +54,15 @@
;(autoload 'send-pr "send-pr"
; "Command to create and send a problem report." t)
+; defcustom should be used here
+(defvar gnats::use-mail-send-and-exit nil
+ "If t, send the problem report using mail-send-and-exit function
+from smtpmail.el but the send-pr command line executable.")
+
+; defcustom should be used here
+(defvar gnats::mail-send-and-exit-arg nil
+ "argument passed to mail-send-and-exit function")
+
;;;;---------------------------------------------------------------------------
;;;; End of Customization Section
;;;;---------------------------------------------------------------------------
@@ -308,11 +318,11 @@
send-pr::template-alist))))))
(fset 'do-send-pr 'send-pr:submit-pr) ;backward compat
-(defun send-pr:submit-pr ()
+
+(defun send-pr:submit-pr-using-send-pr-executable ()
"Pipe the contents of the buffer *send-pr* to `send-pr -f -.' unless this
buffer was loaded with emacsclient, in which case save the buffer and exit."
;;
- (interactive)
(cond
((and (boundp 'server-buffer-clients)
server-buffer-clients)
@@ -353,7 +363,21 @@
(t
(save-buffer)
(message "Exit emacs to send the PR."))))
-
+
+(defun send-pr:submit-pr ()
+ "Either send e-mail using mail-send-and-exit function from smtpmail.el
+or pipe the contents of the buffer *send-pr* to `send-pr -f -.' unless this
+buffer was loaded with emacsclient, in which case save the buffer and exit."
+ ;;
+ (interactive)
+ (if gnats::use-mail-send-and-exit
+ (progn
+ (gnats::prepare-to-send)
+ (mail-send-and-exit gnats::mail-send-and-exit-arg)
+ )
+ (send-pr:submit-pr-using-send-pr-executable)
+ ))
+
;;;;---------------------------------------------------------------------------
;;;; send-pr:send-pr-mode mode
;;;;---------------------------------------------------------------------------
@@ -488,6 +512,29 @@
((gnats::functionp thing) thing)
(t (error "ACK")))))
+(defun gnats::remove-SEND-PR-lines ()
+ (interactive)
+ "Removes SEND-PR lines in the current buffer."
+ (goto-char (point-min))
+ (while (search-forward-regexp "^SEND-PR" nil t)
+ (beginning-of-line)
+ (kill-line t)))
+
+(defun gnats::remove-pattern-lines ()
+ (interactive)
+ "Removes <pattern> lines in the current buffer."
+ (goto-char (point-min))
+ (while (search-forward-regexp "^\t<.*>$" nil t)
+ (beginning-of-line)
+ (kill-line t)))
+
+(defun gnats::prepare-to-send ()
+ "Remove unnecessary lines before sending e-mail."
+ (save-excursion
+ (gnats::remove-SEND-PR-lines)
+ (gnats::remove-pattern-lines)
+ ))
+
;;;;---------------------------------------------------------------------------
;;;; Point movement functions
;;;;---------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%% end of patch %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--
Best regards, Aleksey Cheusov.