From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Richard M. Stallman" Newsgroups: gmane.emacs.devel Subject: [david.reitter@gmail.com: mailclient.el - revised] Date: Sat, 23 Jul 2005 20:01:23 -0400 Message-ID: Reply-To: rms@gnu.org NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1122163633 25436 80.91.229.2 (24 Jul 2005 00:07:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 24 Jul 2005 00:07:13 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 24 02:07:08 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DwU13-0000VB-36 for ged-emacs-devel@m.gmane.org; Sun, 24 Jul 2005 02:06:49 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DwU3G-0003Ow-8O for ged-emacs-devel@m.gmane.org; Sat, 23 Jul 2005 20:09:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DwU2O-0002to-76 for emacs-devel@gnu.org; Sat, 23 Jul 2005 20:08:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DwU2N-0002sk-Jl for emacs-devel@gnu.org; Sat, 23 Jul 2005 20:08:11 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DwTyH-00014E-1y for emacs-devel@gnu.org; Sat, 23 Jul 2005 20:03:57 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DwU6E-0005y4-49 for emacs-devel@gnu.org; Sat, 23 Jul 2005 20:12:10 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1DwTvn-0000Ym-G1; Sat, 23 Jul 2005 20:01:23 -0400 Original-To: emacs-devel@gnu.org 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:41175 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41175 Could people please take a look at this, and comment to me and David? ------- Start of forwarded message ------- 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=hbHyaITmyvQOezM5ZQKLOkFKJjo/G20TJwCfIJZGbboSMF+W/VnlpJIfAS4oCrd8p82kzcs0UTQCM8Ygjg03tBEDuBj/YdN4Sb1Byrs8MtXG1owj6aT6t+KsVXaYxpyQxPm4zinNu/wJUponqBFLojv5PwZq+I3HgfZn87hHDAE= To: Richard Stallman From: David Reitter Subject: mailclient.el - revised Date: Wed, 20 Jul 2005 11:20:19 +0100 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on monty-python X-Spam-Level: X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.63 - --Apple-Mail-19--333784832 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hi, I'm attaching a revised version of the proposed lisp/mail/mailclient.el. The old one had problems when compiling and didn't include an autoload comment. I also rewrote mailclient-encode-string-as-url, because the function it replaces was taken from w3m. Papers have been signed and should already be at your office. - --Apple-Mail-19--333784832 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 Free Software Foundation ;; Maintainer: David Reitter ;; Keywords: mail ;; This file is 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: (require 'sendmail) ;; for mail-sendmail-undelimit-header (defun mailclient-encode-string-as-url (string) "Convert STRING to a URL, using utf-8 as encoding." (apply (function concat) (mapcar (lambda (char) (cond ((eq char ?\x20) "%20") ;; space ((eq char ?\n) "%0D%0A") ;; newline ((string-match "[-a-zA-Z0-9_:/.@]" (char-to-string char)) (char-to-string char)) ;; printable (t ;; everything else (format "%%%02x" char)))) ;; escape ;; Convert string to list of chars (append (encode-coding-string string 'utf-8))))) (defvar mailclient-delim-static "?") (defun mailclient-url-delim () (let ((current mailclient-delim-static)) (setq mailclient-delim-static "&") current)) (defun mailclient-gather-addresses (str delimline &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 "=")) (mailclient-encode-string-as-url (match-string 1)))))) cc)) ;;;###autoload (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" delimline 'drop-first-name) (mailclient-gather-addresses "cc" delimline) (mailclient-gather-addresses "bcc" delimline) (mailclient-gather-addresses "reply-to" delimline) ;; subject line (if (and (goto-char (point-min)) (re-search-forward "^Subject:\s*\\([^\n]*[^ ]\\)\n" delimline t)) (concat (mailclient-url-delim) "subject=" (mailclient-encode-string-as-url (match-string 1))) "") ;; body (concat (mailclient-url-delim) "body=" (mailclient-encode-string-as-url (buffer-substring delimline (point-max)))))))) (kill-buffer tembuf)))) (provide 'mailclient) - --Apple-Mail-19--333784832-- ------- End of forwarded message -------