From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleksandr Gavenko Subject: Re: Kill all items with specific tag to kill-ring. Date: Thu, 25 Apr 2013 08:56:07 +0000 (UTC) Message-ID: References: <87haivyy3h.fsf@gavenkoa.example.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:33934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVIQa-0006cK-1g for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 05:25:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVIQV-00025C-4I for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 05:25:19 -0400 Received: from plane.gmane.org ([80.91.229.3]:60571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVHyU-0001j8-DV for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 04:56:18 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UVHyT-0005s9-IL for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 10:56:17 +0200 Received: from 217.117.64.200 ([217.117.64.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 Apr 2013 10:56:17 +0200 Received: from gavenkoa by 217.117.64.200 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 Apr 2013 10:56:17 +0200 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: emacs-orgmode@gnu.org Carsten Dominik gmail.com> writes: > > > On 25.4.2013, at 10:21, Oleksandr Gavenko gmail.com> wrote: > > > I finish with very hackie code (based on knowledge of internal > > implementation of org-scan-tags): > > > > (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) ) > > > > 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. > 10 min of reading (info "(elisp)Low-Level Kill Ring")... This morning I ask: http://thread.gmane.org/gmane.emacs.help/90339 Want to delete distinct regions but make capable undo by single command. This hack based on: (defun kill-region (beg end &optional yank-handler) .... (if (eq last-command 'kill-region) (kill-append string (< end beg) yank-handler) (kill-new string nil yank-handler))) > 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. > I look to code and found that 'org-map-entries' call 'org-scan-tags'. As 'org-map-entries' looks complicated to me I try to use more low-level function... 'org-map-entries' also allow rich search queries: (info "(org)Matching tags and properties") `+work-boss' Select headlines tagged `:work:', but discard those also tagged `:boss:'. `work|laptop' Selects lines tagged `:work:' or `:laptop:'. `work|laptop+night' Like before, but require the `:laptop:' lines to be tagged also `:night:'. Next 20 min I search for 'org-get-buffer-tags'. This code completely satisfy my needs: (defun my-org-kill-by-tag (tag) (interactive (list (completing-read "Enter tag: " (org-get-buffer-tags)))) (kill-new "") (org-scan-tags (lambda () (let ( (last-command 'kill-region) ) (org-cut-subtree))) '(member tag tags-list) nil) ) Is it possible to include "correct" implementation (seems that I can't able implement one) to org-mode? I want this feature in order to simplify precess of moving entries from job org-file to home org-file by marking entries with tag :HOME:...