1
0
mirror of https://github.com/golang/go synced 2024-11-12 10:30:23 -07:00
Commit Graph

82 Commits

Author SHA1 Message Date
Rui Ueyama
3d63ec240e misc/emacs: ignore backquote in comment or string
go-mode on Emacs 23 wrongly recognizes a backquote in a comment or
a string as a start of a raw string literal. Below is an example
that go-mode does not work well. This patch is to fix that issue.

  // `
  var x = 1
  // `

LGTM=dominik.honnef
R=golang-codereviews, dominik.honnef, adonovan
CC=golang-codereviews
https://golang.org/cl/84900043
2014-04-09 12:28:27 -04:00
Rui Ueyama
5f5e280e14 misc/emacs: do not highlight built-in function if not followed by '('
Name of built-in function is not reserved word in Go, and you can
use it as variable name. "new" is often used as local variable, for
instance.

This patch is to apply font-lock-builtin-face only when built-in
function name is followed by '(', so that it doesn't highlight
non-function variable that happen to have the same name as built-in
function.

LGTM=dominik.honnef
R=golang-codereviews, dominik.honnef, adonovan
CC=golang-codereviews
https://golang.org/cl/79260043
2014-03-27 17:35:07 -04:00
Rui Ueyama
444dd26bf4 misc/emacs: handle backslash in raw string in Emacs 23
Go-mode in Emacs 23 does not recognize a backslash followed
by a backquote as end of raw string literal, as it does not
support syntax-propertize-function which Go-mode uses to
remove special meaning from backslashes in ``.

This patch provides a fallback mechanism to do the same thing
using font-lock-syntactic-keywords, which is supported by
Emacs 23.

LGTM=dominik.honnef
R=golang-codereviews, dominik.honnef
CC=adonovan, golang-codereviews
https://golang.org/cl/78730048
2014-03-27 15:22:52 -04:00
Dominik Honnef
e9ba9470bc misc/emacs: correctly fontify methods when go-fontify-function-calls is nil
We were fontifying the wrong part of method declarations

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/66120043
2014-03-12 11:02:42 -04:00
Dominik Honnef
cce25c88ce 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
2014-02-18 22:23:55 -05:00
Dominik Honnef
0d9b9aafd5 misc/emacs: actually use point argument that is passed to godef--call
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/62600043
2014-02-18 21:51:47 -05:00
Dominik Honnef
79653e4121 misc/emacs: fontify type switch correctly
Require at least one space after "type" and do not fontify closing
parenthesis of type switch as a type.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/37720050
2014-01-06 11:11:03 -05:00
Dominik Honnef
81cab4c3d3 misc/emacs: minor cleanups
R=adonovan
CC=golang-codereviews
https://golang.org/cl/23290044
2014-01-06 10:48:06 -05:00
Dominik Honnef
597b9c0d19 misc/emacs: various cleanups
- Use #' for function symbols
- Remove unused variables
- Use declare-function to shut up byte compiler

This is identical to CL 19010044 with one exception: Making sure
it doesn't break on Emacs 22.1

R=adonovan, bradfitz, shendaras
CC=golang-dev
https://golang.org/cl/20100043
2013-11-08 15:23:12 -05:00
Sameer Ajmani
19dda5cd74 emacs: allow users to customize the gofmt command, in particular, to use goimports instead.
R=adonovan
CC=golang-dev
https://golang.org/cl/23680043
2013-11-08 11:31:44 -05:00
Alan Donovan
75d5c4af71 undo CL 19010044 / dbcd720e5396
bradfitz reports:
> It breaks go-mode on GNU Emacs 22.1.1 as ships with OS X 10.8.6.

««« original CL description
misc/emacs: various cleanups

- Use #' for function symbols
- Remove unused variables
- Use declare-function to shut up byte compiler

R=adonovan
CC=golang-dev
https://golang.org/cl/19010044

»»»

R=bradfitz
CC=golang-dev
https://golang.org/cl/19640043
2013-10-29 22:17:14 -04:00
Dominik Honnef
22b3822da7 misc/emacs: various cleanups
- Use #' for function symbols
- Remove unused variables
- Use declare-function to shut up byte compiler

R=adonovan
CC=golang-dev
https://golang.org/cl/19010044
2013-10-29 13:07:42 -04:00
Dominik Honnef
3b0e6c21ae misc/emacs: support godef-jump on import statements
The newest version of godef supports jumping to a package's source
directory if point is on an import statement.

