Add KDE-emacs/GNUS mail integration tools
g0dil [Thu, 26 Oct 2006 09:04:17 +0000 (09:04 +0000)]
mail/emacs-mail [new file with mode: 0755]
mail/emacs-mail.el [new file with mode: 0644]

diff --git a/mail/emacs-mail b/mail/emacs-mail
new file mode 100755 (executable)
index 0000000..4a4f8ed
--- /dev/null
@@ -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 (file)
index 0000000..bf86ec2
--- /dev/null
@@ -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)