ruby-mode.el

  • Thread starter Asfand Yar Qazi
  • Start date
A

Asfand Yar Qazi

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
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: ruby-mode.el"

|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.
 
A

Asfand Yar Qazi

Yukihiro said:
Hi,

In message "Re: ruby-mode.el"

|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 :)
Asfand Yar
 
D

Don Owens

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
 
V

Ville Mattila

Don Owens said:
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
 
B

Ben Giddings

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
 
G

George Ogata

Ben Giddings said:
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/
 
G

George Ogata

Asfand Yar Qazi said:
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)
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.
 
B

Ben Giddings

George said:
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
 
G

George Ogata

Ben Giddings said:
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.
 
B

Brian Schröder

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
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
 
G

Guillaume Marcais

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]

+1

Guillaume.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top