From: g0dil Date: Thu, 26 Oct 2006 09:04:17 +0000 (+0000) Subject: Add KDE-emacs/GNUS mail integration tools X-Git-Url: http://g0dil.de/git?p=emacsstuff.git;a=commitdiff_plain;h=827b6389c9c4709ca5be5c767715ee7632019c85 Add KDE-emacs/GNUS mail integration tools --- diff --git a/mail/emacs-mail b/mail/emacs-mail new file mode 100755 index 0000000..4a4f8ed --- /dev/null +++ b/mail/emacs-mail @@ -0,0 +1,14 @@ +#!/usr/bin/python + +import sys +import re +import os + +QRE = re.compile("[\\\"]") + +def quote(s): + def repl(m): return "\\"+m.group(0) + return QRE.sub(repl,s) + +os.spawnlp(os.P_WAIT,"gnuclient","gnuclient","--eval", + "(write-mail \"" + "\" \"".join(map(quote,sys.argv[1:])) + "\")") diff --git a/mail/emacs-mail.el b/mail/emacs-mail.el new file mode 100644 index 0000000..bf86ec2 --- /dev/null +++ b/mail/emacs-mail.el @@ -0,0 +1,72 @@ +;;; cc-ide.el --- C++ IDE +;; +;; $Id$ +;; +;; Copyright (C) 2000 Stefan Bund + +;; cc-ide.el 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. + +;; cc-ide.el 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. + +;;; Commentary: + +;;; Change-Log: + +;; $Log$ +;; + +;;; Variables: + +;;; Code: + +(defun mail-add-header (header value &optional separator) + (when (and value (> (length value) 0)) + (mail-position-on-field header) + (if (save-excursion + (skip-chars-backward " \t\n\r") + (not (eq (preceding-char) ?:))) + (insert separator)) + (insert value))) + +(defun write-mail (&optional to subject cc bcc body attachment) + (interactive) + (loop for b in (buffer-list) + if (eq major-mode 'message-mode) + return (pop-to-buffer b) + finally (progn + (if (eq major-mode 'gnus-summary-mode) + (gnus-summary-mail-other-window) + (gnus-group-mail)) + (goto-char (point-max)) + (if (re-search-backward "^-- $" nil) + (forward-line -1)))) + (save-excursion + (mail-add-header "To" to ",\n ") + (mail-add-header "Subject" subject "; ") + (mail-add-header "CC" cc ", ") + (mail-add-header "BCC" bcc ", ")) + (if body (insert body)) +;; (when (file-readable-p "~/.signature") +;; (insert "\n-- \n") +;; (insert-file "~/.signature") +;; (goto-char (point-max)) +;; (if (not (bolp)) +;; (insert "\n"))) + (when (and attachment (> (length attachment) 0)) + (if (and (> (length attachment) 5) + (string= (substring attachment 0 5) "file:")) + (setq attachment (substring attachment 5))) + (when (file-readable-p attachment) + (save-excursion + (goto-char (point-max)) + (insert "\n") + (mime-edit-insert-file attachment)))) + (font-lock-fontify-buffer)) + +(provide 'emacs-mail)