/[emacs]/emacs/man/misc.texi
ViewVC logotype

Diff of /emacs/man/misc.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.46 by miles, Mon Sep 1 15:45:46 2003 UTC revision 1.47 by lh, Tue Sep 30 07:24:14 2003 UTC
# Line 1875  hexl-@key{RET}} for details. Line 1875  hexl-@key{RET}} for details.
1875  @cindex reload files  @cindex reload files
1876  @cindex desktop  @cindex desktop
1877    
1878    You can use the Desktop library to save the state of Emacs from one    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  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  the same set of buffers, major modes, buffer positions, and so on that
1881  the previous Emacs session had.  the previous Emacs session had. Such a state is referred to as a ``desktop''.
1882    
1883  @vindex desktop-enable    The saveplace library provides a simpler feature that records your
1884    To use Desktop, you should use the Customization buffer (@pxref{Easy  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,  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:  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:
1910    
1911  @example  @example
1912  (require 'desktop)  (desktop-save-mode 1)
 (setq desktop-enable t)  
1913  @end example  @end example
1914    
1915  @noindent  @findex desktop-change-dir
1916  @findex desktop-save  @findex desktop-revert
1917  The first time you exit Emacs, you will be asked whether you want to  @findex desktop-read
1918  save your session.  Once you have done that, exiting Emacs will save  @vindex desktop-after-read-hook
1919  the state again in subsequent sessions.  You can also save the state    In order for Emacs to recover the desktop from a previous session, you
 at any time, without exiting Emacs, by typing @kbd{M-x desktop-save}.  
   
   In order for Emacs to recover the state from a previous session, you  
1920  must start it with the same current directory as you used when you  must start it with the same current directory as you used when you
1921  started the previous session.  This is because @code{desktop-read} looks  started the previous session.  This is because @code{desktop-read} looks
1922  in the current directory for the file to read.  This means that you can  in the current directory for the desktop file to read.  This means that you can
1923  have separate saved sessions in different directories; the directory in  have separate saved desktops in different directories; the directory in
1924  which you start Emacs will control which saved session to use.  which you start Emacs will control which saved desktop to use.
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
1977  @vindex desktop-files-not-to-save  @vindex desktop-files-not-to-save
1978    The variable @code{desktop-files-not-to-save} controls which files are  @vindex desktop-modes-not-to-save
1979  excluded from state saving.  Its value is a regular expression that  @vindex desktop-buffer-modes-to-save
1980  matches the files to exclude.  By default, remote (ftp-accessed) files  @vindex desktop-globals-to-save
1981  are excluded; this is because visiting them again in the subsequent  @vindex desktop-locals-to-save
1982  session would be slow.  If you want to include these files in state    The customizable variable @code{desktop-files-not-to-save} controls
1983  saving, set @code{desktop-files-not-to-save} to @code{"^$"}.  which files are excluded from state saving.  Its value is a regular
1984  @xref{Remote Files}.  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
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
2051  @vindex save-place  @vindex save-place
2052  @cindex Saveplace  @cindex Saveplace
2053  @findex toggle-save-place  @findex toggle-save-place

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26