-->

如果我打开doc.foo文件,我想emacs的查找和打开文件doc.bar在同一文件夹(If I o

2019-09-17 23:13发布

具体这个问题在乳胶(auctex)工作时,我出现的时候,但我认为它必须有一个一般的Emacs的解决方案。

对每一个doc.tex文件,我在同一个文件夹关联,并经常编辑doc.sty文件。

有没有一种办法,每当我打开doc.tex文件,我可以有Emacs的打开文件夹中的文件doc.sty? 我不是在所有的elisp精通,所以很简单的东西---它并不需要是健壮的代码:它可以假设这两个文件被命名为DOC的工作*,并且同时存在。

Answer 1:

看看的评论为:
MX find-library RET find-file RET

这不正是你问什么,但它是打开相关文件的内置解决方案。 只需绑定一个关键ff-find-other-file (或ff-find-related-file ,如果你喜欢的别名),你可以来回切换两个文件之间轻松。

特别是,请参阅:

  • CH v ff-other-file-alist RIGHT
  • CH v ff-search-directories RIGHT

因此,像这样:

(add-hook 'latex-mode-hook 'my-latex-mode-hook)

(defun my-latex-mode-hook ()
  "My LaTeX customisations."
  (setq ff-search-directories '(".")
        ff-other-file-alist  '(("\\.tex$" (".sty"))
                               ("\\.sty$" (".tex"))))
  (local-set-key (kbd "C-c f") 'ff-find-other-file))


文章来源: If I open doc.foo file, I want emacs to look for and open doc.bar file in the same folder