Ruby-mode.el

Hi,

Some things about the new ruby-mode.el in Ruby 1.8.2:

font-lock doesn't turn on by default unless I replace the line in ruby-mode.el that reads (eval-when-compile (require 'cl)) with (eval-when-compile (require 'cl) (require 'font-lock)). Is this how it should be?

Ctrl-Q for word-wrapping comments no longer works! It used to word wrap code as well as comments unless a new-line separated them, which was junky but still at least it was something. It no longer works now - what's up? Surely it should be possible to use the comment-wrapping code from (for example) sh-mode?

Thanks,
  Asfand Yar

Hi,

font-lock doesn't turn on by default unless I replace the line in
ruby-mode.el that reads (eval-when-compile (require 'cl)) with
(eval-when-compile (require 'cl) (require 'font-lock)). Is this how
it should be?

ruby-mode.el does not always require font-lock, for example, it should
work with hilit19 as well, so that requiring it by eval-when-compile
is not suitable. I personally haven't seen the problem. I'm not sure
how to avoid your problem.

Ctrl-Q for word-wrapping comments no longer works! It used to word
wrap code as well as comments unless a new-line separated them, which
was junky but still at least it was something. It no longer works now
- what's up? Surely it should be possible to use the comment-wrapping
code from (for example) sh-mode?

I don't think ruby-mode provides any Ctrl-Q binding, which is reserved
for quoted-insert. Or maybe you meant Meta-Q, which is not modified
by ruby-mode by default. Perhaps it belongs to your personal settings.

              matz.

···

In message "Re: ruby-mode.el" on Wed, 9 Feb 2005 17:40:06 +0900, Asfand Yar Qazi <ay1204@qazi.f2s.com> writes:

Does the new ruby-mode.el handle indentation of hanging um... whatsits better?

What I mean is when I have code like so:

if (foo)
   puts("This string is too long for one line, " +
        "so I'm splitting it into two for readability")
end

That's how I want it indented. However, ruby-mode seems to want to indent the continued line (starting with "so ...") so that instead of the quotes lining up, instead ruby-mode wants to indent the second line so that it continues after the + as in:

if (foo)
   puts("This string is too long for one line, " +
                                                  "so I'm splitting it into two for readability")
end

That's not what I'd expect at all, and not how Emacs handles this sort of situation in the other modes I use. Does anybody know why it is this way, and how to make it the way I want it to be?

Ben

Yukihiro Matsumoto wrote:

Hi,

>font-lock doesn't turn on by default unless I replace the line in >ruby-mode.el that reads (eval-when-compile (require 'cl)) with >(eval-when-compile (require 'cl) (require 'font-lock)). Is this how >it should be?

ruby-mode.el does not always require font-lock, for example, it should
work with hilit19 as well, so that requiring it by eval-when-compile
is not suitable. I personally haven't seen the problem. I'm not sure
how to avoid your problem.

It's been a recurring problem for me, actually. I'll see if I can find a fix, and post it to the group.

>Ctrl-Q for word-wrapping comments no longer works! It used to word >wrap code as well as comments unless a new-line separated them, which >was junky but still at least it was something. It no longer works now >- what's up? Surely it should be possible to use the comment-wrapping >code from (for example) sh-mode?

I don't think ruby-mode provides any Ctrl-Q binding, which is reserved
for quoted-insert. Or maybe you meant Meta-Q, which is not modified
by ruby-mode by default. Perhaps it belongs to your personal settings.

              matz.

Sorry, that should have been Meta-Q. OK, I'll see if my personal settings are bodged up.

