Ruby Emacs-mode with Emacs 21.1.1 
Author Message
 Ruby Emacs-mode with Emacs 21.1.1

Hi,

When I searched the archives, I found the posting below.  Currently I am
using Linux-Mandrake 8.1.  It is true that the emacs 20.7.1 that came with
Mandrake was able to recognize Ruby mode.

However, after I upgraded my emacs to 21.1.1 and followed the instructions
below, it does not work anymore (Emacs reverts to Fundamental mode) and
Emacs prints the following error:

    File mode specification error: (file-error "Cannot open load
file" "ruby-mode")

Is there anything else that I should do?  Thanks.

Regards,

Bill
====================================================================

Quote:

> I'd really appreciate it if somebody could give me a pointer on how to
get
> Emacs to recognize ruby-mode -- where to put the file, what to put in my
> .emacs to get it to recognize the mode, etc....

Basically you need to have the el file distributed with ruby in emacs
resource dir:

/usr/share/emacs/site-lisp/ruby-mode.el

And relevant info to use the ruby-mode for ruby files, in your .emacs, or
in /etc/emacs/site-start.d

For example, the one we provide with Linux-Mandrake in site-start.d
contains:

(autoload 'ruby-mode "ruby-mode" "Ruby editing mode." t)
(add-to-list 'auto-mode-alist '("\.rb$" . ruby-mode))
(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))

Of course, if you install Linux-Mandrake, just install packages Emacs and
Ruby and it will work out of the box :-).



Sat, 10 Jul 2004 02:16:09 GMT  
 Ruby Emacs-mode with Emacs 21.1.1
Check and see if ruby-mode.el is still in your load-path.

C-h v load-path

Quote:

> Hi,

> When I searched the archives, I found the posting below.  Currently I am
> using Linux-Mandrake 8.1.  It is true that the emacs 20.7.1 that came with
> Mandrake was able to recognize Ruby mode.

> However, after I upgraded my emacs to 21.1.1 and followed the instructions
> below, it does not work anymore (Emacs reverts to Fundamental mode) and
> Emacs prints the following error:

>     File mode specification error: (file-error "Cannot open load
> file" "ruby-mode")

> Is there anything else that I should do?  Thanks.

> Regards,

> Bill
> ====================================================================

> > I'd really appreciate it if somebody could give me a pointer on how to
> get
> > Emacs to recognize ruby-mode -- where to put the file, what to put in my
> > .emacs to get it to recognize the mode, etc....

> Basically you need to have the el file distributed with ruby in emacs
> resource dir:

> /usr/share/emacs/site-lisp/ruby-mode.el

> And relevant info to use the ruby-mode for ruby files, in your .emacs, or
> in /etc/emacs/site-start.d

> For example, the one we provide with Linux-Mandrake in site-start.d
> contains:

> (autoload 'ruby-mode "ruby-mode" "Ruby editing mode." t)
> (add-to-list 'auto-mode-alist '("\.rb$" . ruby-mode))
> (add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))

> Of course, if you install Linux-Mandrake, just install packages Emacs and
> Ruby and it will work out of the box :-).

--
Alan Chen
Digikata LLC
http://digikata.com


Sat, 10 Jul 2004 03:08:26 GMT  
 Ruby Emacs-mode with Emacs 21.1.1
Hi,

Thanks for the help.  Yes, it turned out that I had to specify
/usr/local/share/ instead of just copying /usr/share/ as in the
instructions.

By the way, in the C or C++ mode, hitting TAB at the beginning of the
line causes Emacs to auto indent while hitting TAB in the middle of
the line inserts regular tab.  However, in Ruby mode, hitting TAB in
the middle of the line causes Emacs to auto indent and I cannot insert
a regular TAB.  Is there any way to make TAB behavior in Ruby the same
as in C/C++?  Thanks.

Regards,

Bill
==============================================================================

Quote:

> Check and see if ruby-mode.el is still in your load-path.

> C-h v load-path


> > Hi,

> > When I searched the archives, I found the posting below.  Currently I am
> > using Linux-Mandrake 8.1.  It is true that the emacs 20.7.1 that came with
> > Mandrake was able to recognize Ruby mode.

> > However, after I upgraded my emacs to 21.1.1 and followed the instructions
> > below, it does not work anymore (Emacs reverts to Fundamental mode) and
> > Emacs prints the following error:

