Emacs Ruby Electric Does Not Insert End

I have a Ruby Electric mode installed through ELPA.

I visited the ruby โ€‹โ€‹file ~/test.rb

Ch m shows that ruby โ€‹โ€‹electric mode is turned on as a font lock, see output below

 Enabled minor modes: Auto-Compression Auto-Encryption Blink-Cursor Column-Number Delete-Selection File-Name-Shadow Global-Font-Lock Global-Linum Iswitchb Line-Number Menu-Bar Mouse-Wheel Shell-Dirtrack Tooltip Transient-Mark 

However, when I enter the code, for example:

 class Test def foo() 

I do not get auto end automatically inserted when RET pressed

UPDATE

I installed via package-list , as recommended on the page I found, which I thought belonged to the author. Looking at the source ~/emacs.d/elpa/ruby-electric-1.1/ruby-electric.el , I see the following:

 ;; FIXME: it should be available in next versions of ruby-mode.el (defun ruby-insert-end () (interactive) (insert "end") (ruby-indent-line t) (end-of-line)) 

So it looks like I have a bad file, try another one.

UPDATE

I used ruby-electric.el , downloaded from http://svn.ruby-lang.org/repos/ruby/tags/v1_9_2_0/misc/ruby-electric.el

Link to this article http://appsintheopen.com/articles/1-setting-up-emacs-for-rails-development/part/7-emacs-ruby-foo

Then took this gist https://gist.github.com/1213051 , adding this to ruby-electric.el

 (defun ruby-insert-end () "Insert \"end\" at point and reindent current line." (interactive) (insert "end") (ruby-indent-line t) (end-of-line)) 

And this hook in my .emacs , it also works without a hook

 (add-hook 'ruby-mode-hook (lambda () (require 'ruby-electric) (ruby-electric-mode t))) 

As discussed in this section of google groups; https://groups.google.com/forum/?fromgroups#!msg/emacs-on-rails/Cuh_x5eCK_M/KDwjY4K6X1YJ

+7
source share
2 answers

Make sure it says REl in the emacs status bar.

I downloaded the ruby-electric from here:
http://shylock.uw.hu/Emacs/ruby-electric.el

Then I loaded the library into emacs and went into the ruby โ€‹โ€‹file and activated the ruby โ€‹โ€‹electric with:

 Mx ruby-electric-mode 

When I print class and hit the space, it automatically fills end (emacs 23 works). You might want to give this version of ruby-electric.el try if you cannot get it to work with ELPA.

+4
source

You need to enable "ruby-extra" to use "ruby-electric":

https://github.com/ruby/ruby/blob/trunk/misc/ruby-additional.el

Someday you need to merge into emacs.

0
source

All Articles