|
From: | Oleksandr Gavenko |
Subject: | Re: Want to delete distinct regions but make capable undo by single command. |
Date: | Thu, 25 Apr 2013 11:13:20 +0000 (UTC) |
User-agent: | Loom/3.14 (http://gmane.org/) |
Oleksandr Gavenko <gavenkoa <at> gmail.com> writes: > > Want to delete distinct regions but make capable undo by single command > (programmatically). > > Like this happen after automatic replacement ('!'). You undo by 'M-_' all > replacement at once instead sequentially each individually. > Wrote such code: (defun my-org-kill-by-tag (tag) "Put all entries that matches TAG from current org-file to `kill-ring'." (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) ) See origin: http://thread.gmane.org/gmane.emacs.orgmode/71263 Kill all items with specific tag to kill-ring. which exploit 'org-cut-subtree' implementation with: (let ( (last-command 'kill-region) ) ...kill-commands...) To make this possible your code MUST use only high-level kill ring functions. Which take care on "last-command == kill-region". If some function in code use 'kill-new' or 'kill-append' - 'last-command' trick fail...
[Prev in Thread] | Current Thread | [Next in Thread] |