On 8/15/06, Marshall T. Vandegrift <llasram / gmail.com> wrote:
> "John Gabriele" <jmg3000 / gmail.com> writes:
>
> >> (autoload 'ruby-mode "ruby-mode" "Mode for editing ruby source files")
> >> (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
> >> (add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))
> >> (autoload 'run-ruby "inf-ruby" "Run an inferior Ruby process")
> >> (autoload 'inf-ruby-keys "inf-ruby" "Set local key defs for inf-ruby
> >> in ruby-mode")
> >
> > I appended those to my ~/.emacs file, but there's still no syntax
> > highlighting when I open a Ruby source file.
>
> Which OS / distro are you running?

Right now: Debian Etch. At home: Ubuntu 6.06. On servers, usually Sarge.

> Many provide a package which
> separately er... packages the Ruby elisp files and makes sure they're
> in the load path, etc.  On Debian (and Ubuntu?) the package is named
> ruby1.8-elisp for ruby 1.8.

Thanks. Dunno how I missed that. I'll try it if we can't get this
working using what we have (the files from ruby-1.8.4, and my ~/.emacs
file). Maybe that package comes with some kind of post-inst script
that modifies some system-wide emacs config file... (?)

> > Also, you mention to add ruby-mode.el to the "autoload list", but you
> > have three lines above for adding stuff to this autoload list. Are
> > ruby-mode, run-ruby, and inf-ruby-keys three separate thingies inside
> > ruby-mode.el?
>
> What the autoload function does is make Emacs load a particular file
> (e.g., "ruby-mode") when you user a particular function (e.g.,
> 'ruby-mode).

Ah. The single-quote mark indicates a function name maybe...

>  Multiple files generally means multiple autoload
> invocations.  Ask your local Emacs installation for more information
> with C-h f autoload RET!

Ok.

> The "ruby-mode.el" file contains the main Ruby editing mode.  The file
> "ruby-electric.el" contains so-termed "electric" keybindings for the
> Ruby editing mode (more on that later).  The file "inf-ruby" has code
> for interacting with an "inferior" ruby process communicating with
> Emacs; i.e., running irb in an Emacs window, sending it code from
> other buffers, etc.

Ah. Looks like I should copy the .../src/ruby-1.8.4/misc/inf-ruby.el
to my ~/.emacs.d as well then. I'd only previously copied the one
ruby-mode.el file.

> > but I've already got that (global-font-lock-mode t nil (font-lock)) in
> > my ~/.emacs file. Do I need that "add-hook" line too?
>
> Nope.
>
> > I've tried appending it to the end of ~/.emacs, but still no syntax
> > highlighting.
>
> If you have global-font-lock-mode enabled and are in Ruby mode, you
> should see syntax highlighting.  Do M-x customize-variable

(I hit return after that. Continuing...)

> global-font-lock-mode RET to make sure that customization is being
> loaded properly.

It says non-nil, so I that should mean that Global-Font-Lock mode is enabled.

> If so, when you open a file ending in '.rb' do you
> see "Ruby" in the modeline?

No. It says "Fundamental".

> If you don't see it, then your
> auto-mode-alist addition isn't getting run.  Can you manually switch
> to ruby-mode with M-x ruby-mode RET?

No. I get "[No Match]". Can't autocomplete it either. I bet I need to
copy that inf_ruby.el file into ~/.emacs.d...

Nope. "File mode specification error: (file-error "Cannot open load
file" "ruby-mode")". Note, it said that without inf_ruby.el in place
as well -- I just hadn't noticed.

Maybe I'm supposed to copy these .el files to some subdirectory
*beneath* ~/.emacs.d?

> If not, then the ruby elisp code
> isn't being made available to your Emacs instance.
>
> > Also, I've read here and there on nntp://gnu.emacs.help that the way
> > I'm trying to get all spaces (and no tabs at all), with 4-space
> > indents:
> >
> > |
> > | '(indent-tabs-mode nil)
> > | '(tab-width 4)
> > |
> >
> > is "evil". Am I doing it right? So far, tabs seem to be coming out
> > just the way I want. :)
>
> Because (1) some tools like 'make' and really old versions of 'sh'
> consider tabs vs. spaces significant, (2a) you can stomp on the toes
> of people who do use tabs when editing their files, and (2b) you can
> create extraneous diffs when editing files which do contain tabs.
> Emacs largely avoid (1) for you automatically, and as for (2) I think
> people who use tabs deserve to be stomped on ;-).

I'll take that as a "yes" that my settings are suitable for what I'm after. :)

> [snip notes on ruby-electric]
>
> Anyway, hope this helps!

Yes, it does! Thank you. When we're done here, I'll try to condense
this tread into something suitable for the wiki.

---John