[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby indenting in jEdit

Jay Levitt

5/14/2005 11:55:00 AM

For some reason, jEdit 4.3pre2 (JRE5, Windows XP SP2) wants to indent
any "end" statements with the rest of the block, which of course throws
off every succeeding line. I've downloaded Karl von Laudermann's
ruby.xml 0.6, but this hasn't made a difference. In fact, now that I
notice, if/then/else has a problem too. Anyone have any ideas how to
troubleshoot this?

Example:

if blah
puts "hi"
else
puts "bye"
end

--
Jay Levitt |
Wellesley, MA | I feel calm. I feel ready. I can only
Faster: jay at jay dot fm | conclude that's because I don't have a
http://... | full grasp of the situation. - Mark Adler
8 Answers

Rob .

5/14/2005 1:23:00 PM

0

Jay, by just typing your example line by line in a blank .rb file the
indenting is correct for me in jEdit 4.2final with v0.6.6 of the Ruby
Editor Plugin:
http://www.jedit.org/ruby...

I'll try this out under 4.3pre2. I know some changes were made for
indenting in 4.3 that might be stuffing things up for Ruby code.

In the meantime, some questions:
1) What version of the Ruby plugin are you running?
2) Is you example from a otherwise empty file, if not can you sent me
the complete file.
3) What order did you type the example in?

Cheers,
Rob

On 5/14/05, Jay Levitt <jay+news@jay.fm> wrote:
> For some reason, jEdit 4.3pre2 (JRE5, Windows XP SP2) wants to indent
> any "end" statements with the rest of the block, which of course throws
> off every succeeding line. I've downloaded Karl von Laudermann's
> ruby.xml 0.6, but this hasn't made a difference. In fact, now that I
> notice, if/then/else has a problem too. Anyone have any ideas how to
> troubleshoot this?
>
> Example:
>
> if blah
> puts "hi"
> else
> puts "bye"
> end
>
> --
> Jay Levitt |
> Wellesley, MA | I feel calm. I feel ready. I can only
> Faster: jay at jay dot fm | conclude that's because I don't have a
> http://... | full grasp of the situation. - Mark Adler


Jay Levitt

5/14/2005 2:32:00 PM

0

In article <525df23a050514062232236a1e@mail.gmail.com>, rob.02004
@gmail.com says...
> I'll try this out under 4.3pre2. I know some changes were made for
> indenting in 4.3 that might be stuffing things up for Ruby code.
>
> In the meantime, some questions:
> 1) What version of the Ruby plugin are you running?
0.6.5 or 0.6.6; both do the same.

> 2) Is you example from a otherwise empty file, if not can you sent me
> the complete file.
Utterly empty buffer, which I switch to Ruby mode via Buffer Options.

> 3) What order did you type the example in?
Exactly as shown, start to finish.

I just resurrected 4.2 from the recycle bin (with RubyPlugin 0.5), and
discovered something interesting: As I type the example in, the "else"
that I type and the automatic "end" show up in the correct columns.
(The automatic "end" doesn't show up for me with 0.6.6 and 4.3pre2.)

BUT - if I then use TAB (mapped to "Indent Selected Lines") to reindent
the code, I end up with the same forever-indenting result as 4.3.3. So
maybe this bug has existed forever, but nobody's noticed because they're
not reindenting?

I should also point out that the increasing left margin I see is
*exactly* what happens whenever I try to write with a pencil on a piece
of paper, much to the dismay of my fourth-grade teacher. However, I
don't know for sure that this bug is related.

--
Jay Levitt |
Wellesley, MA | I feel calm. I feel ready. I can only
Faster: jay at jay dot fm | conclude that's because I don't have a
http://... | full grasp of the situation. - Mark Adler

Rob .

5/16/2005 8:52:00 AM

0

Jay, thanks for your detailed description of the steps you followed. I
can see the problem now:

> > 2) Is your example from a otherwise empty file
> Utterly empty buffer, which I switch to Ruby mode via Buffer Options.

If you first save the file to a "something.rb" file name, then
indenting should work properly for you. Currently the plugin is using
the file extension to determine if the file is "ruby" or not. I'll fix
it to also look at the buffer options setting in a future release.

Thanks for the feedback!

Cheers,
Rob

On 5/14/05, Jay Levitt <jay+news@jay.fm> wrote:
> In article <525df23a050514062232236a1e@mail.gmail.com>, rob.02004
> @gmail.com says...
> > I'll try this out under 4.3pre2. I know some changes were made for
> > indenting in 4.3 that might be stuffing things up for Ruby code.
> >
> > In the meantime, some questions:
> > 1) What version of the Ruby plugin are you running?
> 0.6.5 or 0.6.6; both do the same.
>
> > 2) Is you example from a otherwise empty file, if not can you sent me
> > the complete file.
> Utterly empty buffer, which I switch to Ruby mode via Buffer Options.
>
> > 3) What order did you type the example in?
> Exactly as shown, start to finish.
>
> I just resurrected 4.2 from the recycle bin (with RubyPlugin 0.5), and
> discovered something interesting: As I type the example in, the "else"
> that I type and the automatic "end" show up in the correct columns.
> (The automatic "end" doesn't show up for me with 0.6.6 and 4.3pre2.)
>
> BUT - if I then use TAB (mapped to "Indent Selected Lines") to reindent
> the code, I end up with the same forever-indenting result as 4.3.3. So
> maybe this bug has existed forever, but nobody's noticed because they're
> not reindenting?
>
> I should also point out that the increasing left margin I see is
> *exactly* what happens whenever I try to write with a pencil on a piece
> of paper, much to the dismay of my fourth-grade teacher. However, I
> don't know for sure that this bug is related.


Jay Levitt

5/16/2005 6:54:00 PM

0

In article <525df23a0505160151184d2b21@mail.gmail.com>, rob.02004
@gmail.com says...
>
> > > 2) Is your example from a otherwise empty file
> > Utterly empty buffer, which I switch to Ruby mode via Buffer Options.
>
> If you first save the file to a "something.rb" file name, then
> indenting should work properly for you. Currently the plugin is using
> the file extension to determine if the file is "ruby" or not. I'll fix
> it to also look at the buffer options setting in a future release.

