From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: ding@gnus.org
Subject: Re: Deleting mail in virtual group
Date: Mon, 06 Oct 2014 10:44:08 +0800 [thread overview]
Message-ID: <87r3yl7w93.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <87tx3il6bo.fsf@mailbox.org>
Alexander Baier <alexander.baier@mailbox.org> writes:
> On 2014-10-05 10:36 Eric Abrahamsen wrote:
>> Alexander Baier <alexander.baier@mailbox.org> writes:
>>
>>> On 2014-10-04 14:48 Eric Abrahamsen wrote:
>>>>> I want to write my own command that finds the original group of the
>>>>> article in question and executes the move in that group. Is there a
>>>>> function that gets me the original group of an article in a virtual
>>>>> group?
>>>>
>>>> I'm pretty sure that nnvirtual-find-group-art will do what you want.
>>>> Feed it the article number of the article under point, along with
>>>> gnus-newsgroup-name in the virtual Summary buffer. See how it works!
>>>
>>> Thank you for your quick reply! These to functions do what I want and I
>>> get the correct original group and article. But now I am stuck and do
>>> not know how to get to the original group. This is what I tried:
>>>
>>> #+BEGIN_SRC emacs-lisp
>>> (defun my-nnvirtual-delete-article ()
>>> (interactive)
>>> (let ((original (nnvirtual-find-group-art
>>> gnus-newsgroup-name
>>> (gnus-summary-article-number))))
>>> (with-current-buffer gnus-group-buffer
>>> (gnus-group-goto-group (car original))
>>> (gnus-summary-goto-article (cdr original)))))
>>> #+END_SRC
>>
>> All `gnus-group-goto-group' does is move to the group's line in the
>> *Group* buffer. Try `gnus-group-read-group' instead. That -- or
>> something involving that -- ought to do what you want.
>
> Yes, gnus-group-read-group works! The following code takes the current
> article and moves it from its original group to a specified trash
> group:
>
> #+BEGIN_SRC emacs-lisp
> (defun my-nnvirtual-delete-article ()
> (interactive)
> (let* ((original (nnvirtual-find-group-art
> gnus-newsgroup-name
> (gnus-summary-article-number)))
> (group (car original))
> (article (cdr original))
> (trash (cl-assoc group my-gnus-trash-locations
> :test (lambda (item rx)
> (string-match-p rx item)))))
> (unless trash
> (error "No trash folder configured for group %s" group))
> (with-current-buffer gnus-group-buffer
> (gnus-group-read-group nil nil group (list article))
> (gnus-summary-move-article 1 (cdr trash)))))
>
> (defvar my-gnus-trash-locations
> '(("nnmaildir\\+mailbox:.*" . "nnmaildir+mailbox:Trash"))
> "Locations of trash folders.")
> #+END_SRC
>
> The problem with this code is that I end up in the original group after
> the moving/deleting is finished and not in the virtual group. This
> surprises me, as I always thought of `with-current-buffer' as a macro
> that save my window configuration. Apparently this is not the case, why
> is that?
That I can't tell you! My only guess is that virtual group *Summary*
buffer is actually getting destroyed in the process of shifting groups
and moving messages, and there's nowhere to return to. You could test by
manually replicating what `with-current-buffer' does: save the current
buffer in your let form, then try to `switch-to-buffer' back to it when
the article's been moved, and see if it still exists.
Eric
prev parent reply other threads:[~2014-10-06 2:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-04 9:19 Alexander Baier
2014-10-04 12:48 ` Eric Abrahamsen
2014-10-04 14:10 ` Alexander Baier
2014-10-05 8:36 ` Eric Abrahamsen
2014-10-05 18:28 ` Alexander Baier
2014-10-06 2:44 ` Eric Abrahamsen [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r3yl7w93.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=ding@gnus.org \
/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.
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 NNTP newsgroup(s).