jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Groovy Modules
  • GMOD-189

comments and indentation broken in Emacs Groovy mode

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: Emacs Mode
  • Labels:
    None
  • Environment:
    GNU Emacs 21 (and probably most other versions of Emacs as well)

Description

The Emacs mode for Groovy at <http://svn.groovy.codehaus.org/browse/~raw,r=HEAD/groovy/trunk/groovy/ide/groovy-emacs/groovy-mode.el> contains too many Ruby-isms to be a good Groovy mode.

I've attached a patch that fixes the following issues:

  • Ruby-style comments were recognized but Java-style comments were not.
  • Some Ruby keywords that are not Groovy keywords were highlighted.
  • Indentation after "->" and "import ....*" was wrong.
  • Indetation of "else" blocks was wrong.
  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. File
    groovy.el
    26/Dec/07 9:36 PM
    23 kB
    Seth Schroeder
  2. File
    groovy-mode.el.diff
    02/Oct/06 9:13 AM
    10 kB
    John Williams
  3. File
    groovy-mode-fixed.el.diff
    20/Apr/08 8:57 AM
    10 kB
    Karel Klic

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Seth Schroeder added a comment - 26/Dec/07 9:36 PM

This file is completely different than the other two Groovy modes for emacs. It is based on an excellent GPL2 Javascript mode by kland@comhem.se.

Show
Seth Schroeder added a comment - 26/Dec/07 9:36 PM This file is completely different than the other two Groovy modes for emacs. It is based on an excellent GPL2 Javascript mode by kland@comhem.se.
Hide
Permalink
Guillaume Laforge added a comment - 27/Dec/07 3:22 AM

Russel, could you have a look at this Emacs issue?

Show
Guillaume Laforge added a comment - 27/Dec/07 3:22 AM Russel, could you have a look at this Emacs issue?
Hide
Permalink
Karel Klic added a comment - 20/Apr/08 8:57 AM

I checked the groovy-mode.el.diff and I noticed some parenthesis are missing in the LISP code after applying the patch.
So I attached a new groovy-mode-fixed.el.diff which contains the forgotten parenthesis.

I tested the patched groovy-mode. Looks and behaves better than the previous version.

Show
Karel Klic added a comment - 20/Apr/08 8:57 AM I checked the groovy-mode.el.diff and I noticed some parenthesis are missing in the LISP code after applying the patch. So I attached a new groovy-mode-fixed.el.diff which contains the forgotten parenthesis. I tested the patched groovy-mode. Looks and behaves better than the previous version.
Hide
Permalink
Russel Winder added a comment - 04/May/08 3:17 AM - edited

I have applied Karel Klic's amendment of John Williams' changes to the trunk of the repository. I have not experimented with it though, I have just ensured that the file loads.

In a sense this closes the issue as originally posted – assuming the patch has been made correctly. (John, Karel, can I get you to check this so thjings can be right for the Groovy 1.6.0 release?) I am going to leave the issue open though. Focus for the issue now transfers to the other Emacs mode. The groovy.el file attached to this issue is based on CC-Mode so is more directly compared to .../ide/emacs/groovy-model.el instead of .../ide/groovy-emacs/groovy-mode.el (the focus of the original issue and the patches, which was based on a Ruby mode).

Show
Russel Winder added a comment - 04/May/08 3:17 AM - edited I have applied Karel Klic's amendment of John Williams' changes to the trunk of the repository. I have not experimented with it though, I have just ensured that the file loads. In a sense this closes the issue as originally posted – assuming the patch has been made correctly. (John, Karel, can I get you to check this so thjings can be right for the Groovy 1.6.0 release?) I am going to leave the issue open though. Focus for the issue now transfers to the other Emacs mode. The groovy.el file attached to this issue is based on CC-Mode so is more directly compared to .../ide/emacs/groovy-model.el instead of .../ide/groovy-emacs/groovy-mode.el (the focus of the original issue and the patches, which was based on a Ruby mode).
Hide
Permalink
Ciro Mondueri added a comment - 28/Jun/08 8:06 PM

The groovy.el attachment above, posted by Seth Schroeder works very well.

Thank you Seth!

Show
Ciro Mondueri added a comment - 28/Jun/08 8:06 PM The groovy.el attachment above, posted by Seth Schroeder works very well. Thank you Seth!
Hide
Permalink
Marc Paquette added a comment - 11/Sep/08 8:41 AM

