通过键盘重新指定给给定的子树 [英] refiling to a given subtree by a keybinding

查看:103
本文介绍了通过键盘重新指定给给定的子树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题可能非常简单,但我很挣扎,因为我是ELISP的新手。

The problem is probably very simple, but I'm struggling because I am new to ELISP.

我想要一个键绑定来将当前子树复制到子树TRASH

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!

代码:

(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)


推荐答案

如果您对elisp感兴趣,您可以阅读org-refile的来源,看看如何准备其期望的参数(不直接) 。但是,为了解决这个问题,还有很多其他更普遍的问题,你根本不需要elisp。你需要一个键盘宏。请参阅手册

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. Cx(

  2. Cc Cw TRASH

  3. Cx)

  4. Mx name-last-kbd-macro

  5. org-refile-to-TRASH

  6. Cx b scratch

  7. Mx insert-kbd-macro

  8. org-refile-to-TRASH

  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

你应该会看到:

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

您可以将此代码粘贴到您的init文件中,并使用 org-refile-to-TRASH 作为一个命令,完全像一个defun例如在 global-set-key M-x 等。

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.

这篇关于通过键盘重新指定给给定的子树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