> >     File mode specification error: (file-error "Cannot open load
> > file" "ruby-mode")

> > Is there anything else that I should do?  Thanks.

> > Regards,

> > Bill
> > ====================================================================

> > > I'd really appreciate it if somebody could give me a pointer on how to
>  get
> > > Emacs to recognize ruby-mode -- where to put the file, what to put in my
> > > .emacs to get it to recognize the mode, etc....

> > Basically you need to have the el file distributed with ruby in emacs
> > resource dir:

> > /usr/share/emacs/site-lisp/ruby-mode.el

> > And relevant info to use the ruby-mode for ruby files, in your .emacs, or
> > in /etc/emacs/site-start.d

> > For example, the one we provide with Linux-Mandrake in site-start.d
> > contains:

> > (autoload 'ruby-mode "ruby-mode" "Ruby editing mode." t)
> > (add-to-list 'auto-mode-alist '("\.rb$" . ruby-mode))
> > (add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))

> > Of course, if you install Linux-Mandrake, just install packages Emacs and
> > Ruby and it will work out of the box :-).



Sat, 10 Jul 2004 05:40:26 GMT  
 Ruby Emacs-mode with Emacs 21.1.1

    Bill> By the way, in the C or C++ mode, hitting TAB at the
    Bill> beginning of the line causes Emacs to auto indent while
    Bill> hitting TAB in the middle of the line inserts regular tab.
    Bill> However, in Ruby mode, hitting TAB in the middle of the line
    Bill> causes Emacs to auto indent and I cannot insert a regular
    Bill> TAB.  Is there any way to make TAB behavior in Ruby the same
    Bill> as in C/C++?  Thanks.

Hmmm ... my C++ mode in emacs does autoindent nomatter where you are
on the line, just like the Ruby mode.

At any rate, to insert a hard tab character, press C-Q TAB (control-Q
and then a tab).  This should work in almost any mode.

--

---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)



Sat, 10 Jul 2004 06:46:49 GMT  
 Ruby Emacs-mode with Emacs 21.1.1

Quote:


>     Bill> By the way, in the C or C++ mode, hitting TAB at the
>     Bill> beginning of the line causes Emacs to auto indent while
>     Bill> hitting TAB in the middle of the line inserts regular tab.
>     Bill> However, in Ruby mode, hitting TAB in the middle of the line
>     Bill> causes Emacs to auto indent and I cannot insert a regular
>     Bill> TAB.  Is there any way to make TAB behavior in Ruby the same
>     Bill> as in C/C++?  Thanks.

> Hmmm ... my C++ mode in emacs does autoindent nomatter where you are
> on the line, just like the Ruby mode.

(setq c-tab-always-indent nil)  ; either 'nil' (false) or 't' (true)

