FAQ
I have gotten Emacs working with Gocode and the go-mode plugin provided in
the source tree. The syntax highlighting, code formatting, and code
completion (via gocode) is nice, but I was wondering are there any projects
that implement more advanced functionality similiar to Cedet (
http://cedet.sourceforge.net/)? Specifically, I would like "Jump
to Declaration and "Jump to Definition". I know that LiteIDE offers some
of that support but I prefer the Emacs text editing experience.

Luke

--

Search Discussions

  • Bryanturley at Nov 27, 2012 at 8:52 pm

    On Tuesday, November 27, 2012 2:07:24 PM UTC-6, Luke Mauldin wrote:
    I have gotten Emacs working with Gocode and the go-mode plugin provided in
    the source tree. The syntax highlighting, code formatting, and code
    completion (via gocode) is nice, but I was wondering are there any projects
    that implement more advanced functionality similiar to Cedet (
    http://cedet.sourceforge.net/)? Specifically, I would like "Jump
    to Declaration and "Jump to Definition". I know that LiteIDE offers some
    of that support but I prefer the Emacs text editing experience.

    Luke
    You could always right a module/plugin for emacs that does this. I find a
    normal search works just fine or grep if the codebase is large.

    --
  • Saul Hazledine at Nov 27, 2012 at 9:18 pm

    On Tuesday, 27 November 2012 21:07:24 UTC+1, Luke Mauldin wrote:

    I have gotten Emacs working with Gocode and the go-mode plugin provided in
    the source tree. The syntax highlighting, code formatting, and code
    completion (via gocode) is nice, but I was wondering are there any projects
    that implement more advanced functionality similiar to Cedet (
    http://cedet.sourceforge.net/)? Specifically, I would like "Jump
    to Declaration and "Jump to Definition". I know that LiteIDE offers some
    of that support but I prefer the Emacs text editing experience.

    Luke
    I'd also be interested in any good answers to this question. My method is a
    bit manual but works OK (assuming Ubuntu or similar):

    sudo apt-get install exuberant-ctags

    etags --list-languages

    # Go to source tree containing some Go code
    etags -Re *

    vi .emacs # This step requires a text editor

    (require 'etags-select)

    More information on etags-select can be found at:
    http://marmalade-repo.org/packages/etags-select

    If you use the most excellent Ido mode then the following function is also
    good


    ;; Use ido to list tags, but then select via etags-select (best of
    both worlds!)
    (defun my-ido-find-tag ()
    "Find a tag using ido"
    (interactive)
    (tags-completion-table)
    (let (tag-names)
    (mapatoms (lambda (x)
    (push (prin1-to-string x t) tag-names))
    tags-completion-table)
    (etags-select-find (ido-completing-read "Tag: " tag-names))))
    (global-set-key (kbd "M-.") 'my-ido-find-tag)




    --
  • Luke Mauldin at Nov 27, 2012 at 11:38 pm
    Thank you for the pointers. I will try them out.
    Another question, how can I use gofmt inside of Emacs? I am fairly new to
    Emacs but I know I can launch a shell command and do "gofmt" but my file in
    Emacs doesn't change and I have to close and re-open it to see the changes.
    Is there any shortcut or anyway that I could run the gofmt command and
    have Emacs automatically reload the updated file?

    Luke
    On Tuesday, November 27, 2012 3:18:53 PM UTC-6, Saul Hazledine wrote:
    On Tuesday, 27 November 2012 21:07:24 UTC+1, Luke Mauldin wrote:

    I have gotten Emacs working with Gocode and the go-mode plugin provided
    in the source tree. The syntax highlighting, code formatting, and code
    completion (via gocode) is nice, but I was wondering are there any projects
    that implement more advanced functionality similiar to Cedet (
    http://cedet.sourceforge.net/)? Specifically, I would like "Jump
    to Declaration and "Jump to Definition". I know that LiteIDE offers some
    of that support but I prefer the Emacs text editing experience.

    Luke
    I'd also be interested in any good answers to this question. My method is
    a bit manual but works OK (assuming Ubuntu or similar):

    sudo apt-get install exuberant-ctags

    etags --list-languages

    # Go to source tree containing some Go code
    etags -Re *

    vi .emacs # This step requires a text editor

    (require 'etags-select)

    More information on etags-select can be found at:
    http://marmalade-repo.org/packages/etags-select

    If you use the most excellent Ido mode then the following function is also
    good


    ;; Use ido to list tags, but then select via etags-select (best of
    both worlds!)
    (defun my-ido-find-tag ()
    "Find a tag using ido"
    (interactive)
    (tags-completion-table)
    (let (tag-names)
    (mapatoms (lambda (x)
    (push (prin1-to-string x t) tag-names))
    tags-completion-table)
    (etags-select-find (ido-completing-read "Tag: " tag-names))))
    (global-set-key (kbd "M-.") 'my-ido-find-tag)



    --
  • Senior7515 at Nov 28, 2012 at 12:33 am
    Better yet use this in your .emacs

    (require 'go-mode)(add-hook 'before-save-hook #'gofmt-before-save)


    other wise use


    M-x gofmt


    bwt you can use godoc inside emacs


    M-x godoc


    then type net/http to see an example.


    The other mode i find is helpful is go-play (google for it) you can post any buffer to play.golang.org



    On Tuesday, November 27, 2012 6:38:05 PM UTC-5, Luke Mauldin wrote:

    Thank you for the pointers. I will try them out.
    Another question, how can I use gofmt inside of Emacs? I am fairly new to
    Emacs but I know I can launch a shell command and do "gofmt" but my file in
    Emacs doesn't change and I have to close and re-open it to see the changes.
    Is there any shortcut or anyway that I could run the gofmt command and
    have Emacs automatically reload the updated file?

    Luke
    On Tuesday, November 27, 2012 3:18:53 PM UTC-6, Saul Hazledine wrote:
    On Tuesday, 27 November 2012 21:07:24 UTC+1, Luke Mauldin wrote:

    I have gotten Emacs working with Gocode and the go-mode plugin provided
    in the source tree. The syntax highlighting, code formatting, and code
    completion (via gocode) is nice, but I was wondering are there any projects
    that implement more advanced functionality similiar to Cedet (
    http://cedet.sourceforge.net/)? Specifically, I would like "Jump
    to Declaration and "Jump to Definition". I know that LiteIDE offers some
    of that support but I prefer the Emacs text editing experience.

    Luke
    I'd also be interested in any good answers to this question. My method is
    a bit manual but works OK (assuming Ubuntu or similar):

    sudo apt-get install exuberant-ctags

    etags --list-languages

    # Go to source tree containing some Go code
    etags -Re *

    vi .emacs # This step requires a text editor

    (require 'etags-select)

    More information on etags-select can be found at:
    http://marmalade-repo.org/packages/etags-select

    If you use the most excellent Ido mode then the following function is
    also good


    ;; Use ido to list tags, but then select via etags-select (best of
    both worlds!)
    (defun my-ido-find-tag ()
    "Find a tag using ido"
    (interactive)
    (tags-completion-table)
    (let (tag-names)
    (mapatoms (lambda (x)
    (push (prin1-to-string x t) tag-names))
    tags-completion-table)
    (etags-select-find (ido-completing-read "Tag: " tag-names))))
    (global-set-key (kbd "M-.") 'my-ido-find-tag)



    --
  • Luke Mauldin at Nov 28, 2012 at 1:38 pm
    I added that code to my .emacs and now when I save, emacs invokes gofmt and
    it shows me the differences but my question is, how do I apply those
    differences to the file I am editing and save it? I am sure there must be
    some command to do it but I have been unable to find it.

    Luke
    On Tuesday, November 27, 2012 6:33:02 PM UTC-6, senior7515 wrote:

    Better yet use this in your .emacs

    (require 'go-mode)(add-hook 'before-save-hook #'gofmt-before-save)


    other wise use


    M-x gofmt


    bwt you can use godoc inside emacs


    M-x godoc


    then type net/http to see an example.


    The other mode i find is helpful is go-play (google for it) you can post any buffer to play.golang.org



    On Tuesday, November 27, 2012 6:38:05 PM UTC-5, Luke Mauldin wrote:

    Thank you for the pointers. I will try them out.
    Another question, how can I use gofmt inside of Emacs? I am fairly new
    to Emacs but I know I can launch a shell command and do "gofmt" but my file
    in Emacs doesn't change and I have to close and re-open it to see the
    changes. Is there any shortcut or anyway that I could run the gofmt
    command and have Emacs automatically reload the updated file?

    Luke
    On Tuesday, November 27, 2012 3:18:53 PM UTC-6, Saul Hazledine wrote:
    On Tuesday, 27 November 2012 21:07:24 UTC+1, Luke Mauldin wrote:

    I have gotten Emacs working with Gocode and the go-mode plugin provided
    in the source tree. The syntax highlighting, code formatting, and code
    completion (via gocode) is nice, but I was wondering are there any projects
    that implement more advanced functionality similiar to Cedet (
    http://cedet.sourceforge.net/)? Specifically, I would like "Jump
    to Declaration and "Jump to Definition". I know that LiteIDE offers some
    of that support but I prefer the Emacs text editing experience.

    Luke
    I'd also be interested in any good answers to this question. My method
    is a bit manual but works OK (assuming Ubuntu or similar):

    sudo apt-get install exuberant-ctags

    etags --list-languages

    # Go to source tree containing some Go code
    etags -Re *

    vi .emacs # This step requires a text editor

    (require 'etags-select)

    More information on etags-select can be found at:
    http://marmalade-repo.org/packages/etags-select

    If you use the most excellent Ido mode then the following function is
    also good


    ;; Use ido to list tags, but then select via etags-select (best of
    both worlds!)
    (defun my-ido-find-tag ()
    "Find a tag using ido"
    (interactive)
    (tags-completion-table)
    (let (tag-names)
    (mapatoms (lambda (x)
    (push (prin1-to-string x t) tag-names))
    tags-completion-table)
    (etags-select-find (ido-completing-read "Tag: " tag-names))))
    (global-set-key (kbd "M-.") 'my-ido-find-tag)



    --
  • Dustin Sallings at Nov 29, 2012 at 4:16 am
    Luke Mauldin <lukemauldin@gmail.com>
    writes:
    I added that code to my .emacs and now when I save, emacs invokes
    gofmt and it shows me the differences but my question is, how do I
    apply those differences to the file I am editing and save it?  I am
    sure there must be some command to do it but I have been unable to
    find it.
    You may have an older version of the emacs plugin. There was an issue
    like this that was fixed a while back.

    --
    dustin

    --
  • Luke Mauldin at Nov 29, 2012 at 1:34 pm
    Dustin,

    I just downloaded a version of the emacs plugin from TIP and I configured
    my emacs version to use that plugin. I then followed the same steps I
    followed before to edit the file and when I clicked save I still get the
    "Gofmt patch" buffer as shown in the screenshot. Is there some command I
    need to use to apply the changes or do I need to submit a bug report? I am
    attaching a screenshot.

    Luke
    On Wednesday, November 28, 2012 10:16:09 PM UTC-6, Dustin wrote:

    Luke Mauldin <lukem...@gmail.com <javascript:>>
    writes:
    I added that code to my .emacs and now when I save, emacs invokes
    gofmt and it shows me the differences but my question is, how do I
    apply those differences to the file I am editing and save it? I am
    sure there must be some command to do it but I have been unable to
    find it.
    You may have an older version of the emacs plugin. There was an issue
    like this that was fixed a while back.

    --
    dustin
    --
  • Golang at Dec 1, 2012 at 12:49 am

    On Thursday, November 29, 2012 5:34:01 AM UTC-8, Luke Mauldin wrote:
    Dustin,

    I just downloaded a version of the emacs plugin from TIP and I configured
    my emacs version to use that plugin. I then followed the same steps I
    followed before to edit the file and when I clicked save I still get the
    "Gofmt patch" buffer as shown in the screenshot. Is there some command I
    need to use to apply the changes or do I need to submit a bug report? I am
    attaching a screenshot.

    Luke
    On Wednesday, November 28, 2012 10:16:09 PM UTC-6, Dustin wrote:

    Luke Mauldin <lukem...@gmail.com>
    writes:
    I added that code to my .emacs and now when I save, emacs invokes
    gofmt and it shows me the differences but my question is, how do I
    apply those differences to the file I am editing and save it? I am
    sure there must be some command to do it but I have been unable to
    find it.
    You may have an older version of the emacs plugin. There was an issue
    like this that was fixed a while back.

    --
    dustin
    Answering an earlier question, you can run gofmt over your code in a buffer
    as follows

    control-x h This is mark-whole-buffer, which sets the region
    to be the whole buffer.
    control-u This is universal -argument, which alters the
    next command
    Escape | This is shell-command-on-region, it will prompt
    you for a command, and you answer gofmt

    This will take your buffer, pass it as stdin to the command, and put the
    output back in place of the contents of the buffer. If something goes wrong
    then you can just use control-underscore or control-x u or control-/ (or if
    you have the menu then "undo" from the edit menu) to get your code back.

    --
  • Dustin Sallings at Dec 1, 2012 at 3:13 am
    Luke Mauldin <lukemauldin@gmail.com>
    writes:
    I just downloaded a version of the emacs plugin from TIP and I
    configured my emacs version to use that plugin.  I then followed the
    same steps I followed before to edit the file and when I clicked save
    I still get the "Gofmt patch" buffer as shown in the screenshot.  Is
    there some command I need to use to apply the changes or do I need to
    submit a bug report?  I am attaching a screenshot.
    Interesting. You're using Windows (which I don't know at all). I
    didn't find that fix until I went through the effort of doing it
    myself. The implementation that went in was a little odd in that it
    had some custom logic for determining what the temporary directory is
    instead of just asking.

    You can see the bug here:

    http://code.google.com/p/go/issues/detail?id=3782

    You might try my suggestion I mentioned in the bug. I suspect that
    would help, but if not, I think it'll at least give you the area to
    look.

    --
    dustin

    --
  • Luke Mauldin at Dec 3, 2012 at 2:16 pm
    I tried your suggestion and it still didn't work. I think Emacs with gofmt
    on save is just broken on Windows and unfortunately I don't have enough
    Emacs experience to fix it. I submitted a issue 4475.

    Luke
    On Friday, November 30, 2012 9:12:43 PM UTC-6, Dustin wrote:

    Luke Mauldin <lukem...@gmail.com <javascript:>>
    writes:
    I just downloaded a version of the emacs plugin from TIP and I
    configured my emacs version to use that plugin. I then followed the
    same steps I followed before to edit the file and when I clicked save
    I still get the "Gofmt patch" buffer as shown in the screenshot. Is
    there some command I need to use to apply the changes or do I need to
    submit a bug report? I am attaching a screenshot.
    Interesting. You're using Windows (which I don't know at all). I
    didn't find that fix until I went through the effort of doing it
    myself. The implementation that went in was a little odd in that it
    had some custom logic for determining what the temporary directory is
    instead of just asking.

    You can see the bug here:

    http://code.google.com/p/go/issues/detail?id=3782

    You might try my suggestion I mentioned in the bug. I suspect that
    would help, but if not, I think it'll at least give you the area to
    look.

    --
    dustin
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 27, '12 at 8:07p
activeDec 3, '12 at 2:16p
posts11
users6
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase