diff options
| author | Dmitry Gutov | 2017-12-21 00:34:07 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2017-12-21 00:34:07 +0200 |
| commit | aca827b0d0b108e26628da04d01a4e8bac372bdd (patch) | |
| tree | 9172f3166d283b44df178472830e86c6653028ba /doc | |
| parent | da0d7730b534ec5dee91c472246709d1c93df40c (diff) | |
| parent | 87548f5e98b450f2186d3fb5018ec34f4426351b (diff) | |
| download | emacs-aca827b0d0b108e26628da04d01a4e8bac372bdd.tar.gz emacs-aca827b0d0b108e26628da04d01a4e8bac372bdd.zip | |
Merge branch 'widen-less' into emacs-26
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/text.texi | 56 |
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}). | |||
| 2396 | syntax belongs to a different major mode. Examples include | 2396 | syntax 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 |
| 2398 | snippets of source code, Yacc/Bison programs that include snippets of | 2398 | snippets of source code, Yacc/Bison programs that include snippets of |
| 2399 | plain C code, etc. To correctly indent the embedded chunks, the major | 2399 | Python or JS code, etc. To correctly indent the embedded chunks, the primary |
| 2400 | mode needs to delegate the indentation to another mode's indentation | 2400 | mode needs to delegate the indentation to another mode's indentation |
| 2401 | engine (e.g., call @code{c-indent-defun} for C code or | 2401 | engine (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 |
| 2403 | context to guide the indentation. The following facilities support | 2403 | context to guide the indentation. Major modes, for their part, should |
| 2404 | such multi-mode indentation. | 2404 | avoid 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 |
| 2407 | This variable, when non-@code{nil}, holds the indentation context for | 2408 | This variable, when non-@code{nil}, holds the indentation context for |
| 2408 | the sub-mode's indentation engine provided by the superior major mode. | 2409 | the sub-mode's indentation engine provided by the superior major mode. |
| 2409 | The value should be a list of the form @code{(@var{first-column} | 2410 | The 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 | 2411 | The members of the list have the following meaning: |
| 2411 | list have the following meaning: | ||
| 2412 | 2412 | ||
| 2413 | @table @var | 2413 | @table @var |
| 2414 | @item first-column | 2414 | @item first-column |
| 2415 | The column to be used for top-level constructs. This replaces the | 2415 | The column to be used for top-level constructs. This replaces the |
| 2416 | default value of the top-level column used by the sub-mode, usually | 2416 | default value of the top-level column used by the sub-mode, usually |
| 2417 | zero. | 2417 | zero. |
| 2418 | @item start | 2418 | @item rest |
| 2419 | @itemx end | 2419 | This value is currently unused. |
| 2420 | The region of the code chunk to be indented by the sub-mode. The | ||
| 2421 | value of @var{end} can be @code{nil}, which stands for the value of | ||
| 2422 | @code{point-max}. | ||
| 2423 | @item prev-chunk | ||
| 2424 | If this is non-@code{nil}, it should provide the sub-mode's | ||
| 2425 | indentation engine with a virtual context of the code chunk. Valid | ||
| 2426 | values include: | ||
| 2427 | |||
| 2428 | @itemize @minus | ||
| 2429 | @item | ||
| 2430 | A string whose contents is the text the sub-mode's indentation engine | ||
| 2431 | should consider to precede the code chunk. The sub-mode's indentation | ||
| 2432 | engine can add text properties to that string, to be reused in | ||
| 2433 | repeated calls with the same string, thus using it as a cache. An | ||
| 2434 | example where this is useful is code chunks that need to be indented | ||
| 2435 | as function bodies, but lack the function's preamble---the string | ||
| 2436 | could then include that missing preamble. | ||
| 2437 | @item | ||
| 2438 | A function. It is expected to be called with the start position of | ||
| 2439 | the current chunk, and should return a cons cell | ||
| 2440 | @w{@code{(@var{prev-start} . @var{prev-end})}} that specifies the | ||
| 2441 | region of the previous code chunk, or @code{nil} if there is no previous | ||
| 2442 | chunk. This is useful in literate-programming sources, where code is | ||
| 2443 | split into chunks, and correct indentation needs to access previous | ||
| 2444 | chunks. | ||
| 2445 | @end itemize | ||
| 2446 | @end table | 2420 | @end table |
| 2447 | @end defvar | 2421 | @end defvar |
| 2448 | 2422 | ||
| 2449 | The following convenience functions should be used by major mode's | 2423 | The following convenience function should be used by major mode's |
| 2450 | indentation engine in support of invocations as sub-modes of another | 2424 | indentation engine in support of invocations as sub-modes of another |
| 2451 | major mode. | 2425 | major mode. |
| 2452 | 2426 | ||
| @@ -2457,16 +2431,6 @@ function's value is the column number to use for top-level constructs. | |||
| 2457 | When no superior mode is in effect, this function returns zero. | 2431 | When no superior mode is in effect, this function returns zero. |
| 2458 | @end defun | 2432 | @end defun |
| 2459 | 2433 | ||
| 2460 | @defun prog-widen | ||
| 2461 | Call this function instead of @code{widen} to remove any restrictions | ||
| 2462 | imposed by the mode's indentation engine and restore the restrictions | ||
| 2463 | recorded in @code{prog-indentation-context}. This prevents the | ||
| 2464 | indentation engine of a sub-mode from inadvertently operating on text | ||
| 2465 | outside of the chunk it was supposed to indent, and preserves the | ||
| 2466 | restriction imposed by the superior mode. When no superior mode is in | ||
| 2467 | effect, 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 |