From the documentation for the variable c-tab-always-indent:

    Documentation:
    *Controls the operation of the TAB key.
    If t, hitting TAB always just indents the current line. If nil, hitting
    TAB indents the current line if point is at the left margin or in the
    line's indentation, otherwise it insert a `real' tab character (see
    note). If the symbol `other', then tab is inserted only within literals
    -- defined as comments and strings -- and inside preprocessor
    directives, but the line is always reindented.

    Note: The value of `indent-tabs-mode' will determine whether a real tab
    character will be inserted, or the equivalent number of space. When
    inserting a tab, actually the function stored in the variable
    `c-insert-tab-function' is called.

    Note: indentation of lines containing only comments is also controlled
    by the `c-comment-only-line-offset' variable.

    You can customize this variable.

    Defined in `cc-vars'.

Jim
--

As a math major, I don't have to be able to add -- I just have to be able
to PROVE that I can add.



Sat, 10 Jul 2004 10:05:00 GMT  
 Ruby Emacs-mode with Emacs 21.1.1
I just realized that the feature is only available in C/C++ mode.
There is no such thing as (setq ruby-tab-always-indent nil).

Based on the previous reply, I have been inserting tabs in ruby-mode
using C-Q TAB and it works.  However, after inserting tabs this way
many times, my fingers get tired.  How can I define a short cut using
a control key to enter C-Q TAB?  It it something like (global-set-key
"\C-f" 'xxxx) but I don't know what to enter in xxxx.  Thanks.

Regards,

Bill
==========================================================================

Quote:



> >     Bill> By the way, in the C or C++ mode, hitting TAB at the
> >     Bill> beginning of the line causes Emacs to auto indent while
> >     Bill> hitting TAB in the middle of the line inserts regular tab.
> >     Bill> However, in Ruby mode, hitting TAB in the middle of the line
> >     Bill> causes Emacs to auto indent and I cannot insert a regular
> >     Bill> TAB.  Is there any way to make TAB behavior in Ruby the same
> >     Bill> as in C/C++?  Thanks.

> > Hmmm ... my C++ mode in emacs does autoindent nomatter where you are
> > on the line, just like the Ruby mode.

> (setq c-tab-always-indent nil)     ; either 'nil' (false) or 't' (true)

> Jim



Sat, 10 Jul 2004 22:47:31 GMT  
 Ruby Emacs-mode with Emacs 21.1.1

Quote:

> I just realized that the feature is only available in C/C++ mode.
> There is no such thing as (setq ruby-tab-always-indent nil).

> Based on the previous reply, I have been inserting tabs in ruby-mode
> using C-Q TAB and it works.  However, after inserting tabs this way
> many times, my fingers get tired.  How can I define a short cut using
> a control key to enter C-Q TAB?  It it something like (global-set-key
> "\C-f" 'xxxx) but I don't know what to enter in xxxx.  Thanks.

Here's my Ruby mode hook. Note the calls to "define-key": by using the ruby
mode key map, you affect only that mode.

(setq ruby-mode-hook
      '(lambda ()
         (inf-ruby-keys)
         (setq ruby-indent-level 4)
         (define-key ruby-mode-map "\r" 'ruby-reindent-then-newline-and-indent)
         (define-key ruby-mode-map "\C-c\C-c" 'comment-region)
         (if window-system (font-lock-mode 1))
         )
      )

Jim
--

"Linux was released on August 25th, 1991. Therefore it is a Virgo, not a
Cancer." -- Kevin Lyda



Sat, 10 Jul 2004 23:13:00 GMT  
 Ruby Emacs-mode with Emacs 21.1.1
Hi Jim,

Thanks for the reply.  However, in function (define-key ruby-mode-map
"\C-f" 'xxxx) what should I put as xxxx so that C-f is bound to "C-q,
then TAB"?  Or, what is the function xxxx that simply inserts a real
tab?

Regards,

Bill
===========================================================================

Quote:


> > I just realized that the feature is only available in C/C++ mode.
> > There is no such thing as (setq ruby-tab-always-indent nil).

> > Based on the previous reply, I have been inserting tabs in ruby-mode
> > using C-Q TAB and it works.  However, after inserting tabs this way
> > many times, my fingers get tired.  How can I define a short cut using
> > a control key to enter C-Q TAB?  It it something like (global-set-key
> > "\C-f" 'xxxx) but I don't know what to enter in xxxx.  Thanks.

> Here's my Ruby mode hook. Note the calls to "define-key": by using the ruby
> mode key map, you affect only that mode.

> (setq ruby-mode-hook
>       '(lambda ()
>          (inf-ruby-keys)
>          (setq ruby-indent-level 4)
>          (define-key ruby-mode-map "\r" 'ruby-reindent-then-newline-and-indent)
>          (define-key ruby-mode-map "\C-c\C-c" 'comment-region)
>          (if window-system (font-lock-mode 1))
>          )
>       )

> Jim



Sun, 11 Jul 2004 02:04:47 GMT  
 Ruby Emacs-mode with Emacs 21.1.1

Quote:

> Hi Jim,

> Thanks for the reply.  However, in function (define-key ruby-mode-map
> "\C-f" 'xxxx) what should I put as xxxx so that C-f is bound to "C-q,
> then TAB"?  Or, what is the function xxxx that simply inserts a real
> tab?

It's self-insert-command. So, in your Ruby mode hook add:

    (define-key ruby-mode-map "\t" 'self-insert-command)

Jim
--

"Brought to you again by the Department of Redundancy Department."
    -- Firesign Theatre    



Sun, 11 Jul 2004 04:17:42 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. ruby-mode fix for Emacs 21?

2. Emacs-21 & Python2.1

3. ilisp and Emacs 21

4. pdb misbehaves in emacs-21.2.1

5. Ruby mode for Emacs...

6. ruby-mode in Emacs

7. Here documents and emacs ruby mode

8. Ruby mode for emacs

9. ruby-mode for Emacs crashing

10. error in Ruby emacs-mode

11. ruby emacs mode question

12. Emacs VHDL editing mode (vhdl-mode.el version 2.74)

 

 
Powered by phpBB® Forum Software