【问题标题】:How to let Org-mode open a link like [[file://file.org]] in current window instead of default in other window?如何让 Org-mode 在当前窗口中打开类似 [[file://file.org]] 的链接,而不是在其他窗口中打开默认链接?
【发布时间】:2013-07-11 10:16:16
【问题描述】:

我希望用[C-c C-o]在当前窗口打开类似[[file://filename.org|filename]]的链接,而不是在其他窗口默认打开。

如何改变这种组织模式的默认行为?

似乎默认[C-u C-c C-o] 是在其他窗口中强制打开链接。

这里有一个类似的问题:How do I keep Emacs org-mode from splitting windows?

【问题讨论】:

    标签: emacs org-mode


    【解决方案1】:

    您需要更改org-link-frame-setup 的值。默认值包含缺点(file . find-file-other-window)。您可以将其替换为(file . find-file)

    【讨论】:

    • 我将其替换为(file . find-file),但很快我发现[C-u C-c C-o] 在当前窗口的某个位置打开了链接也是。我希望保留[C-u C-c C-o] 在其他窗口中打开链接。我不知道该怎么做。我阅读了变量org-link-frame-setup 的文档字符串。你有什么想法吗?
    • 如果您想要使用不同的框架设置策略打开链接的不同命令,您可以通过(let ((org-link-frame-setup whatever-policies)) (org-open-at-point)) 创建它们,然后将其绑定到您选择的组合键。
    • 以下是更新org-link-frame-setup 值的方法:(add-to-list 'org-link-frame-setup '(file . find-file))
    【解决方案2】:

    这是我写的解决方案,灵感来自@juanleon 的回答。它映射C-c C-o 以在当前窗口中打开链接,但保留C-u C-c C-o 的默认行为(在其他窗口中打开)。它不会破坏通用参数函数(当我天真地重新映射 C-u C-c C-o 时会发生这种情况)。

    (defun org-force-open-current-window ()
      (interactive)
      (let ((org-link-frame-setup (quote
                                   ((vm . vm-visit-folder)
                                    (vm-imap . vm-visit-imap-folder)
                                    (gnus . gnus)
                                    (file . find-file)
                                    (wl . wl)))
                                  ))
        (org-open-at-point)))
    ;; Depending on universal argument try opening link
    (defun org-open-maybe (&optional arg)
      (interactive "P")
      (if arg
          (org-open-at-point)
        (org-force-open-current-window)
        )
      )
    ;; Redefine file opening without clobbering universal argumnet
    (define-key org-mode-map "\C-c\C-o" 'org-open-maybe)
    

    【讨论】:

      猜你喜欢
      • 2010-09-11
      • 2015-02-09
      • 2012-01-29
      • 2020-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多