[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Cut and paste an entry programmatically
From: |
Michael Brand |
Subject: |
Re: [O] Cut and paste an entry programmatically |
Date: |
Sat, 29 Jun 2019 09:27:48 +0200 |
Hi Kyle
On Sat, Jun 29, 2019 at 2:58 AM Kyle Meyer <address@hidden> wrote:
> Hmm I don't consider that a bug. It's documented behavior for kill
> commands to append to the last kill when called successively.
>
> ,----[ C-h f kill-region RET ]
> | [...]
> | Any command that calls this function is a "kill command".
> | If the previous command was also a kill command,
> | the text killed this time appends to the text killed last time
> | to make one entry in the kill ring.
> | [...]
> `----
Although I knew of course that ~C-k C-k~ appends it didn't ring the
bell it should have. And I was not aware of the concept of a "kill
command" which can make my function a "kill command", _depending on
how it is invoked_.
> In addition to what Samuel posted, another way for a lisp caller to
> avoid the append behavior if desired is to let-bind this-command so that
> kill-region's attempt to set it to kill-region doesn't work. Using your
> example, that'd be
>
> #+begin_src emacs-lisp
> (defun temp ()
> (let (this-command)
> (org-cut-subtree))
> (org-forward-heading-same-level 2)
> (org-paste-subtree))
> #+end_src
This is what I have been looking for, thank you.
Michael