emacs mode

236 views
Skip to first unread message

Rob Pike

unread,
Feb 19, 2013, 4:51:39 PM2/19/13
to golan...@googlegroups.com, golan...@googlegroups.com, dominik...@gmail.com
In a CL at https://codereview.appspot.com/7314113/, Dominik Honnef has
been working on emacs support for Go. I hope that this work leads to a
single improved emacs setup for all our emacs-oriented gophers. I
would like to be sure that we actually achieve that before we check in
this CL. To that end, if you use emacs to write Go I encourage you to
try out this setup and see if it works for you. To make that easy, in
an unprecedented step I have loaded some elisp into the playground;
you can grab the files there without hg clpatch etc. Please let us
know what you discover.

go-mode-load.el: http://play.golang.org/p/w8jWpq_umz (the file comment
there calls it go-mode-loads.el)
go-mode.el: http://play.golang.org/p/nCHi65PVCS

Thanks.

-rob

Alok Parlikar

unread,
Feb 19, 2013, 5:18:02 PM2/19/13
to golan...@googlegroups.com, golan...@googlegroups.com, dominik...@gmail.com
Tried using the new version for a few minutes: Quick impression:

- Issue 4240 used to really be annoying and that seems fixed. 
- I also used to have some issue with syntax highlighting occasionally when there was C code above "import C" line, couldn't reproduce it with the new file, so that looks good :)

I tried to see if Issue 4766 was fixed, it seems not: saving file with a space in its name results in a weird error (unable to find a /tmp/.... file). Not sure how difficult the fix would be, but it would be great if that issue is fixed too. 

Alok Parlikar

