emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r116811: * lisp/electric.el (electric-newline-and-ma


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r116811: * lisp/electric.el (electric-newline-and-maybe-indent): New command.
Date: Thu, 20 Mar 2014 17:14:58 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116811
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16770
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Thu 2014-03-20 13:14:45 -0400
message:
  * 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.
modified:
  admin/FOR-RELEASE              forrelease-20091113204419-o5vbwnq5f7feedwu-3115
  doc/misc/vip.texi              vip.texi-20091113204419-o5vbwnq5f7feedwu-6327
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/bindings.el               
bindings.el-20091113204419-o5vbwnq5f7feedwu-1013
  lisp/electric.el               electric.el-20091113204419-o5vbwnq5f7feedwu-47
=== modified file 'admin/FOR-RELEASE'
--- a/admin/FOR-RELEASE 2014-01-10 19:40:32 +0000
+++ b/admin/FOR-RELEASE 2014-03-20 17:14:45 +0000
@@ -162,110 +162,110 @@
 
 ** 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:

=== modified file 'doc/misc/vip.texi'
--- a/doc/misc/vip.texi 2014-03-18 21:14:36 +0000
+++ b/doc/misc/vip.texi 2014-03-20 17:14:45 +0000
@@ -1568,7 +1568,7 @@
 @kindex 011 TAB (@code{indent-for-tab-command})
 Indent line for current major mode (@code{indent-for-tab-command}).
 @item C-j
address@hidden 012 @kbd{C-j} (@code{electric-indent-just-newline'} or 
@code{newline-and-indent})
address@hidden 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})

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-03-20 16:00:17 +0000
+++ b/lisp/ChangeLog    2014-03-20 17:14:45 +0000
@@ -1,5 +1,12 @@
 2014-03-20  Stefan Monnier  <address@hidden>
 
+       * 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).
 

=== modified file 'lisp/bindings.el'
--- a/lisp/bindings.el  2014-03-04 03:14:11 +0000
+++ b/lisp/bindings.el  2014-03-20 17:14:45 +0000
@@ -795,7 +795,6 @@
 ;; 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)

=== modified file 'lisp/electric.el'
--- a/lisp/electric.el  2014-03-12 06:48:20 +0000
+++ b/lisp/electric.el  2014-03-20 17:14:45 +0000
@@ -286,6 +286,20 @@
   (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 @@
   :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)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]