R=adonovan
CC=golang-dev
https://golang.org/cl/18230043
2013-10-29 11:14:56 -04:00
Dominik Honnef
580ea8b5fd misc/emacs: handle empty "import ()" in go-goto-imports
R=adonovan
CC=golang-dev
https://golang.org/cl/14454058
2013-10-22 12:35:04 -04:00
Dominik Honnef
950c284b11 misc/emacs: send correct content-length to the playground
R=adonovan
CC=golang-dev
https://golang.org/cl/14548049
2013-10-10 16:49:19 -04:00
Dominik Honnef
47bb44fd5b misc/emacs: don't treat (foo)(bar) as a function call when preceded by a word character.
Fixes #6531.

R=adonovan
CC=golang-dev
https://golang.org/cl/14523043
2013-10-10 16:30:20 -04:00
Dominik Honnef
989a63eb0b misc/emacs: find unused imports where path and package name differ
The Go compiler emits extra information for this case:

imported and not used: "sandbox/foo_bar" as bar

R=adonovan
CC=golang-dev
https://golang.org/cl/14111043
2013-10-07 13:08:26 -04:00
Dominik Honnef
b7a609b660 misc/emacs: use built-in buffer-base-buffer instead of own variable
R=adonovan
CC=golang-dev
https://golang.org/cl/13476043
2013-09-06 16:08:11 -04:00
Alan Donovan
264b73b3f2 misc/emacs: allow users to customize path of 'go' tool.
Some users have multiple Go development trees and invoke the
'go' tool via a wrapper that sets GOROOT and GOPATH based on
the current directory.  Such users should customize go-command
to point to the wrapper script.

R=dominik.honnef
CC=golang-dev
https://golang.org/cl/13233043
2013-08-27 09:47:58 -04:00
Aaron France
dccf651b24 misc/emacs: Detect stale coverage reports
When the coverage report file is older than the file we're
showing the coverage report for, then we show a simple message
to state this fact.

R=adonovan, dominik.honnef, bradfitz
CC=golang-dev
https://golang.org/cl/12919044
2013-08-19 16:32:00 -04:00
Dominik Honnef
29794b77dd misc/emacs: godef: print the entire description, not just the first line
When identifying structs or interfaces we really want to know
their makeup, not just their name.

R=adonovan
CC=golang-dev
https://golang.org/cl/13042043
2013-08-16 13:03:40 -04:00
Dominik Honnef
0b25ba9ced misc/emacs: allow godef to work in coverage buffers
Jumps to the same file will use the original buffer, not the
coverage buffer. Making it work for the coverage buffer isn't
worth the trouble, especially because it would break as soon as
you jump to a different file and back.

Use error instead of message so it actually terminates

R=adonovan
CC=golang-dev
https://golang.org/cl/13041043
2013-08-16 00:22:38 -04:00
Dominik Honnef
c320cf85d9 misc/emacs: do not use any free variables
R=adonovan
CC=golang-dev
https://golang.org/cl/12744046
2013-08-16 00:06:19 -04:00
Dominik Honnef
5f199f2d5a misc/emacs: when defining prog-mode, define it like GNU Emacs 24 would
Fixes #6156.

R=adonovan
CC=golang-dev
https://golang.org/cl/13035043
2013-08-15 20:40:38 -07:00
Dominik Honnef
3495aa298d misc/emacs: Refactor coverage code into multiple functions
Also fixes color gradient being calculated against the wrong maximum.

R=adonovan
CC=golang-dev
https://golang.org/cl/12968043
2013-08-15 22:37:16 -04:00
Dominik Honnef
3fe9b11cbb misc/emacs: Allow go-coverage to work in existing coverage buffers by reusing previous arguments
R=golang-dev, adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/12721043
2013-08-14 16:03:44 -07:00
Dominik Honnef
4a0d06c4c5 misc/emacs: add support for mode=count coverage
Use the same algorithm that go tool cover uses when producing HTML
output to render coverage intensity.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12712043
2013-08-09 14:42:43 -07:00
Dominik Honnef
8a90456349 misc/emacs: clear previous overlays before adding new ones
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12578044
2013-08-09 08:56:15 -07:00
Dominik Honnef
6e5f4bab90 misc/emacs: Add support for code coverage output of go test
Renders code coverage as an overlay, replicating the look of the
HTML that go tool cover produces.

