aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2018-06-22 11:48:38 +0300
committerEli Zaretskii2018-06-22 11:48:38 +0300
commit4e15d263134fdb8c9ff75e70f3f86225ad32ad31 (patch)
tree7bff501267307c991015a7e24732d3b4bd482f53
parenta5511956b483e22cfebc0ebeb54d83c95f852648 (diff)
downloademacs-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.texi22
-rw-r--r--etc/NEWS7
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
201particular kinds of text. Each buffer has exactly one major mode at a 202particular kinds of text. Each buffer has exactly one major mode at a
202time. Every major mode is associated with a @dfn{major mode command}, 203time. 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
205buffer-local variables such as a local keymap. @xref{Major Mode 206buffer-local variables such as a local keymap. @xref{Major Mode
206Conventions}. Note that unlike minor modes there is no way to ``turn 207Conventions}. Note that unlike minor modes there is no way to ``turn
207off'' a major mode, instead the buffer must be switched to a different 208off'' a major mode, instead the buffer must be switched to a different
208one. 209one. 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},
211which has no mode-specific definitions or variable settings. 213which has no mode-specific definitions or variable settings.
@@ -216,6 +218,24 @@ commands, it does @emph{not} run any mode hooks (@pxref{Major Mode
216Conventions}), since you are not supposed to customize this mode. 218Conventions}), since you are not supposed to customize this mode.
217@end deffn 219@end deffn
218 220
221@defun major-mode-suspend
222This function works like @code{fundamental-mode}, in that it kills all
223buffer-local variables, but it also records the major mode in effect,
224so that it could subsequently be restored. This function and
225@code{major-mode-restore} (described next) are useful when you need to
226put a buffer under some specialized mode other than the one Emacs
227chooses for it automatically (@pxref{Auto Major Mode}), but would also
228like to be able to switch back to the original mode later.
229@end defun
230
231@defun major-mode-restore &optional avoided-modes
232This function restores the major mode recorded by
233@code{major-mode-suspend}. If no major mode was recorded, this
234function calls @code{normal-mode} (@pxref{Auto Major Mode,
235normal-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
221an existing major mode. @xref{Derived Modes}. We recommend using 241an existing major mode. @xref{Derived Modes}. We recommend using
diff --git a/etc/NEWS b/etc/NEWS
index 83e106ced8c..12757f61d20 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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+++
662Used when switching temporarily to another major mode, e.g. for hexl-mode, 662** New functions 'major-mode-suspend' and 'major-mode-restore'.
663or to switch between c-mode and image-mode in XPM. 663Use 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'.