From: Stefan Monnier Date: Wed, 6 Nov 2013 03:37:03 +0000 (-0500) Subject: * lisp/electric.el (electric-indent-just-newline): New command. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~936 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=feca4e2db9d9dd539b09da9c19f49865952b184d;p=emacs.git * lisp/electric.el (electric-indent-just-newline): New command. (electric-indent-mode-map): New keymap. (electric-indent-mode, electric-pair-mode, electric-layout-mode): Re-add :group which weren't redundant. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5b4cba44021..49dc1685063 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,10 @@ 2013-11-06 Stefan Monnier + * electric.el (electric-indent-just-newline): New command. + (electric-indent-mode-map): New keymap. + (electric-indent-mode, electric-pair-mode, electric-layout-mode): + Re-add :group which weren't redundant. + * electric.el (electric-indent-local-mode): New minor mode. (electric-indent-functions-without-reindent): New var. (electric-indent-post-self-insert-function): Use it. diff --git a/lisp/electric.el b/lisp/electric.el index 9a89587ff93..bb93a1615a7 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -267,6 +267,18 @@ mode set `electric-indent-inhibit', but this can be used as a workaround.") (> pos (line-beginning-position))) (indent-according-to-mode))))) +(defun electric-indent-just-newline (arg) + "Insert just a newline, without any auto-indentation." + (interactive "*P") + (let ((electric-indent-mode nil)) + (newline arg 'interactive))) + +(defvar electric-indent-mode-map + (let ((map (make-sparse-keymap))) + (define-key map [?\C-j] 'electric-indent-just-newline) + map) + "Keymap used for `electric-mode-mode'.") + ;;;###autoload (define-minor-mode electric-indent-mode "Toggle on-the-fly reindentation (Electric Indent mode). @@ -277,7 +289,7 @@ the mode if ARG is omitted or nil. This is a global minor mode. When enabled, it reindents whenever the hook `electric-indent-functions' returns non-nil, or you insert a character from `electric-indent-chars'." - :global t + :global t :group 'electricity (if (not electric-indent-mode) (remove-hook 'post-self-insert-hook #'electric-indent-post-self-insert-function) @@ -427,7 +439,7 @@ an open parenthesis automatically inserts the corresponding closing parenthesis. \(Likewise for brackets, etc.) See options `electric-pair-pairs' and `electric-pair-skip-self'." - :global t + :global t :group 'electricity (if electric-pair-mode (progn (add-hook 'post-self-insert-hook @@ -479,7 +491,7 @@ With a prefix argument ARG, enable Electric Layout mode if ARG is positive, and disable it otherwise. If called from Lisp, enable the mode if ARG is omitted or nil. The variable `electric-layout-rules' says when and how to insert newlines." - :global t + :global t :group 'electricity (if electric-layout-mode (add-hook 'post-self-insert-hook #'electric-layout-post-self-insert-function)