branch: externals/autocrypt
commit cf63019b3f58c8696b7251cde4087127557283a3
Author: Philip Kaludercic <[email protected]>
Commit: Philip Kaludercic <[email protected]>

    Add a 'get-part' implementation for Gnus
---
 autocrypt-gnus.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/autocrypt-gnus.el b/autocrypt-gnus.el
index ffce813e62..bcb0df5ba0 100644
--- a/autocrypt-gnus.el
+++ b/autocrypt-gnus.el
@@ -19,6 +19,8 @@
 ;;; Code:
 
 (require 'gnus)
+(require 'gnus-art)
+(require 'mm-decode)
 (require 'autocrypt)
 
 ;;;###autoload
@@ -34,6 +36,23 @@
   "Return value for HEADER from current message."
   (gnus-fetch-original-field header))
 
+(defun autocrypt-gnus--get-part (index)
+  "Return the INDEX'th part of the message as a string."
+  (save-window-excursion
+    (let ((content nil))
+      (condition-case nil
+          (gnus-article-part-wrapper
+           (1+ index)
+           (lambda (&optional handle _arg _event)
+             (unless handle
+               (gnus-article-jump-to-part (1+ index))
+               (setq handle (get-text-property (point) 'gnus-data)))
+             (with-temp-buffer
+               (mm-insert-part handle)
+               (setq content (buffer-string)))))
+        (error))
+      content)))
+
 (provide 'autocrypt-gnus)
 
 ;;; autocrypt-gnus.el ends here

Reply via email to