From: james.d.masters@... Date: 2007-02-09T08:35:06+09:00 Subject: Re: auto indentation in ruby electric mode On Feb 8, 9:04 am, dannyy...@gmail.com wrote: > Hi, > I'm learning to use Emacs to program Ruby. The ruby-electric-mode > works well except that after I hit ENTER, my cursor will not be > automatically indented. For example, if I type "def foo" and then > ENTER, my cursor will be placed at the first column instead of being > properly indented, say, two spaces to the right of "def". Is there any > way to make the electric mode do auto indentation? Thanks! Here's what I picked up from a website about a month ago (and my left pinkey is much happier now): ;; Automatically indent the next line... (mapcar (lambda (mode) (let ((mode-hook (intern (concat (symbol-name mode) "-hook"))) (mode-map (intern (concat (symbol-name mode) "-map")))) (add-hook mode-hook `(lambda nil (local-set-key (kbd "RET") (or (lookup-key ,mode-map "\C-j") (lookup-key global-map "\C- j"))))))) '(ada-mode c-mode c++-mode cperl-mode emacs-lisp-mode java-mode html- mode lisp-mode php-mode ruby-mode sh-mode sgml-mode))