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 12:49:56 +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]:52957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVJka-0002EB-Jx for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 06:50:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVJkU-0004t8-V4 for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 06:50:04 -0400 Received: from ezel.ic.uva.nl ([146.50.108.158]:46528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVJkU-0004sq-L2 for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 06:49:58 -0400 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 apr. 2013, at 10:56, Oleksandr Gavenko wrote: > Carsten Dominik gmail.com> writes: >=20 >>=20 >>=20 >> On 25.4.2013, at 10:21, Oleksandr Gavenko gmail.com> = wrote: >>=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... >>=20 >> Yes, this work, nice trick with binding last-command to kill-region. >>=20 >=20 > 10 min of reading (info "(elisp)Low-Level Kill Ring")... This morning = I ask: >=20 > http://thread.gmane.org/gmane.emacs.help/90339 > Want to delete distinct regions but make capable undo by single = command. >=20 > This hack based on: >=20 > (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))) >=20 >> 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. >>=20 >> org-map-entries would allow processing of several files in one go, >> but it would be a very similar implementation. >>=20 >=20 > 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... >=20 > 'org-map-entries' also allow rich search queries: >=20 > (info "(org)Matching tags and properties") >=20 > `+work-boss' > Select headlines tagged `:work:', but discard those also tagged > `:boss:'. >=20 > `work|laptop' > Selects lines tagged `:work:' or `:laptop:'. >=20 > `work|laptop+night' > Like before, but require the `:laptop:' lines to be tagged also > `:night:'. >=20 > Next 20 min I search for 'org-get-buffer-tags'. This code completely = satisfy > my needs: >=20 > (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) ) >=20 > Is it possible to include "correct" implementation (seems that I can't = able > implement one) to org-mode? I thought your version did work? Does it not? - Carsten >=20 > 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:... >=20 >=20