[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 12:49:56 +0200 |
On 25 apr. 2013, at 10:56, Oleksandr Gavenko <address@hidden> wrote:
> Carsten Dominik <carsten.dominik <at> gmail.com> writes:
>
>>
>>
>> On 25.4.2013, at 10:21, Oleksandr Gavenko <gavenkoa <at> 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 thought your version did work? Does it not?
- Carsten
>
> 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:...
>
>
- [O] Kill all items with specific tag to kill-ring., Oleksandr Gavenko, 2013/04/25
- Re: [O] Kill all items with specific tag to kill-ring., Carsten Dominik, 2013/04/25
- Re: [O] Kill all items with specific tag to kill-ring., Oleksandr Gavenko, 2013/04/25
- Re: [O] Kill all items with specific tag to kill-ring., Carsten Dominik, 2013/04/25
- Re: [O] Kill all items with specific tag to kill-ring., Oleksandr Gavenko, 2013/04/25
- Re: [O] Kill all items with specific tag to kill-ring.,
Carsten Dominik <=
- Re: [O] Kill all items with specific tag to kill-ring., Oleksandr Gavenko, 2013/04/25
- Re: [O] Kill all items with specific tag to kill-ring., Bernt Hansen, 2013/04/25
- Re: [O] Kill all items with specific tag to kill-ring., Oleksandr Gavenko, 2013/04/29