diff options
| author | Stefan Monnier | 2014-03-20 13:14:45 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-03-20 13:14:45 -0400 |
| commit | 494ec1e71d7f725534be9a5518f0a2bdfe35d2c3 (patch) | |
| tree | 119fdfb556c38c5b260d9e8046bc1a0510196ddf /lisp | |
| parent | 049fac7c941e4b7afad0471c209dc15193460282 (diff) | |
| download | emacs-494ec1e71d7f725534be9a5518f0a2bdfe35d2c3.tar.gz emacs-494ec1e71d7f725534be9a5518f0a2bdfe35d2c3.zip | |
* lisp/electric.el (electric-newline-and-maybe-indent): New command.
Bind it globally to C-j.
(electric-indent-mode): Don't mess with the global map any more.
Don't drop the post-self-insert-hook is some buffer is still using it.
* lisp/bindings.el (global-map): Remove C-j binding.
Fixes: debbugs:16770
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/bindings.el | 1 | ||||
| -rw-r--r-- | lisp/electric.el | 24 |
3 files changed, 25 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8b93411269f..857c086790e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2014-03-20 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2014-03-20 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * electric.el (electric-newline-and-maybe-indent): New command. | ||
| 4 | Bind it globally to C-j. | ||
| 5 | (electric-indent-mode): Don't mess with the global map any more. | ||
| 6 | Don't drop the post-self-insert-hook is some buffer is still using it | ||
| 7 | (bug#16770). | ||
| 8 | * bindings.el (global-map): Remove C-j binding. | ||
| 9 | |||
| 3 | * emacs-lisp/nadvice.el (advice--make-docstring): Try harder to find | 10 | * emacs-lisp/nadvice.el (advice--make-docstring): Try harder to find |
| 4 | the docstring of functions advised before dumping (bug#16993). | 11 | the docstring of functions advised before dumping (bug#16993). |
| 5 | 12 | ||
diff --git a/lisp/bindings.el b/lisp/bindings.el index fac34ed4106..7093b8e662f 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el | |||
| @@ -795,7 +795,6 @@ if `inhibit-field-text-motion' is non-nil." | |||
| 795 | ;; suspend only the relevant terminal. | 795 | ;; suspend only the relevant terminal. |
| 796 | (substitute-key-definition 'suspend-emacs 'suspend-frame global-map) | 796 | (substitute-key-definition 'suspend-emacs 'suspend-frame global-map) |
| 797 | 797 | ||
| 798 | (define-key global-map "\C-j" 'newline-and-indent) | ||
| 799 | (define-key global-map "\C-m" 'newline) | 798 | (define-key global-map "\C-m" 'newline) |
| 800 | (define-key global-map "\C-o" 'open-line) | 799 | (define-key global-map "\C-o" 'open-line) |
| 801 | (define-key esc-map "\C-o" 'split-line) | 800 | (define-key esc-map "\C-o" 'split-line) |
diff --git a/lisp/electric.el b/lisp/electric.el index 7debe0b7f98..4e24101dd6a 100644 --- a/lisp/electric.el +++ b/lisp/electric.el | |||
| @@ -286,6 +286,20 @@ mode set `electric-indent-inhibit', but this can be used as a workaround.") | |||
| 286 | (let ((electric-indent-mode nil)) | 286 | (let ((electric-indent-mode nil)) |
| 287 | (newline arg 'interactive))) | 287 | (newline arg 'interactive))) |
| 288 | 288 | ||
| 289 | ;;;###autoload(define-key global-map "\C-j" 'electric-newline-and-maybe-indent) | ||
| 290 | ;;;###autoload | ||
| 291 | (defun electric-newline-and-maybe-indent () | ||
| 292 | "Insert a newline. | ||
| 293 | If `electric-indent-mode' is enabled, that's that, but if it | ||
| 294 | is *disabled* then additionally indent according to major mode. | ||
| 295 | Indentation is done using the value of `indent-line-function'. | ||
| 296 | In programming language modes, this is the same as TAB. | ||
| 297 | In some text modes, where TAB inserts a tab, this command indents to the | ||
| 298 | column specified by the function `current-left-margin'." | ||
| 299 | (interactive "*") | ||
| 300 | (if electric-indent-mode | ||
| 301 | (electric-indent-just-newline nil) | ||
| 302 | (newline-and-indent))) | ||
| 289 | 303 | ||
| 290 | ;;;###autoload | 304 | ;;;###autoload |
| 291 | (define-minor-mode electric-indent-mode | 305 | (define-minor-mode electric-indent-mode |
| @@ -303,14 +317,12 @@ use `electric-indent-local-mode'." | |||
| 303 | :initialize 'custom-initialize-delay | 317 | :initialize 'custom-initialize-delay |
| 304 | :init-value t | 318 | :init-value t |
| 305 | (if (not electric-indent-mode) | 319 | (if (not electric-indent-mode) |
| 306 | (progn | 320 | (unless (catch 'found |
| 307 | (when (eq (lookup-key global-map [?\C-j]) | 321 | (dolist (buf (buffer-list)) |
| 308 | 'electric-indent-just-newline) | 322 | (with-current-buffer buf |
| 309 | (define-key global-map [?\C-j] 'newline-and-indent)) | 323 | (if electric-indent-mode (throw 'found t))))) |
| 310 | (remove-hook 'post-self-insert-hook | 324 | (remove-hook 'post-self-insert-hook |
| 311 | #'electric-indent-post-self-insert-function)) | 325 | #'electric-indent-post-self-insert-function)) |
| 312 | (when (eq (lookup-key global-map [?\C-j]) 'newline-and-indent) | ||
| 313 | (define-key global-map [?\C-j] 'electric-indent-just-newline)) | ||
| 314 | (add-hook 'post-self-insert-hook | 326 | (add-hook 'post-self-insert-hook |
| 315 | #'electric-indent-post-self-insert-function) | 327 | #'electric-indent-post-self-insert-function) |
| 316 | (electric--sort-post-self-insertion-hook))) | 328 | (electric--sort-post-self-insertion-hook))) |