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 | |
| 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
| -rw-r--r-- | admin/FOR-RELEASE | 198 | ||||
| -rw-r--r-- | doc/misc/vip.texi | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/bindings.el | 1 | ||||
| -rw-r--r-- | lisp/electric.el | 24 |
5 files changed, 125 insertions, 107 deletions
diff --git a/admin/FOR-RELEASE b/admin/FOR-RELEASE index 8b6bddbbd2f..6af5027f73c 100644 --- a/admin/FOR-RELEASE +++ b/admin/FOR-RELEASE | |||
| @@ -162,110 +162,110 @@ TUTORIAL.zh | |||
| 162 | 162 | ||
| 163 | ** Check the manual. | 163 | ** Check the manual. |
| 164 | 164 | ||
| 165 | abbrevs.texi cyd | 165 | abbrevs.texi |
| 166 | ack.texi rgm | 166 | ack.texi |
| 167 | anti.texi cyd | 167 | anti.texi |
| 168 | arevert-xtra.texi cyd | 168 | arevert-xtra.texi |
| 169 | basic.texi cyd | 169 | basic.texi |
| 170 | buffers.texi cyd | 170 | buffers.texi |
| 171 | building.texi cyd | 171 | building.texi |
| 172 | calendar.texi rgm | 172 | calendar.texi |
| 173 | cal-xtra.texi rgm | 173 | cal-xtra.texi |
| 174 | cmdargs.texi cyd | 174 | cmdargs.texi |
| 175 | commands.texi cyd | 175 | commands.texi |
| 176 | custom.texi cyd | 176 | custom.texi |
| 177 | dired.texi cyd | 177 | dired.texi |
| 178 | dired-xtra.texi rgm | 178 | dired-xtra.texi |
| 179 | display.texi cyd | 179 | display.texi |
| 180 | emacs.texi rgm | 180 | emacs.texi |
| 181 | emacs-xtra.texi rgm | 181 | emacs-xtra.texi |
| 182 | emerge-xtra.texi rgm | 182 | emerge-xtra.texi |
| 183 | entering.texi cyd | 183 | entering.texi |
| 184 | files.texi cyd | 184 | files.texi |
| 185 | fixit.texi cyd | 185 | fixit.texi |
| 186 | fortran-xtra.texi rgm | 186 | fortran-xtra.texi |
| 187 | frames.texi cyd | 187 | frames.texi |
| 188 | glossary.texi rgm | 188 | glossary.texi |
| 189 | help.texi cyd | 189 | help.texi |
| 190 | indent.texi cyd | 190 | indent.texi |
| 191 | killing.texi cyd | 191 | killing.texi |
| 192 | kmacro.texi cyd | 192 | kmacro.texi |
| 193 | macos.texi rgm (can't actually test any of it though) | 193 | macos.texi |
| 194 | maintaining.texi cyd | 194 | maintaining.texi |
| 195 | mark.texi cyd | 195 | mark.texi |
| 196 | mini.texi rgm | 196 | mini.texi |
| 197 | misc.texi cyd | 197 | misc.texi |
| 198 | modes.texi cyd | 198 | modes.texi |
| 199 | msdog.texi rgm (can't actually test any of it though) | 199 | msdog.texi |
| 200 | msdog-xtra.texi rgm (can't actually test any of it though) | 200 | msdog-xtra.texi |
| 201 | mule.texi rgm (not 100% sure about "Fontsets") | 201 | mule.texi |
| 202 | m-x.texi cyd | 202 | m-x.texi |
| 203 | package.texi cyd | 203 | package.texi |
| 204 | picture-xtra.texi rgm | 204 | picture-xtra.texi |
| 205 | programs.texi cyd | 205 | programs.texi |
| 206 | regs.texi cyd | 206 | regs.texi |
| 207 | rmail.texi rgm | 207 | rmail.texi |
| 208 | screen.texi cyd | 208 | screen.texi |
| 209 | search.texi cyd | 209 | search.texi |
| 210 | sending.texi cyd | 210 | sending.texi |
| 211 | text.texi cyd | 211 | text.texi |
| 212 | trouble.texi cyd | 212 | trouble.texi |
| 213 | vc-xtra.texi cyd | 213 | vc-xtra.texi |
| 214 | vc1-xtra.texi cyd | 214 | vc1-xtra.texi |
| 215 | windows.texi cyd | 215 | windows.texi |
| 216 | xresources.texi cyd | 216 | xresources.texi |
| 217 | 217 | ||
| 218 | ** Check the Lisp manual. | 218 | ** Check the Lisp manual. |
| 219 | 219 | ||
| 220 | abbrevs.texi rgm | 220 | abbrevs.texi |
| 221 | anti.texi rgm | 221 | anti.texi |
| 222 | back.texi rgm | 222 | back.texi |
| 223 | backups.texi cyd | 223 | backups.texi |
| 224 | buffers.texi cyd | 224 | buffers.texi |
| 225 | commands.texi cyd | 225 | commands.texi |
| 226 | compile.texi cyd | 226 | compile.texi |
| 227 | control.texi cyd | 227 | control.texi |
| 228 | customize.texi cyd | 228 | customize.texi |
| 229 | debugging.texi cyd | 229 | debugging.texi |
| 230 | display.texi cyd | 230 | display.texi |
| 231 | edebug.texi rgm | 231 | edebug.texi |
| 232 | elisp.texi | 232 | elisp.texi |
| 233 | errors.texi rgm | 233 | errors.texi |
| 234 | eval.texi cyd | 234 | eval.texi |
| 235 | files.texi cyd | 235 | files.texi |
| 236 | frames.texi cyd | 236 | frames.texi |
| 237 | functions.texi cyd | 237 | functions.texi |
| 238 | hash.texi cyd | 238 | hash.texi |
| 239 | help.texi cyd | 239 | help.texi |
| 240 | hooks.texi rgm | 240 | hooks.texi |
| 241 | index.texi | 241 | index.texi |
| 242 | internals.texi rgm cyd | 242 | internals.texi |
| 243 | intro.texi cyd | 243 | intro.texi |
| 244 | keymaps.texi cyd | 244 | keymaps.texi |
| 245 | lists.texi cyd | 245 | lists.texi |
| 246 | loading.texi cyd | 246 | loading.texi |
| 247 | macros.texi cyd | 247 | macros.texi |
| 248 | maps.texi rgm | 248 | maps.texi |
| 249 | markers.texi rgm | 249 | markers.texi |
| 250 | minibuf.texi rgm | 250 | minibuf.texi |
| 251 | modes.texi cyd | 251 | modes.texi |
| 252 | nonascii.texi cyd | 252 | nonascii.texi |
| 253 | numbers.texi cyd | 253 | numbers.texi Paul Eggert (24.4) |
| 254 | objects.texi cyd | 254 | objects.texi |
| 255 | os.texi cyd | 255 | os.texi |
| 256 | package.texi rgm | 256 | package.texi |
| 257 | positions.texi cyd | 257 | positions.texi |
| 258 | processes.texi rgm | 258 | processes.texi |
| 259 | searching.texi rgm | 259 | searching.texi |
| 260 | sequences.texi cyd | 260 | sequences.texi |
| 261 | streams.texi cyd | 261 | streams.texi |
| 262 | strings.texi cyd | 262 | strings.texi |
| 263 | symbols.texi cyd | 263 | symbols.texi |
| 264 | syntax.texi cyd | 264 | syntax.texi |
| 265 | text.texi cyd | 265 | text.texi |
| 266 | tips.texi rgm | 266 | tips.texi |
| 267 | variables.texi cyd | 267 | variables.texi |
| 268 | windows.texi rgm (skimmed) | 268 | windows.texi |
| 269 | 269 | ||
| 270 | 270 | ||
| 271 | Local variables: | 271 | Local variables: |
diff --git a/doc/misc/vip.texi b/doc/misc/vip.texi index 2c888fd1432..07f12fdf882 100644 --- a/doc/misc/vip.texi +++ b/doc/misc/vip.texi | |||
| @@ -1568,7 +1568,7 @@ Set mark and push previous mark on mark ring (@code{set-mark-command}). | |||
| 1568 | @kindex 011 TAB (@code{indent-for-tab-command}) | 1568 | @kindex 011 TAB (@code{indent-for-tab-command}) |
| 1569 | Indent line for current major mode (@code{indent-for-tab-command}). | 1569 | Indent line for current major mode (@code{indent-for-tab-command}). |
| 1570 | @item C-j | 1570 | @item C-j |
| 1571 | @kindex 012 @kbd{C-j} (@code{electric-indent-just-newline'} or @code{newline-and-indent}) | 1571 | @kindex 012 @kbd{C-j} (@code{electric-newline-and-maybe-indent}) |
| 1572 | Insert a newline, and maybe indent according to mode. | 1572 | Insert a newline, and maybe indent according to mode. |
| 1573 | @item C-k | 1573 | @item C-k |
| 1574 | @kindex 013 @kbd{C-k} (@code{kill-line}) | 1574 | @kindex 013 @kbd{C-k} (@code{kill-line}) |
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))) |