在org mode中重新整理列表项

4
我一直在试图提升我的Org技能。其中一个任务是整理清单项。我通常喜欢使用清单项,主要原因是-不会弄乱我的内容视图,并且可以得到真正的大纲,考虑到我有多少个任务。
然而,当我尝试将使用捕获系统创建的列表项整理时,我会出现错误-我不被允许这样做,因为这“没有意义”。
有没有办法覆盖这种行为?
编辑: 目前,我只能整理条目(即标题),然后手动将它们转换为列表项。我想知道是否有更好的解决方案...
我在org-capture.el中找到了这个函数:
(defun org-capture-refile ()
  "Finalize the current capture and then refile the entry.
Refiling is done from the base buffer, because the indirect buffer is then
already gone.  Any prefix argument will be passed to the refile command."
  (interactive)
  (unless (eq (org-capture-get :type 'local) 'entry)
    (error
     "Refiling from a capture buffer makes only sense for `entry'-type templates"))
  (let ((pos (point))
    (base (buffer-base-buffer (current-buffer)))
    (org-refile-for-capture t))
    (org-capture-finalize)
    (save-window-excursion
      (with-current-buffer (or base (current-buffer))
    (save-excursion
      (save-restriction
        (widen)
        (goto-char pos)
        (call-interactively 'org-refile)))))))

我该如何去除(unless (eq (org-capture-get :type 'local) 'entry)这一部分,以使其生效?

编辑:12年10月23日

到目前为止,我已经成功让它工作了:

(defun narrow-and-reveal ()
    "Narrow and reveal all content"
    (org-narrow-to-subtree)
    (org-show-subtree)
    )
(defun widen-and-outline ()
    "Widen and move to beginning of file"
    (widen)
    (beginning-of-buffer)
    (org-overview)
    (org-content)
    )
(defun org-goto-symbol ()
  "Will navigate to the symbol at the current point of the cursor"
  (widen-and-outline)
  (interactive)
  (let ((current-prefix-arg 4)) ;; emulate C-u
    (call-interactively 'org-refile)) ;; invoke org-refile interactively
  (narrow-and-reveal)
  )
(defun custom-org-prompt-headline ()
  (org-goto-symbol) ;; invoke org-refile interactively
  (end-of-buffer))
(setq org-capture-templates`(
    ("t" "ToDo" item (file+function (concat org-directory "ToDo.org") custom-org-prompt-headline))))

但是在输入列表项之前,它会提示我文件中的节,我觉得有些分散注意力。我希望能有重新归档列表项的选项。我想这应该不难实现,是吗?


既然你已经表达得很清楚了,为什么不使用C-c C-w而不是在写完笔记后使用C-c C-c来重新归档,这难道不是你的解决方案吗?虽然我不擅长elisp,但我不明白你试图实现的功能与现有功能的区别。 - Nikana Reklawyks
这实际上是我的问题 - 为什么我不能重新归档列表项?由于某种我无法完全理解的原因,org-mode 不允许我这样做。 - Devon Ville
换句话说(我想),有没有一种方法可以使用refile(具有在所有org缓冲区中快速搜索标题的能力),而不是使用标题,只需一行文本即可。我个人认为,这对于在现有标题下复制笔记非常有用。 - studgeek
2个回答

1

实际上,有一种更好的方法:为什么不使用捕获模板

基本上,你只需要定义你喜欢的模板,比如说:

(setq org-capture-templates
 '(("t" "something" item (file+olp "~/path/to/you/file.org" "Header" "Subheader")
        "- %?\n  %i")
   ("n" "notes" checkitem (file+olp "~/somewhere/notes.org" "Notes")
        "- [ ] %?\n")))

然后,在使用时,调用(M-x) org-capture(如果您遵循标准自定义,则绑定为C-cc),在已经是列表项模板中输入您的笔记,按C-cC-c,完成!

所有细节都在手册中(设置语法, 自动扩展元素…)


文件+olp帮助我使用某个捕获模板,但你的答案不是我想要的。我来详细说明一下:我有一个待办事项文件。为了简单起见,假设我有两个标题:“计算机”和“家庭”。我创建一个新的列表项,并希望它位于“计算机”子树中。我可能可以创建2个捕获模板,每个标题一个,但如果我有数十个标题和子标题怎么办?我研究了自定义函数以找到特定位置,但无法创建适合我的东西... - Devon Ville
@EladR:我的回答明显是沿着“为你经常需要推送内容的每个标题制作一个模板”的方向,假设这些标题不是太多(我有大约10个模板,但在成百上千个子标题中仍然非常方便)。 - Nikana Reklawyks
虽然捕获模板对于将文本捕获到特定位置很有用,但它们不具备重定向搜索的灵活性,这正是我认为他正在寻找的(我知道这就是我正在寻找的:)。 - studgeek

1
通过查看邮件列表档案,到目前为止我发现的最佳解决方案是使用`org-refile-active-region-within-subtree`选项。它使得refile可以移动任意文本区域,但在移动之前也会将该文本转换为标题(使用`org-toggle-heading`)。
所以至少文本被移动了,但可能不完全是您想要的(它不再是一个列表)。这可能是一个很好的起点,以寻找更好的解决方案。也许可以在移动文本后运行`org-toggle-heading`来获得更好的效果。
以下是内联文档:
非nil表示也在子树中refile活动区域。 默认情况下,如果区域中不包含一组子树,则`org-refile`不允许refiling区域,但有时进行这样做可能很方便:在这种情况下,区域的第一行将转换为标题,然后再进行refiling。
我在这个主题中找到了它- http://lists.gnu.org/archive/html/emacs-orgmode/2011-08/msg00535.html

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接