aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2013-11-05 22:37:03 -0500
committerStefan Monnier2013-11-05 22:37:03 -0500
commitfeca4e2db9d9dd539b09da9c19f49865952b184d (patch)
treef2709d572b3aed7e29a4a9507db41c5f69aeea39 /lisp
parenta35287ea23112e3e6dc73de6066f31fbe1cb269c (diff)
downloademacs-feca4e2db9d9dd539b09da9c19f49865952b184d.tar.gz
emacs-feca4e2db9d9dd539b09da9c19f49865952b184d.zip
* 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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/electric.el18
2 files changed, 20 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5b4cba44021..49dc1685063 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12013-11-06 Stefan Monnier <monnier@iro.umontreal.ca> 12013-11-06 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * electric.el (electric-indent-just-newline): New command.
4 (electric-indent-mode-map): New keymap.
5 (electric-indent-mode, electric-pair-mode, electric-layout-mode):
6 Re-add :group which weren't redundant.
7
3 * electric.el (electric-indent-local-mode): New minor mode. 8 * electric.el (electric-indent-local-mode): New minor mode.
4 (electric-indent-functions-without-reindent): New var. 9 (electric-indent-functions-without-reindent): New var.
5 (electric-indent-post-self-insert-function): Use it. 10 (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.")
267 (> pos (line-beginning-position))) 267 (> pos (line-beginning-position)))
268 (indent-according-to-mode))))) 268 (indent-according-to-mode)))))
269 269
270(defun electric-indent-just-newline (arg)
271 "Insert just a newline, without any auto-indentation."
272 (interactive "*P")
273 (let ((electric-indent-mode nil))
274 (newline arg 'interactive)))
275
276(defvar electric-indent-mode-map
277 (let ((map (make-sparse-keymap)))
278 (define-key map [?\C-j] 'electric-indent-just-newline)
279 map)
280 "Keymap used for `electric-mode-mode'.")
281
270;;;###autoload 282;;;###autoload
271(define-minor-mode electric-indent-mode 283(define-minor-mode electric-indent-mode
272 "Toggle on-the-fly reindentation (Electric Indent mode). 284 "Toggle on-the-fly reindentation (Electric Indent mode).
@@ -277,7 +289,7 @@ the mode if ARG is omitted or nil.
277This is a global minor mode. When enabled, it reindents whenever 289This is a global minor mode. When enabled, it reindents whenever
278the hook `electric-indent-functions' returns non-nil, or you 290the hook `electric-indent-functions' returns non-nil, or you
279insert a character from `electric-indent-chars'." 291insert a character from `electric-indent-chars'."
280 :global t 292 :global t :group 'electricity
281 (if (not electric-indent-mode) 293 (if (not electric-indent-mode)
282 (remove-hook 'post-self-insert-hook 294 (remove-hook 'post-self-insert-hook
283 #'electric-indent-post-self-insert-function) 295 #'electric-indent-post-self-insert-function)
@@ -427,7 +439,7 @@ an open parenthesis automatically inserts the corresponding
427closing parenthesis. \(Likewise for brackets, etc.) 439closing parenthesis. \(Likewise for brackets, etc.)
428 440
429See options `electric-pair-pairs' and `electric-pair-skip-self'." 441See options `electric-pair-pairs' and `electric-pair-skip-self'."
430 :global t 442 :global t :group 'electricity
431 (if electric-pair-mode 443 (if electric-pair-mode
432 (progn 444 (progn
433 (add-hook 'post-self-insert-hook 445 (add-hook 'post-self-insert-hook
@@ -479,7 +491,7 @@ With a prefix argument ARG, enable Electric Layout mode if ARG is
479positive, and disable it otherwise. If called from Lisp, enable 491positive, and disable it otherwise. If called from Lisp, enable
480the mode if ARG is omitted or nil. 492the mode if ARG is omitted or nil.
481The variable `electric-layout-rules' says when and how to insert newlines." 493The variable `electric-layout-rules' says when and how to insert newlines."
482 :global t 494 :global t :group 'electricity
483 (if electric-layout-mode 495 (if electric-layout-mode
484 (add-hook 'post-self-insert-hook 496 (add-hook 'post-self-insert-hook
485 #'electric-layout-post-self-insert-function) 497 #'electric-layout-post-self-insert-function)