[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb b635b4e 155/350: First stab at article snarfing
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb b635b4e 155/350: First stab at article snarfing |
Date: |
Mon, 14 Aug 2017 11:46:26 -0400 (EDT) |
branch: externals/ebdb
commit b635b4e6d611a4b823942c5869de68fac77120ac
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
First stab at article snarfing
* ebdb-mua.el (ebdb-mua-snarf-article): Interactive function for
snarfing the text of an article in MUA.
(ebdb-mua-article-body): Generic function for returning the text of
an article.
* ebdb-gnus.el (ebdb-mua-article-body): Implement for Gnus.
---
ebdb-gnus.el | 16 ++++++++++++++++
ebdb-mua.el | 21 +++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/ebdb-gnus.el b/ebdb-gnus.el
index eef83d1..e82369a 100644
--- a/ebdb-gnus.el
+++ b/ebdb-gnus.el
@@ -456,6 +456,22 @@ Note that `\( is the backquote, NOT the quote '\(."
(cl-defmethod ebdb-mua-prepare-article (&context (major-mode
gnus-article-mode))
(gnus-summary-select-article))
+(cl-defmethod ebdb-mua-article-body (&context (major-mode gnus-summary-mode))
+ "Return the current article body as a string.
+
+Must not include article headers, though can include headers in
+quoted replies."
+ (gnus-with-article-buffer
+ ;; This pretends that there's no such thing as mime parts, and
+ ;; will probably fail horribly.
+ (article-goto-body)
+ (buffer-substring-no-properties (point) (point-max))))
+
+(cl-defmethod ebdb-mua-article-body (&context (major-mode gnus-article-mode))
+ (gnus-with-article-buffer
+ (article-goto-body)
+ (buffer-substring-no-properties (point) (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 349e9ba..8885667 100644
--- a/ebdb-mua.el
+++ b/ebdb-mua.el
@@ -1118,6 +1118,12 @@ Ie, don't pop up at all."
"When popping up from a random window, use half the window."
(list (get-buffer-window) 0.5))
+(cl-defgeneric ebdb-mua-article-body (major-mode)
+ "Return the text of the current MUA article, as a string.
+
+This method should NOT return the message headers, only the
+article text. This is typically used for snarfing.")
+
;;;###autoload
(defun ebdb-mua-update-records (&optional header-class all)
"Update all records associated with the message under point.
@@ -1288,6 +1294,21 @@ FIELD defaults to value of variable
`ebdb-mua-edit-field'."
(interactive)
(ebdb-mua-edit-field field 'recipients))
+;;;###autoload
+(defun ebdb-mua-snarf-article ()
+ "Snarf the body of the current article."
+ (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)))))
+ (ebdb-mua-prepare-article)
+ (ebdb-snarf (ebdb-mua-article-body) recs))
+ (cl-no-applicable-method
+ (message "Article snarfing doesn't work in this context."))))
+
;; Functions for noninteractive use in MUA hooks
;;;###autoload
- [elpa] externals/ebdb a0eada8 128/350: Change some of the EBDB buffer formatting defaults, (continued)
- [elpa] externals/ebdb a0eada8 128/350: Change some of the EBDB buffer formatting defaults, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 20906ae 131/350: ebdb-prompt-for-record should load if necessary, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1bc78ab 133/350: Add helm-ebdb file, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ed3e270 119/350: Reverse order of args in return value of ebdb-popup-window, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ed6e228 136/350: Make ebdb-annotate-message more class agnostic, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb aa2d973 147/350: Allow optional records argument to ebdb-initialize, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 42f6dce 130/350: Add "Hacking EBDB" section to manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5dda311 118/350: Force mode line update after renaming EBDB buffers, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a94483d 122/350: Refinements to snarfing, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb d9b4865 146/350: More tweaks to snarfing process, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b635b4e 155/350: First stab at article snarfing,
Eric Abrahamsen <=
- [elpa] externals/ebdb 6c267e9 159/350: Fix pop-up mouse menus in EBDB buffers, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 55b3f82 160/350: Fixup with fix popup menus, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb abdb8cd 158/350: Update copyright years to 2017, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5fdf286 166/350: Feeding incorrect args to ebdb-snarf, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 9b6c88d 167/350: Fix incorrect variable name, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb dd13813 171/350: Bah, fixups to a19ff0a, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f1448f4 174/350: Remove this empty file, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 6479c87 173/350: Remove unused code, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb db930f6 163/350: Compiler-inspired fixes, and removal of old-code references, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 281c61e 154/350: Don't ((lambda ()), Eric Abrahamsen, 2017/08/14