Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redefining ENTER key in Emacs

Tags:

emacs

scala

I don't know elisp, but I'm trying to do something like the following:

(add-hook
 'scala-mode-hook
 (lambda ()
   (define-key scala-mode-map (kbd "RET") (lambda ()
                                            (scala-newline)
                                            (scala-indent-line)))))

Goal is to call the two functions each time I hit the ENTER key. How do I actually do this?

like image 428
qrest Avatar asked Dec 03 '22 11:12

qrest


1 Answers

I do essentially this in so many modes that I've squashed them all together:

(mapcar (lambda (hooksym)
          (add-hook hooksym
                    (lambda ()
                      (local-set-key  (kbd "C-m") 'newline-and-indent)
                      )))
        '(
          clojure-mode-hook
          emacs-lisp-mode-hook
          erlang-mode-hook
          java-mode-hook
          js-mode-hook
          lisp-interaction-mode-hook
          lisp-mode-hook
          makefile-mode-hook
          nxml-mode-hook
          python-mode-hook
          ruby-mode-hook
          scheme-mode-hook
          sh-mode-hook
          ))

Just stick scala-mode-hook in there somewhere and it'll work for you too :)

like image 196
offby1 Avatar answered Dec 17 '22 03:12

offby1