]> code.delx.au - gnu-emacs/commitdiff
* doc/lispref/modes.texi (Auto-Indentation): Mention electric-indent variables.
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 18 Mar 2014 21:14:36 +0000 (17:14 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 18 Mar 2014 21:14:36 +0000 (17:14 -0400)
* doc/misc/cc-mode.texi (Indentation Commands): Remove C-j, since it's not
defined by CC-mode but globally.
(FAQ): Tweak text about RET and auto-indentation.
* doc/misc/vip.texi (Other Vi Commands): Adjust doc of C-j.

doc/emacs/basic.texi
doc/lispref/ChangeLog
doc/lispref/modes.texi
doc/lispref/text.texi
doc/misc/ChangeLog
doc/misc/cc-mode.texi
doc/misc/vip.texi
etc/NEWS

index c0a93c9396db4b52aab25e41a261b9bf739fe2e2..c5ded11c62ed5fbdccae1e2d9baa9bb484001f1d 100644 (file)
@@ -42,7 +42,7 @@ forward, so that point remains just after the inserted text.
 @kindex RET
 @kindex C-j
 @cindex newline
-@findex electric-indent-just-newline
+@c @findex electric-indent-just-newline
   To end a line and start a new one, type @key{RET} (@code{newline}).
 (The @key{RET} key may be labeled @key{Return} or @key{Enter} on your
 keyboard, but we refer to it as @key{RET} in this manual.)  This
index dbab5f1fd5df7cebed8dac796b7ac49aa9c5d35d..723bd1188c6038bafbbbc22c35f953754aab5f09 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * modes.texi (Auto-Indentation): Mention electric-indent variables.
+
 2014-03-18  Juanma Barranquero  <lekktu@gmail.com>
 
        * functions.texi (Advising Named Functions): Fix reference.
index 30b0f758c270c188278ed38ed77939aab949dc60..c30547e65ab1b1b42a454e886052c9b55ae1c1e9 100644 (file)
@@ -3303,18 +3303,28 @@ reasonably fast.
 @section Automatic Indentation of code
 
 For programming languages, an important feature of a major mode is to
-provide automatic indentation.  This is controlled in Emacs by
-@code{indent-line-function} (@pxref{Mode-Specific Indent}).
-Writing a good indentation function can be difficult and to a large
-extent it is still a black art.
-
-Many major mode authors will start by writing a simple indentation
-function that works for simple cases, for example by comparing with the
-indentation of the previous text line.  For most programming languages
-that are not really line-based, this tends to scale very poorly:
-improving such a function to let it handle more diverse situations tends
-to become more and more difficult, resulting in the end with a large,
-complex, unmaintainable indentation function which nobody dares to touch.
+provide automatic indentation.  There are two parts: one is to decide what
+is the right indentation of a line, and the other is to decide when to
+reindent a line.  By default, Emacs reindents a line whenever you
+type a character in @code{electric-indent-chars}, which by default only
+includes Newline.  Major modes can add chars to @code{electric-indent-chars}
+according to the syntax of the language.
+
+Deciding what is the right indentation is controlled in Emacs by
+@code{indent-line-function} (@pxref{Mode-Specific Indent}).  For some modes,
+the @emph{right} indentation cannot be known reliably, typically because
+indentation is significant so several indentations are valid but with different
+meanings.  In that case, the mode should set @code{electric-indent-inhibit} to
+make sure the line is not constantly re-indented against the user's wishes.
+
+Writing a good indentation function can be difficult and to a large extent it
+is still a black art.  Many major mode authors will start by writing a simple
+indentation function that works for simple cases, for example by comparing with
+the indentation of the previous text line.  For most programming languages that
+are not really line-based, this tends to scale very poorly: improving
+such a function to let it handle more diverse situations tends to become more
+and more difficult, resulting in the end with a large, complex, unmaintainable
+indentation function which nobody dares to touch.
 
 A good indentation function will usually need to actually parse the
 text, according to the syntax of the language.  Luckily, it is not
@@ -3332,7 +3342,7 @@ programming languages are designed to be parsed forward, but for the
 purpose of indentation it has the advantage of not needing to
 guess a ``safe'' starting point, and it generally enjoys the property
 that only a minimum of text will be analyzed to decide the indentation
-of a line, so indentation will tend to be unaffected by syntax errors in
+of a line, so indentation will tend to be less affected by syntax errors in
 some earlier unrelated piece of code.  Parsing forward on the other hand
 is usually easier and has the advantage of making it possible to
 reindent efficiently a whole region at a time, with a single parse.
index 1a9a3d0a0ec121fcb30a90e05569c202787be69d..f8a3e87344934673da9a100f602c8e6927af755b 100644 (file)
@@ -3946,7 +3946,7 @@ single interval.  But suppose instead that we have two adjacent
 intervals with the same properties, and we kill the text of one interval
 and yank it back.  The same interval-coalescence feature that rescues
 the other case causes trouble in this one: after yanking, we have just
-one interval.  One again, editing does not preserve the distinction
+one interval.  Once again, editing does not preserve the distinction
 between one interval and two.
 
   Insertion of text at the border between intervals also raises
index a2d201ff692e467504ecad89bd9e618063f6d646..8796cafa4d6f2468f5539ce623d01b6f79ff492f 100644 (file)
@@ -1,10 +1,18 @@
+2014-03-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * vip.texi (Other Vi Commands): Adjust doc of C-j.
+
+       * cc-mode.texi (Indentation Commands): Remove C-j, since it's not
+       defined by CC-mode but globally.
+       (FAQ): Tweak text about RET and auto-indentation.
+
 2014-03-18  David Engster  <deng@randomsample.de>
 
        * ede.texi (Project Local Variables): Remove reference to
        `ede-java-root' and the example using it.
        (Android projects, ede-java-root): Remove nodes since they are
        only in CEDET upstream (Bug#17030).  All nodes updated.
-        (ede-cpp-root): Document the :compile-command slot.
+       (ede-cpp-root): Document the :compile-command slot.
        (ede-linux): Document new variables
        `project-linux-build-directory-default' and
        `project-linux-architecture-default'.
 
 1998-03-01  Kim-Minh Kaplan  <KimMinh.Kaplan@utopia.eunet.fr>
 
-       * gnus.texi (Easy Picons): Removed references to
+       * gnus.texi (Easy Picons): Remove references to
        `gnus-group-display-picons'.
        (Hard Picons): Ditto.
 
index c7f51b4dcbe7fc238bebcdabf1bfea8335cac919..f6537ac22b35970d3e1190bea4d9ae798436da02 100644 (file)
@@ -751,13 +751,6 @@ very useful in this case.
 @end itemize
 
 @table @asis
-@c FIXME: This should be `electric-indent-just-newline' since GNU Emacs 24.4.
-@item @kbd{C-j} (@code{newline-and-indent})
-@kindex C-j
-@findex newline-and-indent
-Inserts a newline and indents the new blank line, ready to start
-typing.  This is a standard (X)Emacs command.
-
 @item @kbd{C-M-q} (@code{c-indent-exp})
 @kindex C-M-q
 @findex c-indent-exp
@@ -7054,19 +7047,20 @@ Set the variable @code{c-basic-offset}.  @xref{Getting Started}.
 @item
 @kindex RET
 @kindex C-j
-@emph{Why doesn't the @kbd{RET} key indent the new line?}
-@c FIXME: `electric-indent-mode' is enabled by default in GNU Emacs 24.4.
+@emph{Why does/doesn't the @kbd{RET} key indent the new line?}
+
+Emacs's convention used to be that @kbd{RET} just adds a newline, and that
+@kbd{C-j} adds a newline and indents it.  In Emacs-24.4, this convention was
+reversed.
 
-Emacs's convention is that @kbd{RET} just adds a newline, and that
-@kbd{C-j} adds a newline and indents it.  You can make @kbd{RET} do this
-too by adding this to your @code{c-initialization-hook}:
+If you use an older Emacs and you want @kbd{RET} do this
+too, add this to your @code{c-initialization-hook}:
 
 @example
 (define-key c-mode-base-map "\C-m" 'c-context-line-break)
 @end example
 
-@xref{Getting Started}.  This is a very common question.  If you want
-this to be the default behavior, don't lobby us, lobby RMS@!  @t{:-)}
+@xref{Getting Started}.  This was a very common question.
 
 @item
 @emph{How do I stop my code jumping all over the place when I type?}
index 95f829d14edac25258fa84687ea7ceaa72894320..2c888fd1432e8af7f1020777ff7d5862deae88f4 100644 (file)
@@ -1568,9 +1568,8 @@ 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
-@c FIXME: This should be `electric-indent-just-newline' since GNU Emacs 24.4.
-@kindex 012 @kbd{C-j} (@code{newline-and-indent})
-Insert a newline, then indent according to mode (@code{newline-and-indent}).
+@kindex 012 @kbd{C-j} (@code{electric-indent-just-newline'} or @code{newline-and-indent})
+Insert a newline, and maybe indent according to mode.
 @item C-k
 @kindex 013 @kbd{C-k} (@code{kill-line})
 Kill the rest of the current line; before a newline, kill the newline.
index 78b2df2ecc41ddbbd467ceda62d1f24d18116df8..a919f94ac57baf4837cca64f1c249affb2d82d5e 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -355,6 +355,7 @@ means to always load the .elc file.
 
 ** Indentation changes
 
++++
 *** `electric-indent-mode' is now enabled by default.
 E.g., typing RET reindents the current line and indents the new line.
 `C-j' inserts a newline but does not indent.