开发者

refiling to a given subtree by a keybinding

开发者 https://www.devze.com 2023-04-11 13:26 出处:网络
The problem is probably very simple, but I\'m strugglin开发者_JAVA技巧g because I am new to ELISP.

The problem is probably very simple, but I'm strugglin开发者_JAVA技巧g because I am new to ELISP.

I want to have a keybinding to refile current subtree to subtree TRASH.

I have written the code, which doesn't work, though. Could you please help me to fix it? Thanks in advance!

The code:

(defun org-move-to-trash()
  (org-refile "TRASH") ;; the function fails here because the parameter has to be specified in a different way. But how?
)

(global-set-key (kbd "C-c b") 'org-move-to-trash)


If you're interested in elisp, you can read the source of org-refile to see how to prepare the arguments it expects (it's not straight forward). However, to solve this and many other more general problems, you don't need elisp at all. You need a keyboard macro. See manual.

I'll outline the steps I would take to solve this:

  1. C-x (
  2. C-c C-w TRASH
  3. C-x )
  4. M-x name-last-kbd-macro
  5. org-refile-to-TRASH
  6. C-x b scratch
  7. M-x insert-kbd-macro
  8. org-refile-to-TRASH

You should see:

(fset 'org-refile-to-TRASH
   [?\C-c ?\C-w ?T ?R ?A ?S ?H return])

You can paste this code into your init file, and use org-refile-to-TRASH as a command, exactly like if it were a defun e.g. in global-set-key, M-x, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号