all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] org-attach: Attach current Gnus article parts
@ 2022-05-07 14:31 Juan Manuel Macías
  2022-05-08 12:30 ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Juan Manuel Macías @ 2022-05-07 14:31 UTC (permalink / raw)
  To: orgmode

[-- Attachment #1: Type: text/plain, Size: 630 bytes --]

Hi all,

In the attached patch I add a new command for org-attach: save *all*
attachments from the current Gnus article to the current org-attach-dir.

(Sorry for repeating the word "attach" so much :-))

NB:

1. If no Gnus article is open, it returns an error message.

2. I've only tested it on Emacs 28. I don't know if it can cause any
problems on earlier Emacs/Gnus versions.

3. Although there are several alternatives to Gnus, I have chosen Gnus
specifically because it is part of GNU Emacs.

4. I think an option could be added to save only certain types of files
(pdf, png, jpg, docx, etc.).

Best regards,

Juan Manuel


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-org-attach.el-new-command-to-attach-Gnus-curren.patch --]
[-- Type: text/x-patch, Size: 1865 bytes --]

From 03a53680df38300110c2095a98bc1dec8cc7adce Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias <maciaschain@posteo.net>
Date: Sat, 7 May 2022 16:04:06 +0200
Subject: [PATCH] lisp/org-attach.el: new command to attach Gnus current
 article parts

* (org-attach-gnus-save-parts-current-article): Attach current Gnus
article parts
* (org-attach-commands): add a new key
---
 lisp/org-attach.el | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 5ee2b84b2..54c8a2bdb 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -206,6 +206,8 @@ git-functionality from this file.")
      "Attach a file using symbolic-link method.")
     ((?u ?\C-u) org-attach-url
      "Attach a file from URL (downloading it).")
+    ((?g ?\C-g) org-attach-gnus-save-parts-current-article
+     "Attach current Gnus article parts")
     ((?b) org-attach-buffer
      "Select a buffer and attach its contents to the task.")
     ((?n ?\C-n) org-attach-new
@@ -488,6 +490,21 @@ DIR-property exists (that is different from the unset one)."
   (let ((org-attach-method 'url))
     (org-attach-attach url)))
 
+(defun org-attach-gnus-save-parts-current-article ()
+  "Attach current Gnus article parts."
+  (interactive)
+  (let* ((attach-dir (org-attach-dir 'get-create))
+	 (art gnus-article-current)
+	 (subject (gnus-summary-article-subject (cdr art))))
+    (if (not art)
+	(error "There is no open article")
+      (if (yes-or-no-p (format "Attach current article: \"%s\"" subject))
+	  (progn
+	    (org-attach-tag)
+	    (gnus-summary-save-parts "." attach-dir art)
+	    (message "New attachment: \"%s\"" subject))
+	(keyboard-quit)))))
+
 (defun org-attach-buffer (buffer-name)
   "Attach BUFFER-NAME's contents to current outline node.
 BUFFER-NAME is a string.  Signals a `file-already-exists' error
-- 
2.36.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-08 18:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-07 14:31 [PATCH] org-attach: Attach current Gnus article parts Juan Manuel Macías
2022-05-08 12:30 ` Ihor Radchenko
2022-05-08 13:23   ` Juan Manuel Macías
2022-05-08 14:18     ` Ihor Radchenko
2022-05-08 18:06       ` Juan Manuel Macías

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.