aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorDmitry Gutov2017-12-21 00:34:07 +0200
committerDmitry Gutov2017-12-21 00:34:07 +0200
commitaca827b0d0b108e26628da04d01a4e8bac372bdd (patch)
tree9172f3166d283b44df178472830e86c6653028ba /doc
parentda0d7730b534ec5dee91c472246709d1c93df40c (diff)
parent87548f5e98b450f2186d3fb5018ec34f4426351b (diff)
downloademacs-aca827b0d0b108e26628da04d01a4e8bac372bdd.tar.gz
emacs-aca827b0d0b108e26628da04d01a4e8bac372bdd.zip
Merge branch 'widen-less' into emacs-26
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/text.texi56
1 files changed, 10 insertions, 46 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 1e19f75d682..0ec1998da40 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -2396,57 +2396,31 @@ text at point (@pxref{Completion in Buffers}).
2396syntax belongs to a different major mode. Examples include 2396syntax belongs to a different major mode. Examples include
2397@dfn{literate programming} source files that combine documentation and 2397@dfn{literate programming} source files that combine documentation and
2398snippets of source code, Yacc/Bison programs that include snippets of 2398snippets of source code, Yacc/Bison programs that include snippets of
2399plain C code, etc. To correctly indent the embedded chunks, the major 2399Python or JS code, etc. To correctly indent the embedded chunks, the primary
2400mode needs to delegate the indentation to another mode's indentation 2400mode needs to delegate the indentation to another mode's indentation
2401engine (e.g., call @code{c-indent-defun} for C code or 2401engine (e.g., call @code{js-indent-line} for JS code or
2402@code{python-indent-line} for Python), while providing it with some 2402@code{python-indent-line} for Python), while providing it with some
2403context to guide the indentation. The following facilities support 2403context to guide the indentation. Major modes, for their part, should
2404such multi-mode indentation. 2404avoid calling @code{widen} in their indentation code and obey
2405@code{prog-first-column}.
2405 2406
2406@defvar prog-indentation-context 2407@defvar prog-indentation-context
2407This variable, when non-@code{nil}, holds the indentation context for 2408This variable, when non-@code{nil}, holds the indentation context for
2408the sub-mode's indentation engine provided by the superior major mode. 2409the sub-mode's indentation engine provided by the superior major mode.
2409The value should be a list of the form @code{(@var{first-column} 2410The value should be a list of the form @code{(@var{first-column} . @var{rest}}.
2410@w{(@var{start} . @var{end})} @code{prev-chunk})}. The members of the 2411The members of the list have the following meaning:
2411list have the following meaning:
2412 2412
2413@table @var 2413@table @var
2414@item first-column 2414@item first-column
2415The column to be used for top-level constructs. This replaces the 2415The column to be used for top-level constructs. This replaces the
2416default value of the top-level column used by the sub-mode, usually 2416default value of the top-level column used by the sub-mode, usually
2417zero. 2417zero.
2418@item start 2418@item rest
2419@itemx end 2419This value is currently unused.
2420The region of the code chunk to be indented by the sub-mode. The
2421value of @var{end} can be @code{nil}, which stands for the value of
2422@code{point-max}.
2423@item prev-chunk
2424If this is non-@code{nil}, it should provide the sub-mode's
2425indentation engine with a virtual context of the code chunk. Valid
2426values include:
2427
2428@itemize @minus
2429@item
2430A string whose contents is the text the sub-mode's indentation engine
2431should consider to precede the code chunk. The sub-mode's indentation
2432engine can add text properties to that string, to be reused in
2433repeated calls with the same string, thus using it as a cache. An
2434example where this is useful is code chunks that need to be indented
2435as function bodies, but lack the function's preamble---the string
2436could then include that missing preamble.
2437@item
2438A function. It is expected to be called with the start position of
2439the current chunk, and should return a cons cell
2440@w{@code{(@var{prev-start} . @var{prev-end})}} that specifies the
2441region of the previous code chunk, or @code{nil} if there is no previous
2442chunk. This is useful in literate-programming sources, where code is
2443split into chunks, and correct indentation needs to access previous
2444chunks.
2445@end itemize
2446@end table 2420@end table
2447@end defvar 2421@end defvar
2448 2422
2449The following convenience functions should be used by major mode's 2423The following convenience function should be used by major mode's
2450indentation engine in support of invocations as sub-modes of another 2424indentation engine in support of invocations as sub-modes of another
2451major mode. 2425major mode.
2452 2426
@@ -2457,16 +2431,6 @@ function's value is the column number to use for top-level constructs.
2457When no superior mode is in effect, this function returns zero. 2431When no superior mode is in effect, this function returns zero.
2458@end defun 2432@end defun
2459 2433
2460@defun prog-widen
2461Call this function instead of @code{widen} to remove any restrictions
2462imposed by the mode's indentation engine and restore the restrictions
2463recorded in @code{prog-indentation-context}. This prevents the
2464indentation engine of a sub-mode from inadvertently operating on text
2465outside of the chunk it was supposed to indent, and preserves the
2466restriction imposed by the superior mode. When no superior mode is in
2467effect, this function just calls @code{widen}.
2468@end defun
2469
2470 2434
2471@node Region Indent 2435@node Region Indent
2472@subsection Indenting an Entire Region 2436@subsection Indenting an Entire Region