Also some cleanups.

R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/12684043
2013-08-08 15:54:26 -07:00
Dominik Honnef
6e37bc1eec misc/emacs: replace our go-goto-opening-parenthesis with backward-up-list
R=adonovan
CC=golang-dev
https://golang.org/cl/11524045
2013-07-24 13:48:04 -04:00
Dominik Honnef
9c6fecc2da misc/emacs: Make godef-jump behave more like find-tag by supporting pop-tag-mark
Push point to the find-tag marker ring to support pop-tag-mark.

Fixes #5804.

R=adonovan
CC=golang-dev
https://golang.org/cl/11457044
2013-07-24 11:20:53 -04:00
Dominik Honnef
58ce655fd2 misc/emacs: Add godef-jump-other-window
This will behave like similar "*-other-window" functions in Emacs.

Default key bind is C-x 4 C-c C-j – while awkward, it follows both
the convention for other-window functions and the convention for
not using user- or emacs-reserved keys.

R=golang-dev, adonovan
CC=golang-dev
https://golang.org/cl/10707045
2013-07-17 18:16:44 -04:00
Charles Lee
d9f5c64f6e misc/emacs: fix godef-jump on Windows.
Fixes #5555.

R=adonovan, dominik.honnef, iant
CC=gobot, golang-dev
https://golang.org/cl/9762045
2013-06-26 13:59:25 -07:00
Dominik Honnef
4e15dbe082 misc/emacs: Do not modify kill ring when programmatically deleting text
Operations like gofmt and go-remove-unused-imports delete entire
lines of text. Previously this put them on the kill-ring,
negatively affecting user experience.

R=adonovan
CC=gobot, golang-dev
https://golang.org/cl/9605043
2013-05-23 10:19:03 -07:00
Dominik Honnef
72b14cbb75 misc/emacs: Add support for methods with unnamed receiver
This fixes fontification, navigation and indentation for methods
of the form `func (Foo) Bar...`

R=adonovan
CC=gobot, golang-dev
https://golang.org/cl/8951043
2013-05-14 20:23:35 -07:00
Dominik Honnef
0104cea6c8 misc/emacs: Enable compilation-mode for gofmt error buffer before displaying it.
Some packages, like popwin.el, change display behaviour based on
the buffer's mode, so we should enable compilation-mode before
displaying the buffer.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8155043
2013-03-30 09:54:08 -07:00
Dominik Honnef
4ad1a87f85 misc/emacs: Derive mode from prog-mode if possible
R=golang-dev, bradfitz
CC=adonovan, cw, golang-dev, patrick.allen.higgins
https://golang.org/cl/7956044
2013-03-25 08:58:13 -07:00
Dominik Honnef
c7ad7a1af4 misc/emacs: Kill gofmt error buffer if the buffer was formatted correctly already.
R=adonovan, cw, patrick.allen.higgins, bradfitz
CC=golang-dev
https://golang.org/cl/7844045
2013-03-21 20:03:27 -07:00
Dominik Honnef
24f476409c misc/emacs: Add support for godef
godef[1][2] is a third party tool for printing information about
expressions, especially the location of their definition. This can be
used to implement a "jump to definition" function. Unlike
cross-language solutions like ctags, godef does not require an index,
operates on the Go AST instead of symbols and works across packages,
including the standard library.

This patch implements two new public functions: godef-describe (C-c
C-d) and godef-jump (C-d C-j). godef-describe describes the expression
at point, printing its type, and godef-jump jumps to its definition.

[1]: https://code.google.com/p/rog-go/source/browse/exp/cmd/godef/
[2]: go get code.google.com/p/rog-go/exp/cmd/godef

R=adonovan, cw, patrick.allen.higgins, sameer
CC=golang-dev
https://golang.org/cl/7781043
2013-03-19 11:29:28 -04:00
Dominik Honnef
69eb345727 misc/emacs: Fix indentation for code following multiline function declarations
Correctly indent the body of functions that have been declared
over multiple lines. See http://play.golang.org/p/MHMwNDbFyf for
an example.

Previously, the body of the function would be indented as deep as
the continuation line of the function declaration. Now it gets
indented as deep as the func keyword.

