From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.devel Subject: Sending e-mail via system's mail client from sendmail.el Date: Sun, 10 Jul 2005 12:34:06 +0100 Message-ID: <4A08801D-0AD9-4874-A008-A066E8E5EDDF@gmail.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v730) Content-Type: multipart/mixed; boundary=Apple-Mail-49-954125484 X-Trace: sea.gmane.org 1120996792 5343 80.91.229.2 (10 Jul 2005 11:59:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 10 Jul 2005 11:59:52 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 10 13:59:44 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DraTD-0007uE-HO for ged-emacs-devel@m.gmane.org; Sun, 10 Jul 2005 13:59:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DraUj-0001ob-Gd for ged-emacs-devel@m.gmane.org; Sun, 10 Jul 2005 08:01:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DraS2-0000sU-IV for emacs-devel@gnu.org; Sun, 10 Jul 2005 07:58:26 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DraRx-0000qx-QY for emacs-devel@gnu.org; Sun, 10 Jul 2005 07:58:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DraRx-0000jY-Cw for emacs-devel@gnu.org; Sun, 10 Jul 2005 07:58:21 -0400 Original-Received: from [64.233.184.192] (helo=wproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DraBg-0006mz-4S for emacs-devel@gnu.org; Sun, 10 Jul 2005 07:41:32 -0400 Original-Received: by wproxy.gmail.com with SMTP id 49so1140987wri for ; Sun, 10 Jul 2005 04:34:09 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:to:message-id:content-type:from:subject:date:x-mailer; b=MhOQZgKpOwcHRcvsFm9wfcfcPMN6F+AxV28jsGtFujrAYvkxtMsd88eHsGVDr6GBWBGkVDAHSEPuNmbOTIMYP2sPQZTX000Kdgk8yRtpkgfqPfqvF5Hv4J9JovqvLMAf6E/qy1n++SN78Z7QO4YVhGQLeemToqPKHcT+MzYOVeo= Original-Received: by 10.54.17.66 with SMTP id 66mr4310719wrq; Sun, 10 Jul 2005 04:34:09 -0700 (PDT) Original-Received: from ?129.215.174.81? ([129.215.174.81]) by mx.gmail.com with ESMTP id 67sm7539915wra.2005.07.10.04.34.09; Sun, 10 Jul 2005 04:34:09 -0700 (PDT) Original-To: emacs-devel ' , Richard Stallman X-Mailer: Apple Mail (2.730) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:40723 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:40723 --Apple-Mail-49-954125484 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed The enclosed package allows to hand over a mail buffer from sendmail.el to the system's designated e-mail client. Note that the e-mail client will display the contents of the buffer again for editing. The e-mail client is taken to be whoever handles a mailto: URL via `browse-url'. To activate: (setq send-mail-function 'mailclient-send-it) If this is acceptable, I can rework my earlier patch for emacsbug.el so that it goes through sendmail, but doesn't display the mail for editing before handing it over to the mail client, if send-mail- function is mailclient-send-it. I've tested this on the Mac and on a KDE installation with Mozilla. It addresses long-standing problems on the Mac, but should be equally useful on all systems where users use some mail application instead of emacs. I conjecture it will make sendmail mail easier (or even functional) on WIndows as well. diff -c -r1.285 sendmail.el *** sendmail.el 23 Jun 2005 21:22:43 -0000 1.285 --- sendmail.el 10 Jul 2005 11:28:45 -0000 *************** *** 1,6 **** ;;; sendmail.el --- mail sending commands for Emacs. -*- byte- compile-dynamic: t -*- ! ;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 98, 2000, 2001, 2002, 03, 2004 ;; Free Software Foundation, Inc. ;; Maintainer: FSF --- 1,6 ---- ;;; sendmail.el --- mail sending commands for Emacs. -*- byte- compile-dynamic: t -*- ! ;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 98, 2000, 2001, 2002, 2003, 2004, 2005 ;; Free Software Foundation, Inc. ;; Maintainer: FSF *************** *** 120,126 **** ;; Useful to set in site-init.el ;;;###autoload ! (defcustom send-mail-function 'sendmail-send-it "Function to call to send the current buffer as mail. The headers should be delimited by a line which is not a valid RFC822 header or continuation line, --- 120,129 ---- ;; Useful to set in site-init.el ;;;###autoload ! (defcustom send-mail-function ! (if (eq system-type 'darwin) ! 'mailclient-send-it ! 'sendmail-send-it) "Function to call to send the current buffer as mail. The headers should be delimited by a line which is not a valid RFC822 header or continuation line, *************** *** 130,135 **** --- 133,139 ---- :type '(radio (function-item sendmail-send-it :tag "Use Sendmail package") (function-item smtpmail-send-it :tag "Use SMTPmail package") (function-item feedmail-send-it :tag "Use Feedmail package") + (function-item mailclient-send-it :tag "Use Mailclient package") function) :group 'sendmail) --Apple-Mail-49-954125484 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; x-mac-creator=454D4178; name="mailclient.el" Content-Disposition: attachment; filename=mailclient.el ;;; mailclient.el --- mail sending via system's mail client. -*- byte-compile-dynamic: t -*- ;; Copyright (C) 2005 ;; David Reitter ;; Maintainer: FSF ;; Keywords: mail ;; This file is not yet part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; This package allows to hand over a buffer to be sent off ;; via the system's designated e-mail client. ;; Note that the e-mail client will display the contents of the buffer ;; again for editing. ;; The e-mail client is taken to be whoever handles a mailto: URL ;; via `browse-url'. ;; To activate: ;; (setq send-mail-function 'mailclient-send-it) ; if you use `mail' ;;; Code: ;; Copied from w3m-url-encode-string (w3m.el) (defun url-encode-string (string &optional coding) "Encode STRING by url-encoding. Optional CODING is used for encoding coding-system." (apply (function concat) (mapcar (lambda (ch) (cond ((eq ch ?\n) ; newline "%0D%0A") ((string-match "[-a-zA-Z0-9_:/.]" (char-to-string ch)) (char-to-string ch)) ; printable ((char-equal ch ?\x20) ; space "%20") (t (format "%%%02x" ch)))) ; escape ;; Coerce a string to a list of chars. (append (encode-coding-string (or string "") (or coding file-name-coding-system)) nil)))) (defvar mailclient-delim-static "?") (defmacro mailclient-url-delim () (let ((current mailclient-delim-static)) (setq mailclient-delim-static "&") current)) (defmacro mailclient-gather-addresses (str &optional drop-first-name) (let ((cc "") end) (goto-char (point-min)) ;; find all cc's (while (re-search-forward (format "^%s:[ ]*" (upcase-initials str)) delimline t) (let ((beg (point))) (re-search-forward "\n" delimline t) (setq end (point)) (goto-char beg)) (while (re-search-forward "[ ]*\\([^ ,\n]+\\)" end t) (setq cc (concat cc (if (and drop-first-name (= (length cc) 0)) "" (concat (mailclient-url-delim) str "=")) (url-encode-string (match-string 1)))))) cc)) (defun mailclient-send-it () "Pass current buffer on to the system's mail client. Suitable value for `send-mail-function'. The mail client is taken to be the handler of mailto URLs. " (let ((case-fold-search nil) delimline (mailbuf (current-buffer)) (tembuf (generate-new-buffer " mailclient temp"))) (unwind-protect (save-excursion (set-buffer tembuf) (erase-buffer) (insert-buffer-substring mailbuf) ;; Move to header delimiter (mail-sendmail-undelimit-header) (setq delimline (point-marker)) (if mail-aliases (expand-mail-aliases (point-min) delimline)) (goto-char (point-min)) ;; ignore any blank lines in the header (while (and (re-search-forward "\n\n\n*" delimline t) (< (point) delimline)) (replace-match "\n")) (let ((case-fold-search t)) ;; initialize limiter (setq mailclient-delim-static "?") ;; construct and call up mailto URL (browse-url (concat "mailto:" (mailclient-gather-addresses "to" 'drop-first-name) (mailclient-gather-addresses "cc") (mailclient-gather-addresses "bcc") (mailclient-gather-addresses "reply-to") ;; subject line (if (and (goto-char (point-min)) (re-search-forward "^Subject:\\([^\n]*[^ ]\\)\n" delimline t)) (concat (mailclient-url-delim) "subject=" (url-encode-string (match-string 1))) "") ;; body (concat (mailclient-url-delim) "body=" (url-encode-string (buffer-substring delimline (point-max)))))))) (kill-buffer tembuf)))) (provide 'mailclient) --Apple-Mail-49-954125484 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --Apple-Mail-49-954125484--