Author Topic: Begin/end pairs for Ruby  (Read 4565 times)

spence

  • Community Member
  • Posts: 17
  • Hero Points: 2
Begin/end pairs for Ruby
« on: July 08, 2007, 04:56:41 am »
Although Ruby is a supported language my installation does not have any definitions of begin/end pairs. Is this an error in my installation or are they just not defined yet for Ruby?

I'm running v 12.0.2.0 on Windows Vista.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2091
  • Hero Points: 259
Re: Begin/end pairs for Ruby
« Reply #1 on: July 08, 2007, 04:35:26 pm »
An oversight.

Go to Tools > Options > File Extension Setup
Select ruby
Click on the "Advanced" tab
And set the begin-end pairs to the following string:

(if),(while),(unless),(class),(do),(begin),(case),(module),(for),(until),(def)|(end)


spence

  • Community Member
  • Posts: 17
  • Hero Points: 2
Re: Begin/end pairs for Ruby
« Reply #2 on: July 08, 2007, 10:30:11 pm »
Thanks Dennis. That's a good start, but this set ignores matches to "else" and "elsif". Is there a way to make that work - I was trying it myself and that's where I got stuck.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2091
  • Hero Points: 259
Re: Begin/end pairs for Ruby
« Reply #3 on: July 09, 2007, 01:56:38 pm »
The default begin-end pair matching does not support chained statements like if - elsif - else - end

If you are feeling industrious, you can write support for Ruby begin-end matching by modelling after the support that was written for Ada which has a similar chained statement type.  The name of Ada callback is _ada_find_matching_word(boolean quiet).  To implement support for Ruby, you would need to write _ruby_find_matching_word(boolean quiet)

Or you could switch to Perl, and then you wouldn't have any headaches with Ruby.

emerkel

  • Community Member
  • Posts: 10
  • Hero Points: 0
  • striving to be karma neutral...
Re: Begin/end pairs for Ruby
« Reply #4 on: September 20, 2007, 04:30:15 am »
Ok, so I took the ada.e file and found that method and (being the noob at slick edit and slick c that I am) tried editing the method to work for ruby.  My problem is that I don't think it's getting called, since I don't even get the same messages when I put the cursor on elsif or else in the code window of a ruby file and press ctrl + ].  In the code from the Ada file the messages read 'Not on begin/end or word pair' and when I try it in the editor the message I see reads 'Not on begin/end or paren pair'.  This string appears nowhere in the ruby.e file so I can only gather it is some kind of default.  How would I go about making sure this method is called for ruby to see if this works?

Thanks

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2091
  • Hero Points: 259
Re: Begin/end pairs for Ruby
« Reply #5 on: September 20, 2007, 01:38:13 pm »
You can use a say() statement, like you would with a printf() to add debugging statements.

And, of course, you need to do Macro > Load Module (F12 in CUA) in order to compile and load your new callback.