R=adonovan, cw, patrick.allen.higgins
CC=golang-dev
https://golang.org/cl/7628043
2013-03-12 21:37:18 -07:00
Dominik Honnef
77ddbf1ff0 misc/emacs: Rewrite gofmt to use own function for applying patch instead of using diff-mode.
Instead of relying on gofmt's diff output (which is a unified
    diff), we manually invoke diff -n and produce an RCS format diff,
    which can easily be parsed in Emacs, with the go--apply-rcs-patch
    function.

    This fixes undocumented issues with the old implementation such as
    skipping over hunks of changes, and it fixes the documented issue
    of not being able to handle file names that include whitespace.

    It can also apply the patch on a buffer that has no file name
    attached at all.

    Last but not least, it greatly simplifies the gofmt function
    itself.

Fixes #4766.
Fixes #4475.

R=adonovan, cw, patrick.allen.higgins, sameer
CC=golang-dev
https://golang.org/cl/7516046
2013-03-07 13:12:37 -05:00
Dominik Honnef
cf8434fa31 misc/emacs: Add compatibility for GNU Emacs 23 and XEmacs >=21.5.32
This CL adds compatibility for GNU Emacs 23 (fixing fontification
issues) and XEmacs >=21.5.32 (fixing a lot of issues). Earlier
versions of XEmacs will not be supported because they do not
support POSIX character classes. Because of that, we also make use
of a lot of functions that were added in 21.5.32.

A known and currently unfixable issue with XEmacs is that go-mode
will not always fontify identifiers that use unicode correctly.

All changes for XEmacs are annotated in the diff.

Note: go--position-bytes is not currently used anywhere, but will
be in a future CL.

Fixes #4927.

R=golang-dev, adonovan, cw, patrick.allen.higgins, sameer
CC=golang-dev
https://golang.org/cl/7456051
2013-03-06 14:35:29 -05:00
Dominik Honnef
a969f3c247 misc/emacs: Add tab completion for godoc command, completing from known installed packages
R=golang-dev, adonovan, bradfitz, cw, patrick.allen.higgins, sameer, ugorji
CC=golang-dev
https://golang.org/cl/7373051
2013-03-04 15:31:57 -05:00
Dominik Honnef
b302d68ebc 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
2013-02-26 13:48:32 -05:00
Steven Elliot Harris
43da336b15 misc/emacs: Present "godoc" documentation buffers using view-mode.
Mimic the Emacs convention of presenting read-only files meant
for browsing using view-mode, rather than Fundamental mode
which mistakenly allows editing of the "godoc" content.
Fixes #4322.

R=golang-dev, bradfitz, sameer
CC=golang-dev
https://golang.org/cl/7231055
2013-02-20 14:42:37 -08:00
Sameer Ajmani
f14f458640 misc/emacs: update go-mode syntax table and comment handling as
suggested by pkleiweg.

Fixes #3471.

R=adonovan, pkleiweg, rsc
CC=golang-dev
https://golang.org/cl/7060056
2013-01-09 10:26:34 -05:00
Russ Cox
a93b15cad9 misc/emacs: fix go-mode hang
Fix suggested by serbaut.

Fixes #4445.

R=sameer
CC=golang-dev, serbaut
https://golang.org/cl/6842102
2012-11-27 12:21:10 -05:00
Jean-Marc Eurin
11cafa3a42 misc/emacs: Fix the gofmt patching when the TMPDIR is not the default.
The previous code assumed the gofmt output referred to /tmp but
that's not true if TMPDIR points somewhere else (like on Macs).
Fixes #3782.

R=sameer
CC=golang-dev
https://golang.org/cl/6346050
2012-06-29 12:49:31 -04:00
Mats Lidell
cbcf358d29 misc/emacs: Replace replace-{string|regexp} for XEmacs compatible code
Use code to be used in lisp programs as suggested in the doc strings for
replace-{string|regexp}. Bonus: This code works for XEmacs.

R=golang-dev, sameer, jmeurin
CC=golang-dev
https://golang.org/cl/6296073
2012-06-21 13:01:54 -04:00
Jean-Marc Eurin
44a3a58e45 misc/emacs: Fix a failure when /tmp/<file>.go exists.
R=sameer
CC=golang-dev
https://golang.org/cl/6296060
2012-06-13 10:25:00 -04:00