unread,
Feb 19, 2013, 5:25:06 PM2/19/13
to golan...@googlegroups.com, golan...@googlegroups.com, dominik...@gmail.com
What does go-import-add do, and how do I use it? When I run that command, I get Lisp nesting exceeds `max-lisp-eval-depth'

Thomas Kappler

unread,
Feb 20, 2013, 9:29:55 AM2/20/13
to golan...@googlegroups.com, golan...@googlegroups.com
I've used Dominik's mode for the last few days, first the version from his github, then the one from the playground. It works well for me and I haven't found any problems.

I haven't used the add/remove import functions since I don't see an advantage of remembering special functions when I can just jump to the top and add/remove an import. gofmt will take care of the alphabetical order.

I use go-mode together with

(add-hook 'before-save-hook #'gofmt-before-save)

and gocode auto-completion from github.com/nsf/gocode:

(require 'go-autocomplete)
(require 'auto-complete-config)

This also works well.

Overall I find it a substantial improvement from the one included in the Go distribution, mainly because of the proper parsing that enables beginning-of-defun, expand-region etc., and the correct syntax coloring. So thumbs up from me, and thanks Dominik!

-- Thomas

Jim Robinson

unread,
Feb 22, 2013, 12:56:53 PM2/22/13
to golan...@googlegroups.com, golan...@googlegroups.com, dominik...@gmail.com
Type the following into a new go-mode buffer, and save.  After Gofmt reports the error on line 28 (trailing comma on the 1st test), it appears as though emacs will no longer save the buffer to disk until the error is corrected.  That seems like odd behavior to me, I'd always expect save to at least write the current file to disk even if it complains about syntax errors.

package lexrec

import (
"fmt"
"strings"
"testing"
)

const (
ItemIgnore ItemType = ItemEOF + 1 + iota
ItemAorB
)

type lexTest struct {
name   string
input  string
record Record
expect []Item
}

var (
tItemEOF = Item{ItemEOF, 0, ""}
)

var parseA = Record{Buflen: 1, ErrorFn: SkipPast("\n"), States: []Binding{{ItemA, AcceptRun("a"), true}}}

var lexTests = []lexTest{
{"empty", "", parseA, []Item[tItemEOF]},
}

Dominik Honnef

unread,
Feb 22, 2013, 5:03:12 PM2/22/13
to Rob Pike, golan...@googlegroups.com, golan...@googlegroups.com, dominik...@gmail.com
I would suggest moving on with the CL. All "critical" bugs should be
eliminated by now and the CL is getting a bit unwieldy (which is not
made easier by rietveld failing to properly render some diffs).

I have more adjustments to the mode planned, but they would greatly
benefit from being adressed in new, way smaller CLs, instead of trying
to push them into the existing CL.

Apart from that, there are way too many versions of the mode now, so
some people try the one you initially uploaded, some use mine, some use
the latest from the CL and it makes diagnosing problems a lot harder.
I'd like future bug reports to be based on one single source.

I think the consensus is that there are way too many changes to read the
code, but that it works better than before :)

Yours,
Dominik

serbaut

unread,
Feb 28, 2013, 5:18:13 AM2/28/13
to golan...@googlegroups.com, Rob Pike, golan...@googlegroups.com, dominik...@gmail.com

I am seeing some weird highlighting: http://imgur.com/zx6fSSL

go version devel +b766c6f23b62 Thu Feb 28 16:07:26 2013 +0800 linux/amd64

GNU Emacs 23.1.1


emacs -q -l go/misc/emacs/go-mode.el foo.go

Joakim

Dominik Honnef

unread,
Feb 28, 2013, 9:14:21 AM2/28/13
to serbaut, golan...@googlegroups.com, golan...@googlegroups.com

Robert Zaremba

unread,
Mar 4, 2013, 5:17:05 PM3/4/13
to golan...@googlegroups.com, serbaut, golan...@googlegroups.com
I've updated go-mode and make pul-request to Dominiks github. Changes:
  • Compatibility with Emacs Lisp header conventions. Now it can be used by package.el
  • Proper definition of go-mode mode
  • definition of go-mode-hook
  • Installation instrucions

I encourage to delete "go-mode-load.el" end relay on package.el It delivers all we need to automatic  handling new packages, and generating autoloads.
So the installation now is as simple as package-install-file go-mode.el

Dominik Honnef

unread,
Mar 4, 2013, 5:55:50 PM3/4/13
to golan...@googlegroups.com
Robert Zaremba <robert....@zoho.com> writes:

> I've updated go-mode and make pul-request to Dominiks github. Changes:
>
> - Compatibility with Emacs Lisp header conventions. Now it can be used
> by *package.el*
> - Proper definition of *go-mode* mode
> - definition of *go-mode-hook*
> - Installation instrucions
>
> I encourage to delete "go-mode-load.el" end relay on *package.el* It
> delivers all we need to automatic handling new packages, and generating
> autoloads.
> So the installation now is as simple as package-install-file go-mode.el

The reason I've stayed with go-mode-load.el as opposed to
go-mode-autoload.el is that removing go-mode-load.el now will break
everybody's existing setup as soon as they update to tip.

And the reason I don't advocate package-install-file is because neither
XEmacs nor GNU Emacs 23 have that by default. Same goes for prog-mode.

P.S.: I haven't gotten to your pull request yet because I've been busy
with more pressing changes to go-mode (see ongoing CLs) and because of
real life. I'll process the PR soon.

Cheers,
Dominik

Brad Fitzpatrick

unread,
Mar 4, 2013, 9:35:08 PM3/4/13
to Tong Sun, golan...@googlegroups.com, golan...@googlegroups.com
See https://code.google.com/p/go-wiki/wiki/IDEsAndTextEditorPlugins

On Mon, Mar 4, 2013 at 6:34 PM, Tong Sun <sunto...@gmail.com> wrote:
How to install this go-mode? 
I went through all Dominik's posts but didn't find it. 

Please advice. 

Thanks


On Monday, March 4, 2013 5:17:05 PM UTC-5, Robert Zaremba wrote:

I encourage to delete "go-mode-load.el" end relay on package.el It delivers all we need to automatic  handling new packages, and generating autoloads.
So the installation now is as simple as package-install-file go-mode.el

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dominik Honnef

unread,
Mar 4, 2013, 10:23:46 PM3/4/13
to golang-nuts, golan...@googlegroups.com
> Alright, one question answered, as where is the latest code. Thanks.
> However, Is there a installation doc somewhere?
> What does the "I encourage to delete "go-mode-load.el" end relay on
> package.el " and "So the installation now is as simple as
> package-install-file go-mode.el" mean? They are still Greek to me.

> Thanks

Ignore all the "I encourage to delete" stuff.

The installation guide is in the go-mode-load.el file, at the very top.

bryanturley

unread,
Mar 4, 2013, 11:07:54 PM3/4/13
to golan...@googlegroups.com, golan...@googlegroups.com


On Monday, March 4, 2013 9:41:13 PM UTC-6, Tong Sun wrote:

On Mon, Mar 4, 2013 at 10:23 PM, Dominik Honnef <domi...@fork-bomb.org> wrote:
The installation guide is in the go-mode-load.el file, at the very top.

Thanks, 

so go-mode-load.el shall be put at a place defined by the

  (add-to-list 'load-path "PATH CONTAINING go-mode-load.el" t)


notice the "PATH CONTAINING" bit there?

/some/place/on/your/fs/go-mode-load.el

line. 

Now, how about the go-mode.el and it compiled binary, where should I put them? 
Shall I replace my /usr/share/emacs/site-lisp/golang-mode/go-mode.el, or put it somewhere else?
Is it suggested to put go-mode-load.el into /usr/share/emacs/site-lisp/golang-mode/ as well?

Thanks

See above comment.
I have also just symlinked it into site-lisp from where i put the hg repo, but that is probably a bit of a dirty solution.

Tong Sun

unread,
Mar 4, 2013, 10:41:13 PM3/4/13
to golang-nuts, golan...@googlegroups.com
On Mon, Mar 4, 2013 at 10:23 PM, Dominik Honnef <domi...@fork-bomb.org> wrote:
The installation guide is in the go-mode-load.el file, at the very top.

Thanks, 

so go-mode-load.el shall be put at a place defined by the

  (add-to-list 'load-path "PATH CONTAINING go-mode-load.el" t)

Tong Sun

unread,
Mar 4, 2013, 11:38:24 PM3/4/13
to bryanturley, golang-nuts, golan...@googlegroups.com

On Mon, Mar 4, 2013 at 11:07 PM, bryanturley <bryan...@gmail.com> wrote:
See above comment.

Sorry, you lost me. 

Tong Sun

unread,
Mar 4, 2013, 9:42:43 PM3/4/13
to Brad Fitzpatrick, golang-nuts, golan...@googlegroups.com
Alright, one question answered, as where is the latest code. Thanks. 
However, Is there a installation doc somewhere? 
What does the "I encourage to delete "go-mode-load.el" end relay on package.el " and "So the installation now is as simple as package-install-file go-mode.el" mean? They are still Greek to me. 

Thanks

Tong Sun

unread,
Mar 4, 2013, 9:34:04 PM3/4/13
to golan...@googlegroups.com, golan...@googlegroups.com
How to install this go-mode? 
I went through all Dominik's posts but didn't find it. 

Please advice. 

Thanks


On Monday, March 4, 2013 5:17:05 PM UTC-5, Robert Zaremba wrote:

Robert Zaremba

unread,
Mar 5, 2013, 6:05:06 AM3/5/13
to golan...@googlegroups.com, bryanturley, golan...@googlegroups.com
If you are using Go package release, then go-mode* in /usr/share/emacs/site-lisp takes precedence. So you need either:
  • delete /substitute  files from /usr/share/emacs/site-lisp/go-mode* and use the ones from go repo.
  • load your go-mode* files, by (load-file "path to the file"), before go-mode is used.

package.el is a package manager for Emacs. It is bundled in Emacs 24 (also available as a separate package in Emacs 23) and automates the process of package installation. More about it you can find on http://batsov.com/articles/2012/02/19/package-management-in-emacs-the-good-the-bad-and-the-ugly/  post.

But if you are not confident about package management in Emacs, then stay with go-mode author (Dominik Honnef) advice.

Robert Zaremba

unread,
Mar 5, 2013, 6:07:38 AM3/5/13
to golan...@googlegroups.com, bryanturley, golan...@googlegroups.com
And forgot to mention, that globally loading files is not a good idea, because it will take a time (not much) even if you don't need them (eg: using Emacs not for editing go files).

bryanturley

unread,
Mar 5, 2013, 3:33:31 PM3/5/13
to golan...@googlegroups.com, bryanturley, golan...@googlegroups.com


On Tuesday, March 5, 2013 5:05:06 AM UTC-6, Robert Zaremba wrote:
If you are using Go package release, then go-mode* in /usr/share/emacs/site-lisp takes precedence. So you need either:
  • delete /substitute  files from /usr/share/emacs/site-lisp/go-mode* and use the ones from go repo.
  • load your go-mode* files, by (load-file "path to the file"), before go-mode is used.
Indeed my previous example was 2 different systems.
One I symlinked into site-lisp and one I used the load stuff in my ~/.emacs
I think I fell back on the symlink because it was not happy with the load bits on the 2nd system.
Despite having used emacs for ... ever, I have intentionally avoided getting to know it's insides.

package.el is a package manager for Emacs. It is bundled in Emacs 24 (also available as a separate package in Emacs 23) and automates the process of package installation. More about it you can find on http://batsov.com/articles/2012/02/19/package-management-in-emacs-the-good-the-bad-and-the-ugly/  post.

But if you are not confident about package management in Emacs, then stay with go-mode author (Dominik Honnef) advice.


And on the global loading side, speedwise I have never expected emacs to be blazingly fast ;)

Robert Zaremba

unread,
Mar 5, 2013, 7:57:15 PM3/5/13
to golan...@googlegroups.com, bryanturley, golan...@googlegroups.com
How much  time takes your Emacs startup?

bryanturley

unread,
Mar 5, 2013, 8:03:49 PM3/5/13
to golan...@googlegroups.com, bryanturley, golan...@googlegroups.com
On Tuesday, March 5, 2013 6:57:15 PM UTC-6, Robert Zaremba wrote:
How much  time takes your Emacs startup?


Not sure, never bothers me ;)
Appears to be (visual measurement only) 1/4 to 1/2 second.
Slightly more than 1 second on first run after boot or file cache clearing.

I said "never expected emacs to be blazingly fast" doesn't mean I would tolerate a slow editor.
Baring remote connection latency and other external slowness.

bryanturley

unread,
Mar 5, 2013, 8:07:43 PM3/5/13
to golan...@googlegroups.com, bryanturley, golan...@googlegroups.com


On Tuesday, March 5, 2013 7:03:49 PM UTC-6, bryanturley wrote:
On Tuesday, March 5, 2013 6:57:15 PM UTC-6, Robert Zaremba wrote:
How much  time takes your Emacs startup?


Not sure, never bothers me ;)
Appears to be (visual measurement only) 1/4 to 1/2 second.
Slightly more than 1 second on first run after boot or file cache clearing.


I only ever run it in a terminal, don't like it making it's own windows that might have something to do with startup time as well.

Reply all
Reply to author
Forward
0 new messages