]> err.no Git - eweouz/commitdiff
Add actual support for adding emails from gnus
authorTollef Fog Heen <tfheen@err.no>
Fri, 8 Aug 2008 07:27:34 +0000 (09:27 +0200)
committerTollef Fog Heen <tfheen@err.no>
Fri, 8 Aug 2008 07:27:34 +0000 (09:27 +0200)
lisp/eweouz.el

index d2adcf340a578660a54af4638a968297a1fca39e..6c4a83881f88e9248f7c3e8ffff30e1affc26a40 100644 (file)
 
 (setq eweouz-helper-dirs '("/usr/lib/eweouz" "/usr/local/lib/eweouz"))
 
-(defvar eweouz-path (locate-file "eweouz-dump-addressbook" 
-                                eweouz-helper-dirs 
-                                nil 
-                                'executable))
+(defvar eweouz-dump-path (locate-file "eweouz-dump-addressbook" 
+                                     eweouz-helper-dirs
+                                     nil
+                                     'executable))
+
+(defvar eweouz-write-path (locate-file "eweouz-write-addressbook"
+                                      eweouz-helper-dirs
+                                      nil
+                                      'executable))
 
 (defvar eweouz-buffer nil)
 (defvar eweouz-pop-up-target-lines 5)
     (set-buffer (get-buffer-create eweouz-buffer-name))
     (insert (vcard-pretty-print record))))
 
+(defun eweouz-add-sender ()
+  "Add sender of current message"
+  (interactive)
+
+  (save-excursion
+    (set-buffer gnus-article-buffer)
+    (let* ((from (mail-header-parse-address (gnus-fetch-field "From")))
+          (record '((email . (car from))
+                    (name . (cdr from)))))
+      (eweouz-do-add record))))
+
+(defun eweouz-do-add (record)
+  (interactive)
+  (let* ((name (cdr (assoc 'name record)))
+        (email (cdr (assoc 'email record))))
+    (call-process eweouz-write-path nil nil nil "--id" "new" "--full-name" name
+                 "--emails" email)))
+
 ;;;###autoload
 (defun eweouz-insinuate-gnus ()
   "Call this function to hook EWEOUZ into Gnus."