I've briefly tried the 3 modes for groovy in XEmacs (21.5 beta28) and here are my personnal findings :

  • groovy-mode.el, authored by Russel Winder (LastChangedRevision: 12651 ):
    • Works well, without runtime errors, but indentation is a little messed up when you write groovy style (without
      semicolumns).
    • I find this annoying at best and it becomes unacceptable when
      I try to write code the groovy way and present that to others
      (in training, tutorials, etc).
  • groovy-mode.el, authored by Jeremy Rayner (Revision: 12256):
    • Works well but throws error in some common circumstances, like
      after a '//' comment line : there is code that refers to
      groovy-block-mid-re wich was a const in first revision of that
      mode but was deleted by revision 12256.
    • The effect of this is completly hosed up fontification for
      rest of buffer and equally messed up indentation from same
      point.
    • Personnaly, the net effect is worst that with the other
      groovy-mode described above.
  • groovy.el, authored by Seth Schroeder (Version: 1.0, Date: 2007-12-26):
    • Throws error when writing new code (C-j at eol of "class Test {"): {noformat}
      Debugger entered--Lisp error: (end-of-buffer)
      gr-ctrl-statement-indentation()
      gr-proper-indentation((2 93 nil nil nil nil 0 nil nil (22 93)))
      groovy-indent-line()
      indent-according-to-mode()
      #<compiled-function nil "...(14)" [" " nil newline indent-according-to-mode] 3 993551 "*">()
      call-interactively(newline-and-indent)
      ** When code have already been written, it works pretty well :
              fontification and indentation (almost always) correct, with or
              without semicolumns. 
      ** It had problems with re-indenting a line beginning with an
              'if' in a builder-like block of code (like when you define a
              webflow closure in a grails controller):
      

      class TestController {
      def latch = 1
      def index = { redirect(action:'test') }
      def testFlow = {
      start {
      action

      Unknown macro: { if ( latch == 1 ) { log.debug("latch is 1") } else { latch = 0 } }

      }
      }
      }

      
      
      • Pressing TAB on line with the 'if' adds another tab instead of
        re-indenting.
    • The only other annoyance I noticed : key sequence C-M-q is
      unbound; in modes based on cc-mode, it is usually bound to
      c-indent-exp
Show
Marc Paquette added a comment - 11/Sep/08 8:41 AM I've briefly tried the 3 modes for groovy in XEmacs (21.5 beta28) and here are my personnal findings :
  • groovy-mode.el, authored by Russel Winder (LastChangedRevision: 12651 ):
    • Works well, without runtime errors, but indentation is a little messed up when you write groovy style (without semicolumns).
    • I find this annoying at best and it becomes unacceptable when I try to write code the groovy way and present that to others (in training, tutorials, etc).
  • groovy-mode.el, authored by Jeremy Rayner (Revision: 12256):
    • Works well but throws error in some common circumstances, like after a '//' comment line : there is code that refers to groovy-block-mid-re wich was a const in first revision of that mode but was deleted by revision 12256.
    • The effect of this is completly hosed up fontification for rest of buffer and equally messed up indentation from same point.
    • Personnaly, the net effect is worst that with the other groovy-mode described above.
  • groovy.el, authored by Seth Schroeder (Version: 1.0, Date: 2007-12-26):
    • Throws error when writing new code (C-j at eol of "class Test {"): {noformat} Debugger entered--Lisp error: (end-of-buffer) gr-ctrl-statement-indentation() gr-proper-indentation((2 93 nil nil nil nil 0 nil nil (22 93))) groovy-indent-line() indent-according-to-mode() #<compiled-function nil "...(14)" [" " nil newline indent-according-to-mode] 3 993551 "*">() call-interactively(newline-and-indent)
      ** When code have already been written, it works pretty well :
              fontification and indentation (almost always) correct, with or
              without semicolumns. 
      ** It had problems with re-indenting a line beginning with an
              'if' in a builder-like block of code (like when you define a
              webflow closure in a grails controller):
      
      class TestController { def latch = 1 def index = { redirect(action:'test') } def testFlow = { start { action
      Unknown macro: { if ( latch == 1 ) { log.debug("latch is 1") } else { latch = 0 } }
      } } }
      
      
      • Pressing TAB on line with the 'if' adds another tab instead of re-indenting.
    • The only other annoyance I noticed : key sequence C-M-q is unbound; in modes based on cc-mode, it is usually bound to c-indent-exp
