diff options
| author | Eli Zaretskii | 2018-06-22 11:48:38 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-06-22 11:48:38 +0300 |
| commit | 4e15d263134fdb8c9ff75e70f3f86225ad32ad31 (patch) | |
| tree | 7bff501267307c991015a7e24732d3b4bd482f53 | |
| parent | a5511956b483e22cfebc0ebeb54d83c95f852648 (diff) | |
| download | emacs-4e15d263134fdb8c9ff75e70f3f86225ad32ad31.tar.gz emacs-4e15d263134fdb8c9ff75e70f3f86225ad32ad31.zip | |
Document 'major-mode-suspend' and 'major-mode-restore'
* doc/lispref/modes.texi (Major Modes): Document
'major-mode-suspend' and 'major-mode-restore'. (Bug#31551)
* etc/NEWS: Mark the corresponding entry as documented in
manuals.
| -rw-r--r-- | doc/lispref/modes.texi | 22 | ||||
| -rw-r--r-- | etc/NEWS | 7 |
2 files changed, 25 insertions, 4 deletions
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index d7e217c5287..49b7e1ea3fb 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi | |||
| @@ -197,6 +197,7 @@ from the buffer-local hook list instead of from the global hook list. | |||
| 197 | @cindex major mode | 197 | @cindex major mode |
| 198 | 198 | ||
| 199 | @cindex major mode command | 199 | @cindex major mode command |
| 200 | @cindex suspend major mode temporarily | ||
| 200 | Major modes specialize Emacs for editing or interacting with | 201 | Major modes specialize Emacs for editing or interacting with |
| 201 | particular kinds of text. Each buffer has exactly one major mode at a | 202 | particular kinds of text. Each buffer has exactly one major mode at a |
| 202 | time. Every major mode is associated with a @dfn{major mode command}, | 203 | time. Every major mode is associated with a @dfn{major mode command}, |
| @@ -205,7 +206,8 @@ switching to that mode in the current buffer, by setting various | |||
| 205 | buffer-local variables such as a local keymap. @xref{Major Mode | 206 | buffer-local variables such as a local keymap. @xref{Major Mode |
| 206 | Conventions}. Note that unlike minor modes there is no way to ``turn | 207 | Conventions}. Note that unlike minor modes there is no way to ``turn |
| 207 | off'' a major mode, instead the buffer must be switched to a different | 208 | off'' a major mode, instead the buffer must be switched to a different |
| 208 | one. | 209 | one. However, you can temporarily @dfn{suspend} a major mode and later |
| 210 | @dfn{restore} the suspended mode, see below. | ||
| 209 | 211 | ||
| 210 | The least specialized major mode is called @dfn{Fundamental mode}, | 212 | The least specialized major mode is called @dfn{Fundamental mode}, |
| 211 | which has no mode-specific definitions or variable settings. | 213 | which has no mode-specific definitions or variable settings. |
| @@ -216,6 +218,24 @@ commands, it does @emph{not} run any mode hooks (@pxref{Major Mode | |||
| 216 | Conventions}), since you are not supposed to customize this mode. | 218 | Conventions}), since you are not supposed to customize this mode. |
| 217 | @end deffn | 219 | @end deffn |
| 218 | 220 | ||
| 221 | @defun major-mode-suspend | ||
| 222 | This function works like @code{fundamental-mode}, in that it kills all | ||
| 223 | buffer-local variables, but it also records the major mode in effect, | ||
| 224 | so that it could subsequently be restored. This function and | ||
| 225 | @code{major-mode-restore} (described next) are useful when you need to | ||
| 226 | put a buffer under some specialized mode other than the one Emacs | ||
| 227 | chooses for it automatically (@pxref{Auto Major Mode}), but would also | ||
| 228 | like to be able to switch back to the original mode later. | ||
| 229 | @end defun | ||
| 230 | |||
| 231 | @defun major-mode-restore &optional avoided-modes | ||
| 232 | This function restores the major mode recorded by | ||
| 233 | @code{major-mode-suspend}. If no major mode was recorded, this | ||
| 234 | function calls @code{normal-mode} (@pxref{Auto Major Mode, | ||
| 235 | normal-mode}), but tries to force it not to choose any modes in | ||
| 236 | @var{avoided-modes}, if that argument is non-@code{nil}. | ||
| 237 | @end defun | ||
| 238 | |||
| 219 | The easiest way to write a major mode is to use the macro | 239 | The easiest way to write a major mode is to use the macro |
| 220 | @code{define-derived-mode}, which sets up the new mode as a variant of | 240 | @code{define-derived-mode}, which sets up the new mode as a variant of |
| 221 | an existing major mode. @xref{Derived Modes}. We recommend using | 241 | an existing major mode. @xref{Derived Modes}. We recommend using |
| @@ -658,9 +658,10 @@ manual for more details. | |||
| 658 | 658 | ||
| 659 | * Lisp Changes in Emacs 27.1 | 659 | * Lisp Changes in Emacs 27.1 |
| 660 | 660 | ||
| 661 | ** New functions 'major-mode-suspend' and 'major-mode-restore' | 661 | +++ |
| 662 | Used when switching temporarily to another major mode, e.g. for hexl-mode, | 662 | ** New functions 'major-mode-suspend' and 'major-mode-restore'. |
| 663 | or to switch between c-mode and image-mode in XPM. | 663 | Use them when switching temporarily to another major mode, e.g. for |
| 664 | 'hexl-mode', or to switch between 'c-mode' and 'image-mode' in XPM. | ||
| 664 | 665 | ||
| 665 | +++ | 666 | +++ |
| 666 | ** New macro 'dolist-with-progress-reporter'. | 667 | ** New macro 'dolist-with-progress-reporter'. |