From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Kill all items with specific tag to kill-ring. Date: Thu, 25 Apr 2013 10:36:44 +0200 Message-ID: References: <87haivyy3h.fsf@gavenkoa.example.com> Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVHff-0004N7-9E for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 04:36:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVHfa-0003xw-O0 for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 04:36:51 -0400 Received: from mail-ea0-x230.google.com ([2a00:1450:4013:c01::230]:58581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVHfa-0003xr-Dm for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 04:36:46 -0400 Received: by mail-ea0-f176.google.com with SMTP id h14so1139010eak.21 for ; Thu, 25 Apr 2013 01:36:45 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Oleksandr Gavenko Cc: emacs-orgmode@gnu.org On 25.4.2013, at 10:21, Oleksandr Gavenko wrote: > Carsten Dominik gmail.com> writes: >=20 >>=20 >> On 25.4.2013, at 07:32, Oleksandr Gavenko gmail.com> = wrote: >>=20 >>> I use tags only on top level items in org-file. >>>=20 >>> And want move all items marked by specific tag to different = org-file. >>>=20 >>> I expect that this command kill items with selected tag to kill-ring = in one >>> step (so single undo command return original buffer content). >>>=20 >>> Seems there are no such command build-in command... >>=20 >> no, but you could easily make one using the function org-map-entries. >>=20 >=20 > I finish with very hackie code (based on knowledge of internal > implementation of org-scan-tags): >=20 > (defun my-org-kill-by-tag (tag) > (interactive (list (read-input "Enter tag: "))) > (kill-new "") > (org-scan-tags > (lambda () > (let ( (last-command 'kill-region) ) > (org-cut-subtree))) > '(member tag tags-list) > nil) ) >=20 > You can replace 'org-cut-subtree' by 'org-copy-subtree' if don't want = remove > org entries... Yes, this work, nice trick with binding last-command to kill-region. A less hackie version would probably add the found entries to a string or list and only put that string into the kill ring at the end. org-map-entries would allow processing of several files in one go, but it would be a very similar implementation. - Carsten=