14

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

如何更改此 Org-mode 默认行为?

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

这里有一个类似的问题:如何防止 Emacs org-mode 拆分窗口?

4

2 回答 2

18

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

于 2013-07-11T11:12:26.057 回答
4

这是我写的解决方案,灵感来自@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)
于 2018-04-16T10:50:29.847 回答