Thanks for the reply (I feel like I've been talking to a celebrity :slight_smile:
            Asfand Yar

···

In message "Re: ruby-mode.el" > on Wed, 9 Feb 2005 17:40:06 +0900, Asfand Yar Qazi <ay1204@qazi.f2s.com> writes:

Ben Giddings <bg-rubytalk@infofiend.com> writes:

Does the new ruby-mode.el handle indentation of hanging um... whatsits
better?

What I mean is when I have code like so:

if (foo)
   puts("This string is too long for one line, " +
        "so I'm splitting it into two for readability")
end

That's how I want it indented. However, ruby-mode seems to want to
indent the continued line (starting with "so ...") so that instead of
the quotes lining up, instead ruby-mode wants to indent the second line
so that it continues after the + as in:

if (foo)
   puts("This string is too long for one line, " +
                                                  "so I'm splitting it
into two for readability")
end

That's not what I'd expect at all, and not how Emacs handles this sort
of situation in the other modes I use. Does anybody know why it is this
way, and how to make it the way I want it to be?

The latest version does it a bit better:

if foo
  puts('foo' +
         'bar' +
         'baz')
end

Not exactly what you want, but probably intentional. You can get the
latest version from CVS. The misc/ directory. Online at:

http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/misc/

Has a paren-mode kind of thing been considered for ruby-mode where
having the cursor over an "end" would highlight or blink the cursor
over the corresponding "begin", "while", etc. at the beginning of the
block? I think that would be very useful in the case where you have a
lot of blocks ending together, just as it is for many ending braces in
Perl, for example.

Don

···

On Fri, 11 Feb 2005 01:10:11 +0900, Asfand Yar Qazi <ay1204@qazi.f2s.com> wrote:

Yukihiro Matsumoto wrote:
> Hi,
>
> In message "Re: ruby-mode.el" > > on Wed, 9 Feb 2005 17:40:06 +0900, Asfand Yar Qazi <ay1204@qazi.f2s.com> writes:
>
> >font-lock doesn't turn on by default unless I replace the line in
> >ruby-mode.el that reads (eval-when-compile (require 'cl)) with
> >(eval-when-compile (require 'cl) (require 'font-lock)). Is this how
> >it should be?
>
> ruby-mode.el does not always require font-lock, for example, it should
> work with hilit19 as well, so that requiring it by eval-when-compile
> is not suitable. I personally haven't seen the problem. I'm not sure
> how to avoid your problem.

It's been a recurring problem for me, actually. I'll see if I can
find a fix, and post it to the group.

>
> >Ctrl-Q for word-wrapping comments no longer works! It used to word
> >wrap code as well as comments unless a new-line separated them, which
> >was junky but still at least it was something. It no longer works now
> >- what's up? Surely it should be possible to use the comment-wrapping
> >code from (for example) sh-mode?
>
> I don't think ruby-mode provides any Ctrl-Q binding, which is reserved
> for quoted-insert. Or maybe you meant Meta-Q, which is not modified
> by ruby-mode by default. Perhaps it belongs to your personal settings.
>
> matz.

Sorry, that should have been Meta-Q. OK, I'll see if my personal
settings are bodged up.

Thanks for the reply (I feel like I've been talking to a celebrity :slight_smile:
            Asfand Yar

--
Don Owens
regexman@gmail.com

Asfand Yar Qazi <ay1204@qazi.f2s.com> writes:

Yukihiro Matsumoto wrote:

Hi,
>font-lock doesn't turn on by default unless I replace the line in
>ruby-mode.el that reads (eval-when-compile (require 'cl)) with
>(eval-when-compile (require 'cl) (require 'font-lock)). Is this
how |it should be?
ruby-mode.el does not always require font-lock, for example, it
should
work with hilit19 as well, so that requiring it by eval-when-compile
is not suitable. I personally haven't seen the problem. I'm not sure
how to avoid your problem.

It's been a recurring problem for me, actually. I'll see if I can
find a fix, and post it to the group.

require-ing 'font-lock doesn't turn it on. To have your ruby files
auto-fontified, try this in init.el:

(add-hook 'ruby-mode-hook 'turn-on-font-lock)

>Ctrl-Q for word-wrapping comments no longer works! It used to word
>wrap code as well as comments unless a new-line separated them,
which |was junky but still at least it was something. It no longer
works now |- what's up? Surely it should be possible to use the
comment-wrapping |code from (for example) sh-mode?
I don't think ruby-mode provides any Ctrl-Q binding, which is
reserved
for quoted-insert. Or maybe you meant Meta-Q, which is not modified
by ruby-mode by default. Perhaps it belongs to your personal settings.
              matz.

Sorry, that should have been Meta-Q. OK, I'll see if my personal
settings are bodged up.

Jim Weirich posted a comment filler to:

  http://www.rubygarden.org/ruby?EmacsExtensions

I'll post my one there soon too. It does more, but it's longer and
uglier.

···

In message "Re: ruby-mode.el" >> on Wed, 9 Feb 2005 17:40:06 +0900, Asfand Yar Qazi <ay1204@qazi.f2s.com> writes:

George Ogata wrote:

The latest version does it a bit better:

if foo
  puts('foo' +
         'bar' +
         'baz')
end

Not exactly what you want, but probably intentional. You can get the
latest version from CVS. The misc/ directory. Online at:

If the strings are longer than "foo" does it still start 2 (or maybe whatever your basic-indent setting is) spaces in? Or is the space relative to the position of the +?

I can live with an extra indentation, but not with:

"foo is the Foo" +
                    "bar is the Bar"

Ben

Don Owens <regexman@gmail.com> writes:

Has a paren-mode kind of thing been considered for ruby-mode where
having the cursor over an "end" would highlight or blink the cursor
over the corresponding "begin", "while", etc. at the beginning of the
block? I think that would be very useful in the case where you have a
lot of blocks ending together, just as it is for many ending braces in
Perl, for example.

Don

  Arachno ruby 0.4 has very good feature (control-d control-m) that shows
  matching end very clearly. Also it has identitation lines ala scite
  so you'll understand code much quicker.

- Ville

Ben Giddings <bg-rubytalk@infofiend.com> writes:

If the strings are longer than "foo" does it still start 2 (or maybe
whatever your basic-indent setting is) spaces in?

Yes.

Or is the space relative to the position of the +?

No.

While we are at it, is it possible to make xemacs always indent arrays as if they were contained in brackets?

This is how ruby-mode indents:

foo_bar_baz = [1, 2, 3, 4,
  5, 6, 7, 8]

foo_bar_baz = ([1, 2, 3, 4,
                 5, 6, 7, 8])

This is what I want:

foo_bar_baz = [1, 2, 3, 4,
               5, 6, 7, 8]

regards,

Brian

···

On Fri, 11 Feb 2005 06:30:16 +0900 Ben Giddings <bg-rubytalk@infofiend.com> wrote:

George Ogata wrote:
> The latest version does it a bit better:
>
> if foo
> puts('foo' +
> 'bar' +
> 'baz')
> end
>
> Not exactly what you want, but probably intentional. You can get the
> latest version from CVS. The misc/ directory. Online at:

If the strings are longer than "foo" does it still start 2 (or maybe
whatever your basic-indent setting is) spaces in? Or is the space
relative to the position of the +?

I can live with an extra indentation, but not with:

"foo is the Foo" +
                    "bar is the Bar"

Ben

+1

Guillaume.

···

On Fri, 2005-02-11 at 09:34 +0900, Brian Schröder wrote:

> Ben
>
>
While we are at it, is it possible to make xemacs always indent arrays as if they were contained in brackets?

This is how ruby-mode indents:

foo_bar_baz = [1, 2, 3, 4,
  5, 6, 7, 8]

foo_bar_baz = ([1, 2, 3, 4,
                 5, 6, 7, 8])

This is what I want:

foo_bar_baz = [1, 2, 3, 4,
               5, 6, 7, 8]