[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
address@hidden: mailclient.el - revised]
From: |
Richard M. Stallman |
Subject: |
address@hidden: mailclient.el - revised] |
Date: |
Sat, 23 Jul 2005 20:01:23 -0400 |
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 <address@hidden>
From: David Reitter <address@hidden>
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 <address@hidden>
;; 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_:/address@hidden" (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 -------
- address@hidden: mailclient.el - revised],
Richard M. Stallman <=
- Re: address@hidden: mailclient.el - revised], Lennart Borgman, 2005/07/23
- Re: address@hidden: mailclient.el - revised], David Reitter, 2005/07/24
- Re: address@hidden: mailclient.el - revised], Lennart Borgman, 2005/07/24
- Re: address@hidden: mailclient.el - revised], David Reitter, 2005/07/28
- Re: address@hidden: mailclient.el - revised], Jason Rumney, 2005/07/28
- Re: address@hidden: mailclient.el - revised], Lennart Borgman, 2005/07/28
- Re: address@hidden: mailclient.el - revised], David Reitter, 2005/07/28
- Re: address@hidden: mailclient.el - revised], Lennart Borgman, 2005/07/28