Hide
Permalink
blackdrag blackdrag added a comment - 11/Sep/08 8:45 AM

Marc, do you think you could make a working groovy.el? Would be very nice

Show
blackdrag blackdrag added a comment - 11/Sep/08 8:45 AM Marc, do you think you could make a working groovy.el? Would be very nice
Hide
Permalink
Maher Gamal added a comment - 13/Nov/09 11:20 AM

About a year later...

Is anyone still using Emacs primarily for groovy/grails development ?

Show
Maher Gamal added a comment - 13/Nov/09 11:20 AM About a year later... Is anyone still using Emacs primarily for groovy/grails development ?
Hide
Permalink
Ryan Zezeski added a comment - 13/Nov/09 2:13 PM

:: Raises hand :: Sure do.

I am very interested in finding or creating a proper Groovy mode (and eventually Grails mode) for Emacs. The problem is I just switched back to Emacs after a year of Vim and I know zilch about writing a mode and don't know much about the Elisp dialect. However, I'm pretty comfortable reading Lisp code.

I took at look at both Jeremy and Russel's code and I'm not sure if it is smarter to start with one of their solutions or start from scratch. I favor Russel's more since it derives from CC Mode.

If anyone is working on something I'd love to take a peek and help out where I can.

Show
Ryan Zezeski added a comment - 13/Nov/09 2:13 PM :: Raises hand :: Sure do. I am very interested in finding or creating a proper Groovy mode (and eventually Grails mode) for Emacs. The problem is I just switched back to Emacs after a year of Vim and I know zilch about writing a mode and don't know much about the Elisp dialect. However, I'm pretty comfortable reading Lisp code. I took at look at both Jeremy and Russel's code and I'm not sure if it is smarter to start with one of their solutions or start from scratch. I favor Russel's more since it derives from CC Mode. If anyone is working on something I'd love to take a peek and help out where I can.
Hide
Permalink
Jim Morris added a comment - 22/Nov/09 5:18 PM - edited

I am trying to use emacs with groovy/grails. Both modes have issues that makes it very hard.

I'd help out fixing the issues, if someone could point to the ONE version that everyone will use.

I fixed the ruby one for emacs v23 by adding

+(defconst groovy-block-beg-re
+ "todo ignore for now as it performs strangely..."
+ )

I'm leaning towards the cc-mode one, but am currently using the ruby based one as it is the most usable for me (I don't use ; as a line terminator.)

The biggest issue with the ruby based one right now is trying to get it to reliably use tabs for indent. I used the smarttabs.el, and it mostly works, but sometimes for no apparent reason starts using spaces again. The cc-mode base one works fine with tabs as indentation, but of course the ; issue is still prevalent.

I'll watch this issue, and jump in when a code base is selected

