* 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
This commit is contained in:
parent
049fac7c94
commit
494ec1e71d
5 changed files with 125 additions and 107 deletions
|
@ -162,110 +162,110 @@ TUTORIAL.zh
|
|||
|
||||
** Check the manual.
|
||||
|
||||
abbrevs.texi cyd
|
||||
ack.texi rgm
|
||||
anti.texi cyd
|
||||
arevert-xtra.texi cyd
|
||||
basic.texi cyd
|
||||
buffers.texi cyd
|
||||
building.texi cyd
|
||||
calendar.texi rgm
|
||||
cal-xtra.texi rgm
|
||||
cmdargs.texi cyd
|
||||
commands.texi cyd
|
||||
custom.texi cyd
|
||||
dired.texi cyd
|
||||
dired-xtra.texi rgm
|
||||
display.texi cyd
|
||||
emacs.texi rgm
|
||||
emacs-xtra.texi rgm
|
||||
emerge-xtra.texi rgm
|
||||
entering.texi cyd
|
||||
files.texi cyd
|
||||
fixit.texi cyd
|
||||
fortran-xtra.texi rgm
|
||||
frames.texi cyd
|
||||
glossary.texi rgm
|
||||
help.texi cyd
|
||||
indent.texi cyd
|
||||
killing.texi cyd
|
||||
kmacro.texi cyd
|
||||
macos.texi rgm (can't actually test any of it though)
|
||||
maintaining.texi cyd
|
||||
mark.texi cyd
|
||||
mini.texi rgm
|
||||
misc.texi cyd
|
||||
modes.texi cyd
|
||||
msdog.texi rgm (can't actually test any of it though)
|
||||
msdog-xtra.texi rgm (can't actually test any of it though)
|
||||
mule.texi rgm (not 100% sure about "Fontsets")
|
||||
m-x.texi cyd
|
||||
package.texi cyd
|
||||
picture-xtra.texi rgm
|
||||
programs.texi cyd
|
||||
regs.texi cyd
|
||||
rmail.texi rgm
|
||||
screen.texi cyd
|
||||
search.texi cyd
|
||||
sending.texi cyd
|
||||
text.texi cyd
|
||||
trouble.texi cyd
|
||||
vc-xtra.texi cyd
|
||||
vc1-xtra.texi cyd
|
||||
windows.texi cyd
|
||||
xresources.texi cyd
|
||||
abbrevs.texi
|
||||
ack.texi
|
||||
anti.texi
|
||||
arevert-xtra.texi
|
||||
basic.texi
|
||||
buffers.texi
|
||||
building.texi
|
||||
calendar.texi
|
||||
cal-xtra.texi
|
||||
cmdargs.texi
|
||||
commands.texi
|
||||
custom.texi
|
||||
dired.texi
|
||||
dired-xtra.texi
|
||||
display.texi
|
||||
emacs.texi
|
||||
emacs-xtra.texi
|
||||
emerge-xtra.texi
|
||||
entering.texi
|
||||
files.texi
|
||||
fixit.texi
|
||||
fortran-xtra.texi
|
||||
frames.texi
|
||||
glossary.texi
|
||||
help.texi
|
||||
indent.texi
|
||||
killing.texi
|
||||
kmacro.texi
|
||||
macos.texi
|
||||
maintaining.texi
|
||||
mark.texi
|
||||
mini.texi
|
||||
misc.texi
|
||||
modes.texi
|
||||
msdog.texi
|
||||
msdog-xtra.texi
|
||||
mule.texi
|
||||
m-x.texi
|
||||
package.texi
|
||||
picture-xtra.texi
|
||||
programs.texi
|
||||
regs.texi
|
||||
rmail.texi
|
||||
screen.texi
|
||||
search.texi
|
||||
sending.texi
|
||||
text.texi
|
||||
trouble.texi
|
||||
vc-xtra.texi
|
||||
vc1-xtra.texi
|
||||
windows.texi
|
||||
xresources.texi
|
||||
|
||||
** Check the Lisp manual.
|
||||
|
||||
abbrevs.texi rgm
|
||||
anti.texi rgm
|
||||
back.texi rgm
|
||||
backups.texi cyd
|
||||
buffers.texi cyd
|
||||
commands.texi cyd
|
||||
compile.texi cyd
|
||||
control.texi cyd
|
||||
customize.texi cyd
|
||||
debugging.texi cyd
|
||||
display.texi cyd
|
||||
edebug.texi rgm
|
||||
abbrevs.texi
|
||||
anti.texi
|
||||
back.texi
|
||||
backups.texi
|
||||
buffers.texi
|
||||
commands.texi
|
||||
compile.texi
|
||||
control.texi
|
||||
customize.texi
|
||||
debugging.texi
|
||||
display.texi
|
||||
edebug.texi
|
||||
elisp.texi
|
||||
errors.texi rgm
|
||||
eval.texi cyd
|
||||
files.texi cyd
|
||||
frames.texi cyd
|
||||
functions.texi cyd
|
||||
hash.texi cyd
|
||||
help.texi cyd
|
||||
hooks.texi rgm
|
||||
errors.texi
|
||||
eval.texi
|
||||
files.texi
|
||||
frames.texi
|
||||
functions.texi
|
||||
hash.texi
|
||||
help.texi
|
||||
hooks.texi
|
||||
index.texi
|
||||
internals.texi rgm cyd
|
||||
intro.texi cyd
|
||||
keymaps.texi cyd
|
||||
lists.texi cyd
|
||||
loading.texi cyd
|
||||
macros.texi cyd
|
||||
maps.texi rgm
|
||||
markers.texi rgm
|
||||
minibuf.texi rgm
|
||||
modes.texi cyd
|
||||
nonascii.texi cyd
|
||||
numbers.texi cyd
|
||||
objects.texi cyd
|
||||
os.texi cyd
|
||||
package.texi rgm
|
||||
positions.texi cyd
|
||||
processes.texi rgm
|
||||
searching.texi rgm
|
||||
sequences.texi cyd
|
||||
streams.texi cyd
|
||||
strings.texi cyd
|
||||
symbols.texi cyd
|
||||
syntax.texi cyd
|
||||
text.texi cyd
|
||||
tips.texi rgm
|
||||
variables.texi cyd
|
||||
windows.texi rgm (skimmed)
|
||||
internals.texi
|
||||
intro.texi
|
||||
keymaps.texi
|
||||
lists.texi
|
||||
loading.texi
|
||||
macros.texi
|
||||
maps.texi
|
||||
markers.texi
|
||||
minibuf.texi
|
||||
modes.texi
|
||||
nonascii.texi
|
||||
numbers.texi Paul Eggert (24.4)
|
||||
objects.texi
|
||||
os.texi
|
||||
package.texi
|
||||
positions.texi
|
||||
processes.texi
|
||||
searching.texi
|
||||
sequences.texi
|
||||
streams.texi
|
||||
strings.texi
|
||||
symbols.texi
|
||||
syntax.texi
|
||||
text.texi
|
||||
tips.texi
|
||||
variables.texi
|
||||
windows.texi
|
||||
|
||||
|
||||
Local variables:
|
||||
|
|
|
@ -1568,7 +1568,7 @@ Set mark and push previous mark on mark ring (@code{set-mark-command}).
|
|||
@kindex 011 TAB (@code{indent-for-tab-command})
|
||||
Indent line for current major mode (@code{indent-for-tab-command}).
|
||||
@item C-j
|
||||
@kindex 012 @kbd{C-j} (@code{electric-indent-just-newline'} or @code{newline-and-indent})
|
||||
@kindex 012 @kbd{C-j} (@code{electric-newline-and-maybe-indent})
|
||||
Insert a newline, and maybe indent according to mode.
|
||||
@item C-k
|
||||
@kindex 013 @kbd{C-k} (@code{kill-line})
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
2014-03-20 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* 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
|
||||
(bug#16770).
|
||||
* bindings.el (global-map): Remove C-j binding.
|
||||
|
||||
* emacs-lisp/nadvice.el (advice--make-docstring): Try harder to find
|
||||
the docstring of functions advised before dumping (bug#16993).
|
||||
|
||||
|
|
|
@ -795,7 +795,6 @@ if `inhibit-field-text-motion' is non-nil."
|
|||
;; suspend only the relevant terminal.
|
||||
(substitute-key-definition 'suspend-emacs 'suspend-frame global-map)
|
||||
|
||||
(define-key global-map "\C-j" 'newline-and-indent)
|
||||
(define-key global-map "\C-m" 'newline)
|
||||
(define-key global-map "\C-o" 'open-line)
|
||||
(define-key esc-map "\C-o" 'split-line)
|
||||
|
|
|
@ -286,6 +286,20 @@ mode set `electric-indent-inhibit', but this can be used as a workaround.")
|
|||
(let ((electric-indent-mode nil))
|
||||
(newline arg 'interactive)))
|
||||
|
||||
;;;###autoload(define-key global-map "\C-j" 'electric-newline-and-maybe-indent)
|
||||
;;;###autoload
|
||||
(defun electric-newline-and-maybe-indent ()
|
||||
"Insert a newline.
|
||||
If `electric-indent-mode' is enabled, that's that, but if it
|
||||
is *disabled* then additionally indent according to major mode.
|
||||
Indentation is done using the value of `indent-line-function'.
|
||||
In programming language modes, this is the same as TAB.
|
||||
In some text modes, where TAB inserts a tab, this command indents to the
|
||||
column specified by the function `current-left-margin'."
|
||||
(interactive "*")
|
||||
(if electric-indent-mode
|
||||
(electric-indent-just-newline nil)
|
||||
(newline-and-indent)))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode electric-indent-mode
|
||||
|
@ -303,14 +317,12 @@ use `electric-indent-local-mode'."
|
|||
:initialize 'custom-initialize-delay
|
||||
:init-value t
|
||||
(if (not electric-indent-mode)
|
||||
(progn
|
||||
(when (eq (lookup-key global-map [?\C-j])
|
||||
'electric-indent-just-newline)
|
||||
(define-key global-map [?\C-j] 'newline-and-indent))
|
||||
(unless (catch 'found
|
||||
(dolist (buf (buffer-list))
|
||||
(with-current-buffer buf
|
||||
(if electric-indent-mode (throw 'found t)))))
|
||||
(remove-hook 'post-self-insert-hook
|
||||
#'electric-indent-post-self-insert-function))
|
||||
(when (eq (lookup-key global-map [?\C-j]) 'newline-and-indent)
|
||||
(define-key global-map [?\C-j] 'electric-indent-just-newline))
|
||||
(add-hook 'post-self-insert-hook
|
||||
#'electric-indent-post-self-insert-function)
|
||||
(electric--sort-post-self-insertion-hook)))
|
||||
|
|
Loading…
Add table
Reference in a new issue