mirror of
https://github.com/golang/go
synced 2024-11-26 23:51:29 -07:00
misc/emacs: add support for ff-find-other-file
c-mode classically uses ff-find-other-file to toggle between headers and implementation. For Go it seemingly makes sense to jump between implementation and test. While there's no enforced mapping of file names for tests, the mapping in this CL seems to be very common at least throughout the standard library, and ff-find-other-file fails gracefully when the mapping doesn't apply. LGTM=adonovan R=adonovan CC=golang-codereviews https://golang.org/cl/65750044
This commit is contained in:
parent
0d9b9aafd5
commit
cce25c88ce
@ -7,6 +7,7 @@
|
|||||||
(require 'cl)
|
(require 'cl)
|
||||||
(require 'etags)
|
(require 'etags)
|
||||||
(require 'ffap)
|
(require 'ffap)
|
||||||
|
(require 'find-file)
|
||||||
(require 'ring)
|
(require 'ring)
|
||||||
(require 'url)
|
(require 'url)
|
||||||
|
|
||||||
@ -168,6 +169,13 @@ from https://github.com/bradfitz/goimports."
|
|||||||
:type 'string
|
:type 'string
|
||||||
:group 'go)
|
:group 'go)
|
||||||
|
|
||||||
|
(defcustom go-other-file-alist
|
||||||
|
'(("_test\\.go\\'" (".go"))
|
||||||
|
("\\.go\\'" ("_test.go")))
|
||||||
|
"See the documentation of `ff-other-file-alist' for details."
|
||||||
|
:type '(repeat (list regexp (choice (repeat string) function)))
|
||||||
|
:group 'go)
|
||||||
|
|
||||||
(defface go-coverage-untracked
|
(defface go-coverage-untracked
|
||||||
'((t (:foreground "#505050")))
|
'((t (:foreground "#505050")))
|
||||||
"Coverage color of untracked code."
|
"Coverage color of untracked code."
|
||||||
@ -561,6 +569,8 @@ recommended that you look at goflymake
|
|||||||
(set (make-local-variable 'go-dangling-cache) (make-hash-table :test 'eql))
|
(set (make-local-variable 'go-dangling-cache) (make-hash-table :test 'eql))
|
||||||
(add-hook 'before-change-functions (lambda (x y) (setq go-dangling-cache (make-hash-table :test 'eql))) t t)
|
(add-hook 'before-change-functions (lambda (x y) (setq go-dangling-cache (make-hash-table :test 'eql))) t t)
|
||||||
|
|
||||||
|
;; ff-find-other-file
|
||||||
|
(setq ff-other-file-alist 'go-other-file-alist)
|
||||||
|
|
||||||
(setq imenu-generic-expression
|
(setq imenu-generic-expression
|
||||||
'(("type" "^type *\\([^ \t\n\r\f]*\\)" 1)
|
'(("type" "^type *\\([^ \t\n\r\f]*\\)" 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user