emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Kill all items with specific tag to kill-ring.


From: Carsten Dominik
Subject: Re: [O] Kill all items with specific tag to kill-ring.
Date: Thu, 25 Apr 2013 10:36:44 +0200

On 25.4.2013, at 10:21, Oleksandr Gavenko <address@hidden> wrote:

> Carsten Dominik <carsten.dominik <at> gmail.com> writes:
> 
>> 
>> On 25.4.2013, at 07:32, Oleksandr Gavenko <gavenkoa <at> gmail.com> wrote:
>> 
>>> I use tags only on top level items in org-file.
>>> 
>>> And want move all items marked by specific tag to different org-file.
>>> 
>>> I expect that this command kill items with selected tag to kill-ring in one
>>> step (so single undo command return original buffer content).
>>> 
>>> Seems there are no such command build-in command...
>> 
>> no, but you could easily make one using the function org-map-entries.
>> 
> 
> 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.

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]