Commit b302d68e authored by Dominik Honnef's avatar Dominik Honnef Committed by Sameer Ajmani

misc/emacs: Greatly improve go-mode for Emacs.

The original go-mode is plagued with odd behaviour, lack of
behaviour typical to modes in Emacs and bugs.

This change rewrites great parts of go-mode (basically only
keeping the gofmt and godoc functions).

Additionally it adds new features such as manipulating package
imports.

For more information please see
https://groups.google.com/group/golang-nuts/browse_frm/thread/3a9d6dae3369c0b5/1efe65e2f7afb190

Fixes #3618.
Fixes #4240.
Fixes #4322.
Fixes #4671.
Fixes #4726.

R=golang-dev, fullung, sameer, cw, arthur, proppy, adonovan, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/7314113
parent 6c2cbdb1
;;; go-mode-load.el --- Major mode for the Go programming language ;;; go-mode-load.el --- automatically extracted autoloads
;;; Commentary: ;;; Commentary:
;; To install go-mode, add the following lines to your .emacs file: ;; To install go-mode, add the following lines to your .emacs file:
;; (add-to-list 'load-path "PATH CONTAINING go-mode-load.el" t) ;; (add-to-list 'load-path "PATH CONTAINING go-mode-load.el" t)
;; (require 'go-mode-load) ;; (require 'go-mode-load)
;;
;; After this, go-mode will be used for files ending in '.go'. ;; After this, go-mode will be used for files ending in '.go'.
;;
;; To compile go-mode from the command line, run the following ;; To compile go-mode from the command line, run the following
;; emacs -batch -f batch-byte-compile go-mode.el ;; emacs -batch -f batch-byte-compile go-mode.el
;;
;; See go-mode.el for documentation. ;; See go-mode.el for documentation.
;;
;;; Code:
;; To update this file, evaluate the following form ;; To update this file, evaluate the following form
;; (let ((generated-autoload-file buffer-file-name)) (update-file-autoloads "go-mode.el")) ;; (let ((generated-autoload-file buffer-file-name)) (update-file-autoloads "go-mode.el"))
;;; Code:
;;;### (autoloads (gofmt-before-save gofmt go-mode) "go-mode" "go-mode.el" ;;;### (autoloads (go-download-play godoc gofmt-before-save go-mode)
;;;;;; (19917 17808)) ;;;;;; "go-mode" "go-mode.el" (20767 50749))
;;; Generated autoloads from go-mode.el ;;; Generated autoloads from go-mode.el
(autoload 'go-mode "go-mode" "\ (autoload 'go-mode "go-mode" "\
Major mode for editing Go source text. Major mode for editing Go source text.
This provides basic syntax highlighting for keywords, built-ins, This mode provides (not just) basic editing capabilities for
functions, and some types. It also provides indentation that is working with Go code. It offers almost complete syntax
\(almost) identical to gofmt. highlighting, indentation that is almost identical to gofmt,
proper parsing of the buffer content to allow features such as
navigation by function, manipulation of comments or detection of
strings.
Additionally to these core features, it offers various features to
help with writing Go code. You can directly run buffer content
through gofmt, read godoc documentation from within Emacs, modify
and clean up the list of package imports or interact with the
Playground (uploading and downloading pastes).
The following extra functions are defined:
- `gofmt'
- `godoc'
- `go-import-add'
- `go-remove-unused-imports'
- `go-goto-imports'
- `go-play-buffer' and `go-play-region'
- `go-download-play'
If you want to automatically run `gofmt' before saving a file,
add the following hook to your emacs configuration:
\(add-hook 'before-save-hook 'gofmt-before-save)
If you're looking for even more integration with Go, namely
on-the-fly syntax checking, auto-completion and snippets, it is
recommended to look at goflymake
\(https://github.com/dougm/goflymake), gocode
\(https://github.com/nsf/gocode) and yasnippet-go
\(https://github.com/dominikh/yasnippet-go)
\(fn)" t nil) \(fn)" t nil)
(add-to-list 'auto-mode-alist (cons "\\.go$" #'go-mode)) (add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode))
(autoload 'gofmt "go-mode" "\
Pipe the current buffer through the external tool `gofmt`.
Replace the current buffer on success; display errors on failure.
\(fn)" t nil)
(autoload 'gofmt-before-save "go-mode" "\ (autoload 'gofmt-before-save "go-mode" "\
Add this to .emacs to run gofmt on the current buffer when saving: Add this to .emacs to run gofmt on the current buffer when saving:
(add-hook 'before-save-hook #'gofmt-before-save) (add-hook 'before-save-hook 'gofmt-before-save).
Note that this will cause go-mode to get loaded the first time
you save any file, kind of defeating the point of autoloading.
\(fn)" t nil) \(fn)" t nil)
;;;*** (autoload 'godoc "go-mode" "\
Show go documentation for a query, much like M-x man.
\(fn QUERY)" t nil)
(autoload 'go-download-play "go-mode" "\
Downloads a paste from the playground and inserts it in a Go
buffer. Tries to look for a URL at point.
\(fn URL)" t nil)
;;;***
(provide 'go-mode-load) (provide 'go-mode-load)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; go-mode-load.el ends here
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment