[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 851c0f1 320/350: Half-implement signature snarfing
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 851c0f1 320/350: Half-implement signature snarfing for MUAs |
Date: |
Mon, 14 Aug 2017 11:47:03 -0400 (EDT) |
branch: externals/ebdb
commit 851c0f12c6230d2e499d5cc5983e1252e936c41d
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Half-implement signature snarfing for MUAs
* ebdb-com.el: Remove commented-out customization option regarding
signature snarfing. This would have implemented automated snarfing,
which would have been a nightmare. Only snarf on user command.
* ebdb-mua.el (ebdb-mua-get-signature): New generic method for
returning the text of a message signature.
(ebdb-mua-snarf-article): Add signature snarfing as a part of this
function. Perhaps we'll want a separate function later?
* ebdb-gnus.el (ebdb-mua-get-signature): Implement for Gnus, figure
out the others later.
---
ebdb-com.el | 7 -------
ebdb-gnus.el | 10 ++++++++++
ebdb-mua.el | 31 +++++++++++++++++++++++++++----
3 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index a35e8f8..f261db1 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -80,13 +80,6 @@ Used by `ebdb-mouse-menu'."
:group 'ebdb-record-display
:type 'sexp)
-;; (defcustom ebdb-mua-auto-snarf-signature nil
-;; "If t, EBDB will attempt to snarf the mail message signature
-;; and add additional field information (ie phone or address) to
-;; the sending record.
-
-;; Valid values are nil, 'query or t, or 'auto.")
-
(defcustom ebdb-display-hook nil
"Hook run after the *EBDB* is filled in."
:group 'ebdb-record-display
diff --git a/ebdb-gnus.el b/ebdb-gnus.el
index 78394ca..4d0e318 100644
--- a/ebdb-gnus.el
+++ b/ebdb-gnus.el
@@ -472,6 +472,16 @@ quoted replies."
(article-goto-body)
(buffer-substring-no-properties (point) (point-max))))
+(cl-defmethod ebdb-mua-article-signature (&context (major-mode
gnus-summary-mode))
+ (gnus-with-article-buffer
+ (gnus-article-search-signature)
+ (forward-line)
+ (buffer-substring-no-properties
+ (point)
+ ;; Assume a blank line concludes a signature.
+ (or (re-search-forward "\n\n" nil t)
+ (point-max)))))
+
(defun ebdb-insinuate-gnus ()
"Hook EBDB into Gnus."
;; `ebdb-mua-display-sender' fails in *Article* buffers, where
diff --git a/ebdb-mua.el b/ebdb-mua.el
index 0a47580..2072f69 100644
--- a/ebdb-mua.el
+++ b/ebdb-mua.el
@@ -953,6 +953,14 @@ Dispatches on the value of major-mode."
This method should NOT return the message headers, only the
article text. This is typically used for snarfing.")
+(cl-defgeneric ebdb-mua-article-signature (major-mode)
+ "Return the text of the signature of the current article.")
+
+;; At the moment this is only implemented for Gnus.
+(cl-defmethod ebdb-mua-article-signature ()
+ "Default version returns nothing."
+ "")
+
;;;###autoload
(defun ebdb-mua-update-records (&optional header-class all)
"Update all records associated with the message under point.
@@ -1073,16 +1081,31 @@ where it was in the MUA, rather than quitting the EBDB
buffer."
;;;###autoload
(defun ebdb-mua-snarf-article ()
- "Snarf the body of the current article."
+ "Snarf the body of the current article.
+
+This snarfs all available record information in the article,
+first attempting to associate it with the senders and recipients
+of the article, afterwards prompting for the creation of new
+records.
+
+In addition, if a signature is present, snarf it and attempt at
+associate field information in it with the article sender."
(interactive)
(condition-case nil
;; If the MUA has already popped up a buffer, assume the records
;; displayed there are relevant to the article snarf.
(let* ((buf (get-buffer (ebdb-make-buffer-name)))
- (recs (when (buffer-live-p buf)
- (mapcar #'car (buffer-local-value 'ebdb-records buf)))))
+ (all-recs (ebdb-update-records
+ (ebdb-get-address-components)
+ 'existing))
+ (sender (ebdb-update-records
+ (ebdb-get-address-components 'sender)
+ 'existing))
+ (signature (ebdb-mua-get-signature)))
(ebdb-mua-prepare-article)
- (ebdb-snarf (ebdb-mua-article-body) nil nil recs))
+ (unless (or (null (stringp signature)) (string-blank-p signature))
+ (ebdb-snarf signature nil nil sender))
+ (ebdb-snarf (ebdb-mua-article-body) nil nil all-recs))
(cl-no-applicable-method
(message "Article snarfing doesn't work in this context."))))
- [elpa] externals/ebdb 8cdb1d1 307/350: Fix bug in ebdb-char-fold-search logic, (continued)
- [elpa] externals/ebdb 8cdb1d1 307/350: Fix bug in ebdb-char-fold-search logic, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5329d89 306/350: Mark arg as used in call to ebdb-with-record-edits, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 56f8f5f 301/350: Mention Org integration in the manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c0910a1 312/350: Add test for multiple databases plus read only, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 9e5b55d 316/350: Set local variable correctly in manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e80675b 300/350: Mention support for completion frameworks in manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 9a0cca1 321/350: Create ebdb-parse method for URL fields, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b26e295 325/350: Fall back to human readable name of labeled fields, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 0fe0957 289/350: Large pile of manual, docstring, and comment edits, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4034f7a 331/350: Add phone field snarfing to the list of snarf routines, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 851c0f1 320/350: Half-implement signature snarfing for MUAs,
Eric Abrahamsen <=
- [elpa] externals/ebdb d589a33 328/350: Internationalized ebdb-parse for phones wasn't doing enough setup, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4d26065 339/350: Prepare ebdb-gnorb to be extricated, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 27325c4 336/350: Replace trailing whitespace in tests, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b990fdf 327/350: File header changes preparatory to breaking off separate libraries, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5f97295 337/350: Catching wrong error in internationalized version of name string, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 2c9d491 323/350: Rework snarf collection, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f466e6e 342/350: Add some country name "shorthands", Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 26ee1cb 330/350: Refactor snarfing, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 6cc67a7 315/350: Add instructions for writing i18n libraries to manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c11ef0e 334/350: Rename ebdb-message-header to ebdb-mua-message-header, Eric Abrahamsen, 2017/08/14