Gnus development mailing list
 help / color / mirror / Atom feed
From: Alexander Baier <alexander.baier@mailbox.org>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: ding@gnus.org
Subject: Re: Deleting mail in virtual group
Date: Sun, 05 Oct 2014 20:28:11 +0200	[thread overview]
Message-ID: <87tx3il6bo.fsf@mailbox.org> (raw)
In-Reply-To: <87a95a9ald.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Sun, 05 Oct 2014 16:36:46 +0800")

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? 

Regards,
-- 
Alexander Baier



  reply	other threads:[~2014-10-05 18:28 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 [this message]
2014-10-06  2:44         ` Eric Abrahamsen

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=87tx3il6bo.fsf@mailbox.org \
    --to=alexander.baier@mailbox.org \
    --cc=ding@gnus.org \
    --cc=eric@ericabrahamsen.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.
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).