diff options
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/electric.el | 18 |
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 @@ | |||
| 1 | 2013-11-06 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2013-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. | |||
| 277 | This is a global minor mode. When enabled, it reindents whenever | 289 | This is a global minor mode. When enabled, it reindents whenever |
| 278 | the hook `electric-indent-functions' returns non-nil, or you | 290 | the hook `electric-indent-functions' returns non-nil, or you |
| 279 | insert a character from `electric-indent-chars'." | 291 | insert 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 | |||
| 427 | closing parenthesis. \(Likewise for brackets, etc.) | 439 | closing parenthesis. \(Likewise for brackets, etc.) |
| 428 | 440 | ||
| 429 | See options `electric-pair-pairs' and `electric-pair-skip-self'." | 441 | See 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 | |||
| 479 | positive, and disable it otherwise. If called from Lisp, enable | 491 | positive, and disable it otherwise. If called from Lisp, enable |
| 480 | the mode if ARG is omitted or nil. | 492 | the mode if ARG is omitted or nil. |
| 481 | The variable `electric-layout-rules' says when and how to insert newlines." | 493 | The 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) |