diff options
| author | Lars Hansen | 2003-09-30 07:24:14 +0000 |
|---|---|---|
| committer | Lars Hansen | 2003-09-30 07:24:14 +0000 |
| commit | 080e83d1ccb59387416218e40a35de85de4010bc (patch) | |
| tree | 970bcd7ec2faee201d1d4a624d9e6a0db04bc104 /man | |
| parent | c5b31c4d7923a82a2937877f891a5e67f7ea6511 (diff) | |
| download | emacs-080e83d1ccb59387416218e40a35de85de4010bc.tar.gz emacs-080e83d1ccb59387416218e40a35de85de4010bc.zip | |
Section "Saving Emacs Sessions" rewritten.
Diffstat (limited to 'man')
| -rw-r--r-- | man/misc.texi | 189 |
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 |
| 1879 | session to another. Saving the state means that Emacs starts up with | 1879 | session to another. Saving the state means that Emacs starts up with |
| 1880 | the same set of buffers, major modes, buffer positions, and so on that | 1880 | the same set of buffers, major modes, buffer positions, and so on that |
| 1881 | the previous Emacs session had. | 1881 | the 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 | 1884 | position in each file when you kill its buffer (or kill Emacs), and |
| 1885 | Customization}) to set @code{desktop-enable} to a non-@code{nil} value, | 1885 | jumps to the same position when you visit the file again (even in |
| 1886 | or add these lines at the end of your @file{.emacs} file: | 1886 | another Emacs session). |
| 1887 | |||
| 1888 | @menu | ||
| 1889 | The 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 | |||
| 1897 | The 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}. | ||
| 1906 | To enable desktop saving, you should use the Customization buffer | ||
| 1907 | (@pxref{Easy Customization}) to set @code{desktop-save-mode} to a | ||
| 1908 | non-@code{nil} value for future sessions, or add this line somewhere | ||
| 1909 | in 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 |
| 1895 | The first time you exit Emacs, you will be asked whether you want to | 1917 | @findex desktop-read |
| 1896 | save your session. Once you have done that, exiting Emacs will save | 1918 | @vindex desktop-after-read-hook |
| 1897 | the 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 |
| 1898 | at 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 | ||
| 1901 | must start it with the same current directory as you used when you | 1920 | must start it with the same current directory as you used when you |
| 1902 | started the previous session. This is because @code{desktop-read} looks | 1921 | started the previous session. This is because @code{desktop-read} looks |
| 1903 | in the current directory for the file to read. This means that you can | 1922 | in the current directory for the desktop file to read. This means that you can |
| 1904 | have separate saved sessions in different directories; the directory in | 1923 | have separate saved desktops in different directories; the directory in |
| 1905 | which you start Emacs will control which saved session to use. | 1924 | which you start Emacs will control which saved desktop to use. |
| 1906 | 1925 | You can also save the current desktop and recover one saved in another directory | |
| 1926 | by typing @kbd{M-x desktop-change-dir}. | ||
| 1927 | Typing @kbd{M-x desktop-revert} reverts to the last recovered desktop. | ||
| 1928 | |||
| 1929 | You may want Emacs to display a buffer list when a desktop is | ||
| 1930 | loaded. This is possible by adding e.g.@: the function @code{buffer-menu} to | ||
| 1931 | @code{desktop-after-read-hook}. @pxref{Buffers}. | ||
| 1932 | |||
| 1933 | Specify the option @samp{--no-desktop} on the command line when you don't want | ||
| 1934 | any 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 | ||
| 1944 | looks for a desktop file in the current directory and in your home | ||
| 1945 | directory, in that order. Thus, if you save a desktop file in your | ||
| 1946 | home directory, it will act as a default desktop when you start Emacs | ||
| 1947 | from a directory that doesn't have its own. Once a desktop file is | ||
| 1948 | found, the session described in it will be restored, and the directory | ||
| 1949 | where the desktop file was found will become the desktop directory. | ||
| 1950 | The desktop directory is the directory in which the desktop file is | ||
| 1951 | saved 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 | ||
| 1955 | directories where Emacs should look for a desktop file at startup by | ||
| 1956 | customizing 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 | ||
| 1965 | save them automatically at exit, set the customizable variable | ||
| 1966 | @code{desktop-save} to the value @code{nil}. Then desktops are never | ||
| 1967 | saved automatically, instead you can save then by typing @kbd{M-x | ||
| 1968 | desktop-save} or @kbd{M-x desktop-save-in-desktop-dir}. The first of | ||
| 1969 | these commands prompts for a directory to save the desktop in, the | ||
| 1970 | second saves it in the desktop directory. Customization of the | ||
| 1971 | variable @code{desktop-save} also lets you control when the desktop | ||
| 1972 | should be saved, based upon whether a desktop file already exists in | ||
| 1973 | the 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 |
| 1909 | excluded from state saving. Its value is a regular expression that | 1979 | @vindex desktop-buffer-modes-to-save |
| 1910 | matches the files to exclude. By default, remote (ftp-accessed) files | 1980 | @vindex desktop-globals-to-save |
| 1911 | are excluded; this is because visiting them again in the subsequent | 1981 | @vindex desktop-locals-to-save |
| 1912 | session would be slow. If you want to include these files in state | 1982 | The customizable variable @code{desktop-files-not-to-save} controls |
| 1913 | saving, set @code{desktop-files-not-to-save} to @code{"^$"}. | 1983 | which files are excluded from state saving. Its value is a regular |
| 1914 | @xref{Remote Files}. | 1984 | expression that matches the files to exclude. By default, remote |
| 1985 | (ssh- or ftp-accessed) files are excluded; this is because visiting | ||
| 1986 | them again in a subsequent session would be slow. If you want to | ||
| 1987 | include these files in state saving, set | ||
| 1988 | @code{desktop-files-not-to-save} to @code{"^$"}. @xref{Remote Files}. | ||
| 1989 | You can also exclude buffers from state saving based on their mode by | ||
| 1990 | customizing @code{desktop-modes-not-to-save}. | ||
| 1991 | |||
| 1992 | It is possible to save the state of buffers not visiting files, | ||
| 1993 | based on their mode. To do that, mention their mode it the | ||
| 1994 | customizable variable @code{desktop-buffer-modes-to-save}. However, | ||
| 1995 | only certain non-visiting modes will have their buffers recreated when | ||
| 1996 | the 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, | ||
| 2002 | customize 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 | ||
| 2005 | excessive amounts of data. If you want to save only the first | ||
| 2006 | e.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 | ||
| 2024 | all buffers except for internal ones and it will clear the global | ||
| 2025 | variables listed in @code{desktop-globals-to-clear}. If you want to | ||
| 2026 | preserve certain buffers, customize the variable | ||
| 2027 | @code{desktop-clear-preserve-buffers-regexp}. Its value is a regular | ||
| 2028 | expression 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 | ||
| 2032 | found to load. If you want a dired buffer showing the desktop | ||
| 2033 | directory 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 | ||
| 2041 | the format in which file names are saved in the desktop buffer. The | ||
| 2042 | default value is @code{absolute}, which means that file names are | ||
| 2043 | absolute. If you change this to @code{tilde}, file names are relative | ||
| 2044 | to your home directory. This means that desktop files might be copied | ||
| 2045 | from one machine to another, altough the absolute name of the home | ||
| 2046 | directories 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 |