[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb bedce9d 012/449: gnorb-gnus.el: (gnorb-gnus(artic
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb bedce9d 012/449: gnorb-gnus.el: (gnorb-gnus(article|mime)-org-attach) |
Date: |
Fri, 27 Nov 2020 23:14:58 -0500 (EST) |
branch: externals/gnorb
commit bedce9dbdc94d1363b5d20130ff473352ed28615
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
gnorb-gnus.el: (gnorb-gnus(article|mime)-org-attach)
New function: take files received as mail attachments and re-attach them
to an Org heading using org-attach.
---
lisp/gnorb-gnus.el | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/lisp/gnorb-gnus.el b/lisp/gnorb-gnus.el
index eb55071..46632b2 100644
--- a/lisp/gnorb-gnus.el
+++ b/lisp/gnorb-gnus.el
@@ -31,7 +31,60 @@
:tag "Gnorb Gnus"
:group 'gnorb)
+;;; What follows is a very careful copy-pasta of bits and pieces from
+;;; mm-decode.el and gnus-art.el. Voodoo was involved.
+(defun gnorb-gnus-article-org-attach (n)
+ "Save MIME part N, which is the numerical prefix, of the
+ article under point as an attachment to the specified org
+ heading."
+ (interactive "P")
+ (gnus-article-part-wrapper n 'gnorb-gnus-attach-part))
+
+(defun gnorb-gnus-mime-org-attach ()
+ "Save the MIME part under point as an attachment to the
+ specified org heading."
+ (interactive)
+ (gnus-article-check-buffer)
+ (let ((data (get-text-property (point) 'gnus-data)))
+ (when data
+ (gnorb-gnus-attach-part data))))
+
+(defun gnorb-gnus-attach-part (handle &optional org-heading)
+ "Attach HANDLE to an existing org heading."
+ (let ((filename (or (mail-content-type-get
+ (mm-handle-disposition handle) 'filename)
+ (mail-content-type-get
+ (mm-handle-type handle) 'name)))
+ (org-heading (or org-heading
+ (org-refile-get-location "Attach part to"))))
+ (require 'org-attach)
+ (when filename
+ (setq filename (gnus-map-function mm-file-name-rewrite-functions
+ (file-name-nondirectory filename))))
+ ;; Get a temp pathname inside `gnorb-tmp-dir', and save the
+ ;; attachment there
+ (setq filename (expand-file-name filename gnorb-tmp-dir))
+ (mm-save-part-to-file handle filename)
+ ;; then visit the headline in question...
+ (save-window-excursion
+ (find-file (nth 1 org-heading))
+ (goto-char (nth 3 org-heading))
+ ;; ...and actually attach the file, moving it out of the tmp dir
+ (org-attach-attach filename nil 'mv))))
+
+;;; Something is still slightly wrong about the following -- it
+;;; doesn't provide "a" as a key on the button itself, which is what I
+;;; was hoping.
+
+;; (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
+;; "a" gnorb-gnus-article-org-attach)
+
+;; (push '("attach to org heading" . gnorb-gnus-mime-org-attach)
+;; gnus-mime-action-alist)
+
+;; (push '(gnorb-gnus-mime-org-attach "a" "Attach to Org heading")
+;; gnus-mime-button-commands)
(provide 'gnorb-gnus)
;;; gnorb-gnus.el ends here
- [elpa] externals/gnorb 869940a 015/449: README.org: Change file format to Org mode, expand docs, (continued)
- [elpa] externals/gnorb 869940a 015/449: README.org: Change file format to Org mode, expand docs, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 3429f3b 009/449: gnorb-org.el: (gnorb-org-contact-link), Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b7dce0b 016/449: gnorb-utils.el: Require the cl library., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d79617f 019/449: gnorb-org.el: Email current subtree as exported text or file, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 27d08ef 022/449: README.org: Reorganize README, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 3edf1c9 025/449: gnorb-utils.el: gnorb-prompt-for-bbdb-record, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 32ecc09 026/449: gnorb-org.el: gnorb-org-handle-mail, gnorb-org-email-subtree, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 123b521 031/449: gnorb-org.el: bugfix gnorb-org-restore-after-send, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb a9c7410 032/449: gnorb-gnus.el: bugfix gnorb-gnus-attach-part, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5adcc84 008/449: gnorb-utils: (gnorb-prompt-for-bbdb-record), Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb bedce9d 012/449: gnorb-gnus.el: (gnorb-gnus(article|mime)-org-attach),
Stefan Monnier <=
- [elpa] externals/gnorb d28a099 005/449: gnorb-bbdb.el: New function gnorb-bbdb-tag-agenda, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 63ac8f6 011/449: gnorb-org.el: (gnorb-org-handle-mail, gnorb-org-handle-mail-agenda), Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb c2b1a3a 013/449: Docstring for gnorb-org-contact-link, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d4987a7 014/449: gnorb-utils.el: More likely requires for Org libraries, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 62368b7 017/449: gnorb-gnus.el: Make attachment fiddling work in org capture, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb da7cf10 018/449: gnorb-utils.el: Require mailcap, and parse, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5264b3c 021/449: README.org: Document gnorb-org-email-subtree, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 82bb9db 023/449: README.org: Add keybindings to gnus mime commands., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 534b2bf 024/449: gnorb-org.el: new option gnorb-org-mail-todos, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9c5d04a 027/449: README.org: More explanation about the mail stuff., Stefan Monnier, 2020/11/27