Can I configure ff-find-other-file to switch between tests and implementations?

Whenever I have to edit C ++ code, I use ff-find-other-fileto switch between the header and implementation files. Can I use it for Python files to switch between implementations and tests? For example, if I'm in foo.py, I would like to be able to switch to foo_test.py.

+5
source share
2 answers

You really want to install ff-other-file-alist(and perhaps also ff-search-directories). These variables are automatically buffered, so you can safely set them in mode.

cc-other-file-alist - C/++, ff-other-file-alist.

, , alist :

'(("_test\\.py$" (".py"))
  ("\\.py$" ("_test.py")))

, , .py . , foo_test.py foo_test_test.py .....

. :

doc.foo, , emacs doc.bar

:

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

(defun my-python-mode-hook ()
  "My python customisations."
  (setq ff-search-directories '(".")
        ff-other-file-alist '(("_test\\.py$" (".py"))
                              ("\\.py$" ("_test.py")))))
+3

.macs cc-other-file-alist, :

(setq cc-other-file-alist
  `(("\\.py$" ("_test.py"))))
+1

All Articles