Show
Jim Morris added a comment - 22/Nov/09 5:18 PM - edited I am trying to use emacs with groovy/grails. Both modes have issues that makes it very hard. I'd help out fixing the issues, if someone could point to the ONE version that everyone will use. I fixed the ruby one for emacs v23 by adding +(defconst groovy-block-beg-re + "todo ignore for now as it performs strangely..." + ) I'm leaning towards the cc-mode one, but am currently using the ruby based one as it is the most usable for me (I don't use ; as a line terminator.) The biggest issue with the ruby based one right now is trying to get it to reliably use tabs for indent. I used the smarttabs.el, and it mostly works, but sometimes for no apparent reason starts using spaces again. The cc-mode base one works fine with tabs as indentation, but of course the ; issue is still prevalent. I'll watch this issue, and jump in when a code base is selected
Hide
Permalink
Seth Schroeder added a comment - 22/Nov/09 6:29 PM

Sometimes I use a Javascript mode to edit Groovy code... but recently I just suffer through Fundamental mode as I'm frustrated that Groovy and Grails have stagnated over the last two years. They may survive but Rails has shamed them.

Show
Seth Schroeder added a comment - 22/Nov/09 6:29 PM Sometimes I use a Javascript mode to edit Groovy code... but recently I just suffer through Fundamental mode as I'm frustrated that Groovy and Grails have stagnated over the last two years. They may survive but Rails has shamed them.
Hide
Permalink
Maher Gamal added a comment - 26/Nov/09 4:43 PM

It seems some prefer the cc-mode version more than the ruby-based one. Though, from a practical point of view, the ruby-based one is the most usable one now.

Can we focus on the ruby-based one ?

Show
Maher Gamal added a comment - 26/Nov/09 4:43 PM It seems some prefer the cc-mode version more than the ruby-based one. Though, from a practical point of view, the ruby-based one is the most usable one now. Can we focus on the ruby-based one ?
Hide
Permalink
Jim Morris added a comment - 26/Nov/09 4:59 PM

It is true that right now the ruby-mode based one has less issues with indenting, however I understand that it does not work with nxhtml, which is used to edit grails/gsp files.

I have started to fix some of the indentation issues with the cc-mode based one, because it does work with nxhtml. I have no idea why or how to fix the ruby based one. You are welcome to try to fix the ruby one though, it does seem much simpler. I'll continue to work on the cc-mode for now.

Show
Jim Morris added a comment - 26/Nov/09 4:59 PM It is true that right now the ruby-mode based one has less issues with indenting, however I understand that it does not work with nxhtml, which is used to edit grails/gsp files. I have started to fix some of the indentation issues with the cc-mode based one, because it does work with nxhtml. I have no idea why or how to fix the ruby based one. You are welcome to try to fix the ruby one though, it does seem much simpler. I'll continue to work on the cc-mode for now.
Hide
Permalink
Maher Gamal added a comment - 28/Nov/09 5:09 PM

Thanks Jim for helping out here on this. Can you keep us posted on it.

Show
Maher Gamal added a comment - 28/Nov/09 5:09 PM Thanks Jim for helping out here on this. Can you keep us posted on it.
Hide
Permalink
Jim Morris added a comment - 28/Nov/09 5:18 PM

I have fixed most of the obvious indentation issues, and Russel has committed them to the repo.

If anyone finds any more, just post a JIRA assigned to the Emacs Mode component, stating the version of emacs being used. Include the shortest example that exhibits the problem.

I just checked in an addition that enables the imenu and hence the speedbar parsing for groovy, so watch for that to get commited.

Show
Jim Morris added a comment - 28/Nov/09 5:18 PM I have fixed most of the obvious indentation issues, and Russel has committed them to the repo. If anyone finds any more, just post a JIRA assigned to the Emacs Mode component, stating the version of emacs being used. Include the shortest example that exhibits the problem. I just checked in an addition that enables the imenu and hence the speedbar parsing for groovy, so watch for that to get commited.
Hide
Permalink
Russel Winder added a comment - 29/Nov/09 1:11 AM

Apologies for failing to pick up that this thread has restarted.

Jim has done a great job of getting some of the real formatting irritants out of the CC Mode based Groovy mode.This one is now effectively under active maintenance. The other two (Jez's and Seth's) are unlikely to be maintained any further. So the comparison material above is no longer a good statement of the state of play. If anyone fancies doing a new up-to-date comparison based on the Groovy mode including Jim's work, that would be great.

I have set up a project on Launchpad (https://launchpad.net/groovy-emacs-mode) as a place to share Bazaar branches of the Groovy Emacs Mode – for now Bazaar is the tool of development of the code, though the master Bazaar branch actually resides in the Groovy Subversion store (thanks to the wonders of bzr-svn). So anyone can take a branch of the working mainline (lp:groovy-emacs-mode) and hack away. If you have merge proposals then I am acting as human gatekeeper for change requests.

My proposal is that going forward there is one and only one Emacs Groovy Mode. Currently this is based on my CC Mode effort amended by Jim, but if it evolves into something totally different then that is fine – it is the nature of open source.

Bug reports and other change proposals should continue to be placed using this Groovy JIRA, but make sure the component is Emacs Mode. The intention is not to use Launchpad bug management.

As far as I am aware all Jim's changes bar one are merged and in the mainline.

Looking forward to lots of activity now that Jim has started the ball rolling . . .

Show
Russel Winder added a comment - 29/Nov/09 1:11 AM Apologies for failing to pick up that this thread has restarted. Jim has done a great job of getting some of the real formatting irritants out of the CC Mode based Groovy mode.This one is now effectively under active maintenance. The other two (Jez's and Seth's) are unlikely to be maintained any further. So the comparison material above is no longer a good statement of the state of play. If anyone fancies doing a new up-to-date comparison based on the Groovy mode including Jim's work, that would be great. I have set up a project on Launchpad (https://launchpad.net/groovy-emacs-mode) as a place to share Bazaar branches of the Groovy Emacs Mode – for now Bazaar is the tool of development of the code, though the master Bazaar branch actually resides in the Groovy Subversion store (thanks to the wonders of bzr-svn). So anyone can take a branch of the working mainline (lp:groovy-emacs-mode) and hack away. If you have merge proposals then I am acting as human gatekeeper for change requests. My proposal is that going forward there is one and only one Emacs Groovy Mode. Currently this is based on my CC Mode effort amended by Jim, but if it evolves into something totally different then that is fine – it is the nature of open source. Bug reports and other change proposals should continue to be placed using this Groovy JIRA, but make sure the component is Emacs Mode. The intention is not to use Launchpad bug management. As far as I am aware all Jim's changes bar one are merged and in the mainline. Looking forward to lots of activity now that Jim has started the ball rolling . . .
Hide
Permalink
Russel Winder added a comment - 29/Nov/09 1:15 AM

Setting the correct component so that searching for Emacs Mode issues is easy.

Show
Russel Winder added a comment - 29/Nov/09 1:15 AM Setting the correct component so that searching for Emacs Mode issues is easy.
Hide
Permalink
Ryan Zezeski added a comment - 30/Nov/09 9:01 PM

Just want to thank both of you for picking this up. The recent changes have already made a noticeable difference.

Show
Ryan Zezeski added a comment - 30/Nov/09 9:01 PM Just want to thank both of you for picking this up. The recent changes have already made a noticeable difference.
Hide
Permalink
Russel Winder added a comment - 09/Dec/09 8:47 AM

I am thinking that with Jim's efforts over the last couple of weeks that the core issue here is solved. I think there is more to do but I am thinking that perhaps we should close this issue as fixed and raise new issues for any specific remaining problems. Basically I believe this issue is now too general to be truly useful.

If no-one objects I'll mark as resolved and closed Friday morning.

Show
Russel Winder added a comment - 09/Dec/09 8:47 AM I am thinking that with Jim's efforts over the last couple of weeks that the core issue here is solved. I think there is more to do but I am thinking that perhaps we should close this issue as fixed and raise new issues for any specific remaining problems. Basically I believe this issue is now too general to be truly useful. If no-one objects I'll mark as resolved and closed Friday morning.
Hide
Permalink
Jim Morris added a comment - 10/Dec/09 12:23 AM

I have no problem with closing it, it got me to fix some of the bugs so its job is done

FYI I have started on a grails-mode for emacs, which should work hand in hand with groovy-mode.

It is pretty raw right now, and I'd appreciate any help on it.

So far I have integrated "anything" to help in navigating around a grails project. it is available here...

http://github.com/wolfmanjm/grails-mode

Show
Jim Morris added a comment - 10/Dec/09 12:23 AM I have no problem with closing it, it got me to fix some of the bugs so its job is done FYI I have started on a grails-mode for emacs, which should work hand in hand with groovy-mode. It is pretty raw right now, and I'd appreciate any help on it. So far I have integrated "anything" to help in navigating around a grails project. it is available here... http://github.com/wolfmanjm/grails-mode
Hide
Permalink
Russel Winder added a comment - 12/Dec/09 3:29 AM

I have cloned the Git repository and so have Grails mode.

I assume things on this mode are tracked via the Grails JIRA?

Show
Russel Winder added a comment - 12/Dec/09 3:29 AM I have cloned the Git repository and so have Grails mode. I assume things on this mode are tracked via the Grails JIRA?
Hide
Permalink
Russel Winder added a comment - 12/Dec/09 3:30 AM

Marking this issue as fixed and closing it.

For any bug reports or modification requests please raise new JIRA issues tagged with component "Emacs Mode".

Show
Russel Winder added a comment - 12/Dec/09 3:30 AM Marking this issue as fixed and closing it. For any bug reports or modification requests please raise new JIRA issues tagged with component "Emacs Mode".

People

  • Assignee:
    Russel Winder
    Reporter:
    John Williams
Vote (2)
Watch (4)

Dates

  • Created:
    02/Oct/06 9:13 AM
    Updated:
    23/Mar/11 8:24 AM
    Resolved:
    12/Dec/09 3:30 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.