From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/85087 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.gnus.general Subject: Re: Deleting mail in virtual group Date: Mon, 06 Oct 2014 10:44:08 +0800 Message-ID: <87r3yl7w93.fsf@ericabrahamsen.net> References: <87mw9cfazu.fsf@mailbox.org> <87zjdcyp8o.fsf@ericabrahamsen.net> <874mvkexiw.fsf@mailbox.org> <87a95a9ald.fsf@ericabrahamsen.net> <87tx3il6bo.fsf@mailbox.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1412563531 9750 80.91.229.3 (6 Oct 2014 02:45:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 Oct 2014 02:45:31 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M33331@lists.math.uh.edu Mon Oct 06 04:45:24 2014 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XayIe-00045O-7a for ding-account@gmane.org; Mon, 06 Oct 2014 04:45:24 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1XayHm-0006rj-Mr; Sun, 05 Oct 2014 21:44:30 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1XayHj-0006rD-44 for ding@lists.math.uh.edu; Sun, 05 Oct 2014 21:44:27 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1XayHg-00049S-E3 for ding@lists.math.uh.edu; Sun, 05 Oct 2014 21:44:26 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1XayHe-0008FA-FB for ding@gnus.org; Mon, 06 Oct 2014 04:44:22 +0200 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XayHe-0003V2-Ah for ding@gnus.org; Mon, 06 Oct 2014 04:44:22 +0200 Original-Received: from 125.77.224.30 ([125.77.224.30]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 06 Oct 2014 04:44:22 +0200 Original-Received: from eric by 125.77.224.30 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 06 Oct 2014 04:44:22 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 74 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 125.77.224.30 User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:bo0aiU2c4/V1S53/U+6+eOdexso= X-Spam-Score: -1.7 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:85087 Archived-At: Alexander Baier writes: > On 2014-10-05 10:36 Eric Abrahamsen wrote: >> Alexander Baier 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