aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/misc.texi189
1 files changed, 162 insertions, 27 deletions
diff --git a/man/misc.texi b/man/misc.texi
index aab01beb5f9..7851510dcb3 100644
--- a/man/misc.texi
+++ b/man/misc.texi
@@ -1875,44 +1875,179 @@ hexl-@key{RET}} for details.
1875@cindex reload files 1875@cindex reload files
1876@cindex desktop 1876@cindex desktop
1877 1877
1878 You can use the Desktop library to save the state of Emacs from one 1878 You can use the desktop library to save the state of Emacs from one
1879session to another. Saving the state means that Emacs starts up with 1879session to another. Saving the state means that Emacs starts up with
1880the same set of buffers, major modes, buffer positions, and so on that 1880the same set of buffers, major modes, buffer positions, and so on that
1881the previous Emacs session had. 1881the previous Emacs session had. Such a state is referred to as a ``desktop''.
1882 1882
1883@vindex desktop-enable 1883 The saveplace library provides a simpler feature that records your
1884 To use Desktop, you should use the Customization buffer (@pxref{Easy 1884position in each file when you kill its buffer (or kill Emacs), and
1885Customization}) to set @code{desktop-enable} to a non-@code{nil} value, 1885jumps to the same position when you visit the file again (even in
1886or add these lines at the end of your @file{.emacs} file: 1886another Emacs session).
1887
1888@menu
1889The desktop library
1890* Desktop Save Mode:: How to enable desktop saving.
1891* Desktop file and directory:: About desktop files and desktop directory.
1892* Saving manually:: How to saving the desktop manually and why.
1893* Information saved:: Controlling which information to save.
1894* Desktop clear:: Clearing the desktop.
1895* File name format:: Different formats to save file names in.
1896
1897The saveplace library
1898* Saveplace:: Recording the position in each file.
1899@end menu
1900
1901@node Desktop Save Mode
1902@subsection Desktop Save Mode
1903@findex desktop-save-mode
1904@vindex desktop-save-mode
1905 Desktop Save Mode is a global minor mode. @pxref{Minor Modes}.
1906To enable desktop saving, you should use the Customization buffer
1907(@pxref{Easy Customization}) to set @code{desktop-save-mode} to a
1908non-@code{nil} value for future sessions, or add this line somewhere
1909in your @file{.emacs} file:
1887 1910
1888@example 1911@example
1889(require 'desktop) 1912(desktop-save-mode 1)
1890(setq desktop-enable t)
1891@end example 1913@end example
1892 1914
1893@noindent 1915@findex desktop-change-dir
1894@findex desktop-save 1916@findex desktop-revert
1895The first time you exit Emacs, you will be asked whether you want to 1917@findex desktop-read
1896save your session. Once you have done that, exiting Emacs will save 1918@vindex desktop-after-read-hook
1897the state again in subsequent sessions. You can also save the state 1919 In order for Emacs to recover the desktop from a previous session, you
1898at any time, without exiting Emacs, by typing @kbd{M-x desktop-save}.
1899
1900 In order for Emacs to recover the state from a previous session, you
1901must start it with the same current directory as you used when you 1920must start it with the same current directory as you used when you
1902started the previous session. This is because @code{desktop-read} looks 1921started the previous session. This is because @code{desktop-read} looks
1903in the current directory for the file to read. This means that you can 1922in the current directory for the desktop file to read. This means that you can
1904have separate saved sessions in different directories; the directory in 1923have separate saved desktops in different directories; the directory in
1905which you start Emacs will control which saved session to use. 1924which you start Emacs will control which saved desktop to use.
1906 1925You can also save the current desktop and recover one saved in another directory
1926by typing @kbd{M-x desktop-change-dir}.
1927Typing @kbd{M-x desktop-revert} reverts to the last recovered desktop.
1928
1929You may want Emacs to display a buffer list when a desktop is
1930loaded. This is possible by adding e.g.@: the function @code{buffer-menu} to
1931@code{desktop-after-read-hook}. @pxref{Buffers}.
1932
1933Specify the option @samp{--no-desktop} on the command line when you don't want
1934any desktop to be loaded (even when desktop saving is enabled).
1935
1936@node Desktop file and directory
1937@subsection Desktop file and desktop directory
1938@cindex desktop file
1939@cindex desktop directory
1940@vindex desktop-dirname
1941@vindex desktop-base-file-name
1942@vindex desktop-path
1943 Emacs sessions are stored in desktop files. When Emacs starts, it
1944looks for a desktop file in the current directory and in your home
1945directory, in that order. Thus, if you save a desktop file in your
1946home directory, it will act as a default desktop when you start Emacs
1947from a directory that doesn't have its own. Once a desktop file is
1948found, the session described in it will be restored, and the directory
1949where the desktop file was found will become the desktop directory.
1950The desktop directory is the directory in which the desktop file is
1951saved when Emacs is exited; it is saved in the variable
1952@code{desktop-dirname}.
1953
1954 You can change the base name of the desktop file and the list of
1955directories where Emacs should look for a desktop file at startup by
1956customizing the variables @code{desktop-base-file-name} and
1957@code{desktop-path}.
1958
1959@node Saving manually
1960@subsection Saving the desktop manually
1961@vindex desktop-save
1962@findex desktop-save
1963@findex desktop-save-in-desktop-dir
1964 If you prefer to save desktops manually rather than having Emacs
1965save them automatically at exit, set the customizable variable
1966@code{desktop-save} to the value @code{nil}. Then desktops are never
1967saved automatically, instead you can save then by typing @kbd{M-x
1968desktop-save} or @kbd{M-x desktop-save-in-desktop-dir}. The first of
1969these commands prompts for a directory to save the desktop in, the
1970second saves it in the desktop directory. Customization of the
1971variable @code{desktop-save} also lets you control when the desktop
1972should be saved, based upon whether a desktop file already exists in
1973the desktop directory -- see the documentation of the variable.
1974
1975@node Information saved
1976@subsection Controlling which information to save
1907@vindex desktop-files-not-to-save 1977@vindex desktop-files-not-to-save
1908 The variable @code{desktop-files-not-to-save} controls which files are 1978@vindex desktop-modes-not-to-save
1909excluded from state saving. Its value is a regular expression that 1979@vindex desktop-buffer-modes-to-save
1910matches the files to exclude. By default, remote (ftp-accessed) files 1980@vindex desktop-globals-to-save
1911are excluded; this is because visiting them again in the subsequent 1981@vindex desktop-locals-to-save
1912session would be slow. If you want to include these files in state 1982 The customizable variable @code{desktop-files-not-to-save} controls
1913saving, set @code{desktop-files-not-to-save} to @code{"^$"}. 1983which files are excluded from state saving. Its value is a regular
1914@xref{Remote Files}. 1984expression that matches the files to exclude. By default, remote
1985(ssh- or ftp-accessed) files are excluded; this is because visiting
1986them again in a subsequent session would be slow. If you want to
1987include these files in state saving, set
1988@code{desktop-files-not-to-save} to @code{"^$"}. @xref{Remote Files}.
1989You can also exclude buffers from state saving based on their mode by
1990customizing @code{desktop-modes-not-to-save}.
1991
1992 It is possible to save the state of buffers not visiting files,
1993based on their mode. To do that, mention their mode it the
1994customizable variable @code{desktop-buffer-modes-to-save}. However,
1995only certain non-visiting modes will have their buffers recreated when
1996the desktop is loaded. These are @code{dired-mode}, @code{Info-mode},
1997@code{rmail-mode} and @code{mh-folder-mode}.
1998
1999@vindex desktop-save-hook
2000@findex desktop-truncate
2001 To control which variables will be saved in the desktop file,
2002customize the variables @code{desktop-globals-to-save} and
2003@code{desktop-locals-to-save}. List variables, such as
2004@code{search-ring} and @code{regexp-search-ring}, may contain
2005excessive amounts of data. If you want to save only the first
2006e.g.@: three elements, add to @code{desktop-save-hook} the function
2007
2008@example
2009'(lambda ()
2010 (desktop-truncate search-ring 3)
2011 (desktop-truncate regexp-search-ring 3))
2012@end example
1915 2013
2014@node Desktop clear
2015@subsection Clearing the desktop
2016@findex desktop-clear
2017@findex desktop-change-dir
2018@findex desktop-revert
2019@findex desktop-read
2020@vindex desktop-globals-to-clear
2021@vindex desktop-clear-preserve-buffers-regexp
2022@vindex desktop-no-desktop-file-hook
2023 Type @kbd{M-x desktop-clear} to empty the desktop. This will kill
2024all buffers except for internal ones and it will clear the global
2025variables listed in @code{desktop-globals-to-clear}. If you want to
2026preserve certain buffers, customize the variable
2027@code{desktop-clear-preserve-buffers-regexp}. Its value is a regular
2028expression matching the names of buffers not to kill. The commands
2029@code{desktop-change-dir} and @code{desktop-revert} both calls
2030@code{desktop-clear} before loading the desktop. Furthermore,
2031@code{desktop-read} calls @code{desktop-clear} if no desktop file is
2032found to load. If you want a dired buffer showing the desktop
2033directory in when no desktop file is found, customize
2034@code{desktop-no-desktop-file-hook} to have the value
2035@code{((lambda () (dired desktop-dirname)))}. @pxref{Dired}.
2036
2037@node File name format
2038@subsection File name format
2039@vindex desktop-file-name-format
2040 The customizable variable @code{desktop-file-name-format} controls
2041the format in which file names are saved in the desktop buffer. The
2042default value is @code{absolute}, which means that file names are
2043absolute. If you change this to @code{tilde}, file names are relative
2044to your home directory. This means that desktop files might be copied
2045from one machine to another, altough the absolute name of the home
2046directories differ. If you change @code{desktop-file-name-format} to
2047@code{local}, file names are relative to the desktop directory.
2048
2049@node Saveplace
2050@subsection Saveplace
1916@vindex save-place 2051@vindex save-place
1917@cindex Saveplace 2052@cindex Saveplace
1918@findex toggle-save-place 2053@findex toggle-save-place