emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: "Juan Manuel Macías" <maciaschain@posteo.net>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] org-attach: Attach current Gnus article parts
Date: Sun, 08 May 2022 22:18:33 +0800	[thread overview]
Message-ID: <87czgoqf9i.fsf@localhost> (raw)
In-Reply-To: <87a6bsp397.fsf@posteo.net>

Juan Manuel Macías <maciaschain@posteo.net> writes:

> What I don't quite understand is why it wouldn't be appropriate to add a
> new entry with the new feature to the org-attach menu.

Thinking about it more, new feature in org-attach menu should actually
be ok.

My initial logic was that we cannot easily select attach method for
entries in the attach menu. However, anything other than 'cp method is
meaningless when saving article attachments.

> Well, as I said, I have chosen Gnus because it is part of GNU Emacs. In
> any case, if anyone wants to write a patch with a more general solution,
> I'd encourage them. I think that would be an interesting feature for
> org-attach. I only use Gnus and unfortunately I'm not familiar with
> other mail reader libraries (I could try to do something more "agnostic"
> from message-mode, when I have some more time...).

I think that a good example implementation is from notmuch.el. It does
not use anything specific to notmuch, just built-in mm-*.el from gnus:

(defun notmuch-save-attachments (mm-handle &optional queryp)
  (notmuch-foreach-mime-part
   (lambda (p)
     (let ((disposition (mm-handle-disposition p)))
       (and (listp disposition)
	    (or (equal (car disposition) "attachment")
		(and (equal (car disposition) "inline")
		     (assq 'filename disposition)))
	    (or (not queryp)
		(y-or-n-p
		 (concat "Save '" (cdr (assq 'filename disposition)) "' ")))
	    (mm-save-part p))))
   mm-handle))

(defun notmuch-foreach-mime-part (function mm-handle)
  (cond ((stringp (car mm-handle))
	 (dolist (part (cdr mm-handle))
	   (notmuch-foreach-mime-part function part)))
	((bufferp (car mm-handle))
	 (funcall function mm-handle))
	(t (dolist (part mm-handle)
	     (notmuch-foreach-mime-part function part)))))

Best,
Ihor


  reply	other threads:[~2022-05-08 14:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-05-08 18:06       ` Juan Manuel Macías

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87czgoqf9i.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=maciaschain@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).