J
Joe Peterson
I've done some searching to find an emacs configuration that will allow
highlighting and indentation for eruby and .rhtml files. I've found
some solutions that work, partially, but none work flawlessly. The
current problem I am stuck on is that blocks starting with "do" do not
indent properly if they are the first indentable block in the code. It
could have to do with the "special case" for "do iter blocks" in
ruby-mode.el, but I have not yet figured out the solution. First of
all, here's the .emacs code that I am using:
(require 'mmm-mode)
(require 'ruby-mode)
(setq mmm-global-mode 'maybe)
(setq mmm-submode-decoration-level 0)
(mmm-add-classes
'((eruby-mode
:submode ruby-mode
:front "<%[=#]?"
:back "%>")))
(add-to-list 'auto-mode-alist '("\\.rhtml$" . html-mode))
(add-to-list 'mmm-mode-ext-classes-alist '(html-mode nil eruby-mode))
And here's my example .rhtml code:
<title>Yo man!</title>
<%
require "cgi"
cgi = CGI.new
puts cgi["foo"]
i = 0
j = 1
500.times do
puts j
k = i + j
i = j
j = k
end
%>
Note the improperly indented "puts" on the first line of the do block
starting with "500.times do". If I hit tab on that line, it does not
indent. If, however, I put the following anywhere before this block:
def foo
a = 1
end
...then indentation inside the "500.times" block works! Other things,
like "if" blocks, also work. It is as if there must be an example of a
non-do block first to initialize things.
This strangeness does not happen with plain ruby-mode (used with .rb
files), but it does happen when using mmm-mode or even two-mode-mode to
handle .rhtml files.
I do not know whether there is a bug in ruby-mode.el that only shows
itself when used in multi-mode cases, or if the problem lies elsewhere.
If anyone knows a workaround, it would be much appreciated.
Thanks, LavaJoe
highlighting and indentation for eruby and .rhtml files. I've found
some solutions that work, partially, but none work flawlessly. The
current problem I am stuck on is that blocks starting with "do" do not
indent properly if they are the first indentable block in the code. It
could have to do with the "special case" for "do iter blocks" in
ruby-mode.el, but I have not yet figured out the solution. First of
all, here's the .emacs code that I am using:
(require 'mmm-mode)
(require 'ruby-mode)
(setq mmm-global-mode 'maybe)
(setq mmm-submode-decoration-level 0)
(mmm-add-classes
'((eruby-mode
:submode ruby-mode
:front "<%[=#]?"
:back "%>")))
(add-to-list 'auto-mode-alist '("\\.rhtml$" . html-mode))
(add-to-list 'mmm-mode-ext-classes-alist '(html-mode nil eruby-mode))
And here's my example .rhtml code:
<title>Yo man!</title>
<%
require "cgi"
cgi = CGI.new
puts cgi["foo"]
i = 0
j = 1
500.times do
puts j
k = i + j
i = j
j = k
end
%>
Note the improperly indented "puts" on the first line of the do block
starting with "500.times do". If I hit tab on that line, it does not
indent. If, however, I put the following anywhere before this block:
def foo
a = 1
end
...then indentation inside the "500.times" block works! Other things,
like "if" blocks, also work. It is as if there must be an example of a
non-do block first to initialize things.
This strangeness does not happen with plain ruby-mode (used with .rb
files), but it does happen when using mmm-mode or even two-mode-mode to
handle .rhtml files.
I do not know whether there is a bug in ruby-mode.el that only shows
itself when used in multi-mode cases, or if the problem lies elsewhere.
If anyone knows a workaround, it would be much appreciated.
Thanks, LavaJoe