org mode的refile如何应对相同名称的多个entry

我在使用org mode的refile功能时,假如当前文件的不同位置,有两个相同名称的entry,例如都是叫note。现在refile会自动选择第一个位置。印象中之前这种情况时,refile会出现一个列表,列出相同entry的完整路径,让我手动选择想refile到哪个位置。请问这个列表应该如何调出来呢?

你可能想要

(setq org-outline-path-complete-in-steps nil
      org-refile-use-outline-path 'file)
2 个赞

我试过,没有效果。比如说,我当前打开的org文件,是这样的

* entry1

** note

* entry2

** entry3

*** note

现在refile到note,会自动到第一个note,也就是entry1\note\这个位置。我记得之前,如果碰到重复名称,会跳出一个minibuf,出现一个列表,是entry1\note\,entry1\entry2\note\这样的选项,让我可以选择到哪个位置。

没错没错,就是这种效果。请问你的完整设置是什么样的呢?我这边不是这样的效果。我是用的org mode 9.2.6,emacs 26.3。这是我的设置

(setq org-refile-targets (quote ((nil :maxlevel . 9)

                             (org-agenda-files :maxlevel . 9))))

(setq org-refile-active-region-within-subtree t)

(setq org-outline-path-complete-in-steps nil)

(setq org-refile-use-outline-path 'file)

我测试了一下,可以看到文件中有三个位置有aa这个entry,但是refile,输入aa后回车,显示no match。如果把org-refile-use-outline-path设置成nil,可以refile,但是只能自动refile到第一个aa的位置。请问这是哪里出问题了呢,非常感谢。

考虑下换个更新的 Org 或者 Emacs

org-refile-use-outline-path was added, or its default value changed, in Org version 9.6.

我看了一下更新日志,这个函数在5.XX版本已经有了。按理说9.2.6是用这个功能的。 这个功能是对应这个参数对面?

1 个赞

试了org mode 9.7.21,还是相同的问题。就是搞不懂,这是哪里设置的问题。

可以 emacs -Q 排除一下,或者二分法试试排除。

刚才用emacs -Q启动,试了一下,问题依然存在。所以我怀疑是emacs本身的问题,等下载一个新的emacs试一下。

用emacs -Q启动后有相同的问题。但我有了新的发现,当我refile时,如果不输入任何文本,直接按空格,就会出现这样的minibuffer。但是只能鼠标选择,此时输入任何文本也没法对其筛选。似乎这个功能是emacs自带的叫completion的功能。

这个效果跟按Tab一样,不过看起来org-refile-use-outline-path没生效,不然前面应该是类似xxx.org/xx/xx这些选项。

看起来像windows,下个官方的pretest https://mirrors.tuna.tsinghua.edu.cn/gnu-alpha/emacs/pretest/windows/emacs-30/emacs-30.0.93.zip 升级一下比较好。

现在debian 要变成oldstable的stable都28.2了 :grinning:

非常感谢大家的回复。我尝试了emacs 29.4和它自带的org mode 9.6。即使使用空白.emacs文件的情况下,问题依然没有解决。当org-refile-use-outline-path设置为nil时,可以refile但无法解决重复值。当org-refile-use-outline-path设置是file、t等值时,会显示no match,造成无法refile。确实不知道该怎么解决了,只能先设置成nil,至少refile还能发挥作用。

空白的怎么可能加载 org mode. 好好检查一下 org mode 相关配置吧

emacs已经自带org mode了,直接打开.org文件就到了org mode模式。

相关配置就这些,好久之前抄的了

maybe 需要配下 completion,emacs -Q 也装个 vertico 啥的,最近比较忙,没空帮忙看为啥不行

抱歉说的不对。我试了 emacs -q,的确加载了 org mode。用 refile 的效果就是你在这个图里的效果 org mode的refile如何应对相同名称的多个entry - #12,来自 xiaoa****

说明想要实现带路径的,的确需要补全package,应该是补全影响了行为

看了一下我用的 doom emacs 带的配置:

(setq org-refile-targets
        '((nil :maxlevel . 3)
          (org-agenda-files :maxlevel . 3))
        ;; Without this, completers like ivy/helm are only given the first level of
        ;; each outline candidates. i.e. all the candidates under the "Tasks" heading
        ;; are just "Tasks/". This is unhelpful. We want the full path to each refile
        ;; target! e.g. FILE/Tasks/heading/subheading
        org-refile-use-outline-path 'file
        org-outline-path-complete-in-steps nil)