Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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.
-
- groovy.el
- 26/Dec/07 9:36 PM
- 23 kB
- Seth Schroeder
-
- groovy-mode.el.diff
- 02/Oct/06 9:13 AM
- 10 kB
- John Williams
-
- groovy-mode-fixed.el.diff
- 20/Apr/08 8:57 AM
- 10 kB
- Karel Klic
Activity
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.
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).
The groovy.el attachment above, posted by Seth Schroeder works very well.
Thank you Seth!
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).
- Works well, without runtime errors, but indentation is a little messed up when you write groovy style (without
- 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.
- Works well but throws error in some common circumstances, like
- 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 {
actionUnknown 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.
- Pressing TAB on line with the 'if' adds another tab instead of
- 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
- Throws error when writing new code (C-j at eol of "class Test {"):
{noformat}
- 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)
class TestController { def latch = 1 def index = { redirect(action:'test') } def testFlow = { start { action
** 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):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
- 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)
Marc, do you think you could make a working groovy.el? Would be very nice
About a year later...
Is anyone still using Emacs primarily for groovy/grails development ?
:: 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.
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
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.
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 ?
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.
Thanks Jim for helping out here on this. Can you keep us posted on it.
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.
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 . . .
Setting the correct component so that searching for Emacs Mode issues is easy.
Just want to thank both of you for picking this up. The recent changes have already made a noticeable difference.
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.
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...
I have cloned the Git repository and so have Grails mode.
I assume things on this mode are tracked via the Grails JIRA?
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".
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.