【问题标题】:Refile list items in org mode在 org 模式下重新归档列表项
【发布时间】:2012-10-15 21:53:27
【问题描述】:

我一直在尝试改进我的 org-fu,我的任务之一是重新归档列表项。 出于各种原因,我通常更喜欢使用列表项(主要是 - 考虑到我的任务量,不要乱扔我的 CONTENT 视图,并且有一个真实的大纲)。

但是,可惜,当我尝试重新提交使用捕获系统创建的列表项时,我收到一个错误 - 我不允许这样做,因为它“没有意义”。

有没有办法覆盖这种行为?

编辑: ATM 我只设法重新归档条目(即标题),然后手动将它们转换为列表项。我认为有比这更好的解决方案...

我在 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)的部分去掉才能生效?

编辑:23.10.12

到目前为止,我设法让它工作:

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

但在输入列表项本身之前,它会提示我输入文件中的部分,我觉得这有点让人分心。 我只想选择重新归档列表项。我无法想象它应该那么难实现..是吗?

【问题讨论】:

  • 既然你已经说清楚了,为什么refiling 不是你的解决方案,在你写下注释后使用C-c C-w 而不是C-c C-c?我不擅长 elisp,但我不明白你想要实现的现有功能没有涵盖的内容。
  • 这实际上是我的问题 - 为什么我不能重新归档列表项?由于某种原因我无法完全理解,org-mode 不允许我这样做。
  • 换一种说法(我认为),有没有办法只用一行文本而不是标题来使用 refile(能够在所有 org 缓冲区中快速搜索标题)。我个人会发现这对于在现有标题下复制笔记非常有用。

标签: emacs org-mode


【解决方案1】:

确实,更好的方法:为什么不使用capture templates

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

(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(如果您关注standard customizations,则绑定到C-cc),在中输入您的注释已经是一个列表项模板,C-cC-c,你就完成了!

所有细节都在manualsettings syntaxautomagically expanding elements...)

【讨论】:

  • file+olp 帮助我使用了某个捕获模板,但您的答案不是我想要的。我会详细说明:我有一个待办事项文件。为了简单起见,假设我有两个标题:“计算机”和“家庭”。我创建了一个新列表项并希望它位于“计算机”子树中。我可能可以创建 2 个捕获模板,每个标题一个,但是如果我有数十个标题和副标题怎么办?我查看了自定义功能以找到特定位置,但无法创建适合我的东西...
  • @EladR:我的回答很明显是“为每个标题制作一个模板,您经常想向其发送内容”,理所当然地认为这些不会太多(我确实有大约 10 个模板,但在数百个子标题中仍然非常方便。)
  • 虽然捕获模板非常适合将文本捕获到特定位置,但它们并没有提供我认为他正在寻找的重新文件搜索的灵活性(我知道这就是我正在寻找的为:)。
【解决方案2】:

在浏览了邮件列表档案之后,到目前为止我找到的最佳解决方案是org-refile-active-region-within-subtree 选项。它使 refile 能够移动任意文本区域,但它在移动文本之前也会将该文本转换为标题(使用 org-toggle-heading)。

所以至少文本被移动了,但它可能不是 100% 你想要的(它不再是一个列表)。尽管寻找更好的解决方案,但它可能是一个很好的起点。也许通过在移动文本后运行org-toggle-heading

这是内联文档:

非零意味着也重新归档子树中的活动区域。

默认情况下 `org-refile' 不允许重新归档区域,如果它们不允许的话 包含一组子树,但这样做可能很方便 有时:在这种情况下,区域的第一行被转换为 重新提交前的标题。

我在这个帖子中找到了它 - http://lists.gnu.org/archive/html/emacs-orgmode/2011-08/msg00535.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多