Hmm.. nope, there's more to it than that. This turns on the plugin's
pre- and re-indenting of "else" and "end", but if I then select
Edit | Indent | Indent Lines, it still messes up the spacing.

I suspect the problem is in the ruby.xml file or the parser itself, but
I don't know enough about any of this to troubleshoot... can you
duplicate that on your end?

--
Jay Levitt |
Wellesley, MA | I feel calm. I feel ready. I can only
Faster: jay at jay dot fm | conclude that's because I don't have a
http://... | full grasp of the situation. - Mark Adler

Rob .

5/17/2005 1:52:00 PM

0

> but if I then select
> Edit | Indent | Indent Lines, it still messes up the spacing.

The Edit->Indent->Indent Lines action is implemented as part of the
core jEdit editor, and it was designed for languages that have blocks
enclosed in a start and end token, e.g. '{' and '}'. There is no logic
in the core jEdit codebase to support indenting languages like Ruby
and Python, so Edit->Indent->Indent Lines won't work for Ruby.

For Ruby indenting I recommend you use the 'enter' key bound as a
shortcut to the Ruby plugin "Auto-indent and insert end" action. This
will for the most part indent your code appropriately as you type it.
Indenting discrepances will require you to make manual alterations,
the Edit->Indent->Indent Lines action won't work.

Cheers,
Rob

On 5/16/05, Jay Levitt <jay+news@jay.fm> wrote:
> In article <525df23a0505160151184d2b21@mail.gmail.com>, rob.02004
> @gmail.com says...
> >
> > > > 2) Is your example from a otherwise empty file
> > > Utterly empty buffer, which I switch to Ruby mode via Buffer Options.
> >
> > If you first save the file to a "something.rb" file name, then
> > indenting should work properly for you. Currently the plugin is using
> > the file extension to determine if the file is "ruby" or not. I'll fix
> > it to also look at the buffer options setting in a future release.
>
> Hmm.. nope, there's more to it than that. This turns on the plugin's
> pre- and re-indenting of "else" and "end", but if I then select
> Edit | Indent | Indent Lines, it still messes up the spacing.
>
> I suspect the problem is in the ruby.xml file or the parser itself, but
> I don't know enough about any of this to troubleshoot... can you
> duplicate that on your end?
>
> --
> Jay Levitt |
> Wellesley, MA | I feel calm. I feel ready. I can only
> Faster: jay at jay dot fm | conclude that's because I don't have a
> http://... | full grasp of the situation. - Mark Adler


Jay Levitt

5/17/2005 3:33:00 PM

0

In article <525df23a050517065137427482@mail.gmail.com>, rob.02004
@gmail.com says...
> The Edit->Indent->Indent Lines action is implemented as part of the
> core jEdit editor, and it was designed for languages that have blocks
> enclosed in a start and end token, e.g. '{' and '}'. There is no logic
> in the core jEdit codebase to support indenting languages like Ruby
> and Python, so Edit->Indent->Indent Lines won't work for Ruby.
>
> For Ruby indenting I recommend you use the 'enter' key bound as a
> shortcut to the Ruby plugin "Auto-indent and insert end" action. This
> will for the most part indent your code appropriately as you type it.
> Indenting discrepances will require you to make manual alterations,
> the Edit->Indent->Indent Lines action won't work.

Ah hah! That explains it. I'm coming from the emacs world, where the
mode itself controls the indentation. Thanks... seems like I should be
fine just letting the Ruby plugin do the auto-indentation.

One suggestion: Since I have TAB bound to "Indent Lines", which is
useful in the more C-like languages, it makes manual tab tweaking a bit
of a pain. (I do have ESC-TAB bound to normal tabbing.) One workaround
would be if the Ruby plugin offered a "Smart Indent Lines" function,
which would either go to the standard routine for most buffers, or your
own plugin for Ruby buffers. You could even get super-smart, and if I
hit tab twice in a row on a line, start adding normal tabs so I could
override the default...

--
Jay Levitt |
Wellesley, MA | I feel calm. I feel ready. I can only
Faster: jay at jay dot fm | conclude that's because I don't have a
http://... | full grasp of the situation. - Mark Adler

Karl von Laudermann

5/17/2005 7:54:00 PM

0

Jay Levitt wrote:
>
> One suggestion: Since I have TAB bound to "Indent Lines", which is
> useful in the more C-like languages, it makes manual tab tweaking a
bit
> of a pain. (I do have ESC-TAB bound to normal tabbing.) One
workaround
> would be if the Ruby plugin offered a "Smart Indent Lines" function,
> which would either go to the standard routine for most buffers, or
your
> own plugin for Ruby buffers.

My solution is to have C+[ and C+] mapped to Shift Indent Left/Right.
This makes it easy to increase/decrease the current line indentation.

Belorion

5/17/2005 8:28:00 PM

0

> My solution is to have C+[ and C+] mapped to Shift Indent Left/Right.
> This makes it easy to increase/decrease the current line indentation.

In jEdit one can increase/decrease indent using ALT+(left arrow) or
ALT+(right arrow). I think this is set by default. Works on multiple
lines as well (so if you have more than 1 line highlighted, the indent
will be applied to all of them).

Matt