From: "Richard M. Stallman" <rms@gnu.org>
Subject: [david.reitter@gmail.com: mailclient.el - revised]
Date: Sat, 23 Jul 2005 20:01:23 -0400 [thread overview]
Message-ID: <E1DwTvn-0000Ym-G1@fencepost.gnu.org> (raw)
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 <rms@gnu.org>
From: David Reitter <david.reitter@gmail.com>
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 <david.reitter@gmail.com>
;; 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 -------
next reply other threads:[~2005-07-24 0:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-24 0:01 Richard M. Stallman [this message]
2005-07-24 0:17 ` [david.reitter@gmail.com: mailclient.el - revised] Lennart Borgman
2005-07-24 14:11 ` David Reitter
2005-07-24 14:46 ` Lennart Borgman
2005-07-28 11:34 ` David Reitter
2005-07-28 12:24 ` Jason Rumney
2005-07-28 13:01 ` Lennart Borgman
2005-07-28 13:31 ` David Reitter
2005-07-28 12:55 ` Lennart Borgman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1DwTvn-0000Ym-G1@fencepost.gnu.org \
--to=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.