Mercurial > hg > xemacs-beta
view man/lispref/backups.texi @ 2367:ecf1ebac70d8
[xemacs-hg @ 2004-11-04 23:05:23 by ben]
commit mega-patch
configure.in: Turn off -Winline and -Wchar-subscripts.
Use the right set of cflags when compiling modules.
Rewrite ldap configuration to separate the inclusion of lber
(needed in recent Cygwin) from the basic checks for the
needed libraries.
add a function for MAKE_JUNK_C; initially code was added to
generate xemacs.def using this, but it will need to be rewritten.
add an rm -f for junk.c to avoid weird Cygwin bug with cp -f onto
an existing file.
Sort list of auto-detected functions and eliminate unused checks for
stpcpy, setlocale and getwd.
Add autodetection of Cygwin scanf problems
BETA: Rewrite section on configure to indicate what flags are important
and what not.
digest-doc.c, make-dump-id.c, profile.c, sorted-doc.c: Add proper decls for main().
make-msgfile.c: Document that this is old junk.
Move proposal to text.c.
make-msgfile.lex: Move proposal to text.c.
make-mswin-unicode.pl: Convert error-generating code so that the entire message will
be seen as a single unrecognized token.
mule/mule-ccl.el: Update docs.
lispref/mule.texi: Update CCL docs.
ldap/eldap.c: Mule-ize.
Use EXTERNAL_LIST_LOOP_2 instead of deleted EXTERNAL_LIST_LOOP.
* XEmacs 21.5.18 "chestnut" is released.
---------------------------------------------------------------
MULE-RELATED WORK:
---------------------------------------------------------------
---------------------------
byte-char conversion
---------------------------
buffer.c, buffer.h, insdel.c, text.c: Port FSF algorithm for byte-char conversion, replacing broken
previous version. Track the char position of the gap. Add
functions to do char-byte conversion downwards as well as upwards.
Move comments about algorithm workings to internals manual.
---------------------------
work on types
---------------------------
alloc.c, console-x-impl.h, dump-data.c, dump-data.h, dumper.c, dialog-msw.c, dired-msw.c, doc.c, editfns.c, esd.c, event-gtk.h, event-msw.c, events.c, file-coding.c, file-coding.h, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-shared.c, glyphs-x.c, glyphs.c, glyphs.h, gui.c, hpplay.c, imgproc.c, intl-win32.c, lrecord.h, lstream.c, keymap.c, lisp.h, libsst.c, linuxplay.c, miscplay.c, miscplay.h, mule-coding.c, nas.c, nt.c, ntheap.c, ntplay.c, objects-msw.c, objects-tty.c, objects-x.c, print.c, process-nt.c, process.c, redisplay.h, select-common.h, select-gtk.c, select-x.c, sgiplay.c, sound.c, sound.h, sunplay.c, sysfile.h, sysdep.c, syswindows.h, text.c, unexnt.c, win32.c, xgccache.c: Further work on types. This creates a full set of types for all
the basic semantics of `char' that I have so far identified, so that
its semantics can always be identified for the purposes of proper
Mule-safe code, and the raw use of `char' always avoided.
(1) More type renaming, for consistency of naming.
Char_ASCII -> Ascbyte
UChar_ASCII -> UAscbyte
Char_Binary -> CBinbyte
UChar_Binary -> Binbyte
SChar_Binary -> SBinbyte
(2) Introduce Rawbyte, CRawbyte, Boolbyte, Chbyte, UChbyte, and
Bitbyte and use them.
(3) New types Itext, Wexttext and Textcount for separating out
the concepts of bytes and textual units (different under UTF-16
and UTF-32, which are potential internal encodings).
(4) qxestr*_c -> qxestr*_ascii.
lisp.h: New; goes with other qxe() functions. #### Maybe goes in a
different section.
lisp.h: Group generic int-type defs together with EMACS_INT defs.
lisp.h: * lisp.h (WEXTTEXT_IS_WIDE)
New defns.
lisp.h: New type to replace places where int occurs as a boolean.
It's signed because occasionally people may want to use -1 as
an error value, and because unsigned ints are viral -- see comments
in the internals manual against using them.
dynarr.c: int -> Bytecount.
---------------------------
Mule-izing
---------------------------
device-x.c: Partially Mule-ize.
dumper.c, dumper.h: Mule-ize. Use Rawbyte. Use stderr_out not printf. Use wext_*().
sysdep.c, syswindows.h, text.c: New Wexttext API for manipulation of external text that may be
Unicode (e.g. startup code under Windows).
emacs.c: Mule-ize. Properly deal with argv in external encoding.
Use wext_*() and Wexttext. Use Rawbyte.
#if 0 some old junk on SCO that is unlikely to be correct.
Rewrite allocation code in run-temacs.
emacs.c, symsinit.h, win32.c: Rename win32 init function and call it even earlier, to
initialize mswindows_9x_p even earlier, for use in startup code
(XEUNICODE_P).
process.c: Use _wenviron not environ under Windows, to get Unicode environment
variables.
event-Xt.c: Mule-ize drag-n-drop related stuff.
dragdrop.c, dragdrop.h, frame-x.c: Mule-ize.
text.h: Add some more stand-in defines for particular kinds of conversion;
use in Mule-ization work in frame-x.c etc.
---------------------------
Freshening
---------------------------
intl-auto-encap-win32.c, intl-auto-encap-win32.h: Regenerate.
---------------------------
Unicode-work
---------------------------
intl-win32.c, syswindows.h: Factor out common options to MultiByteToWideChar and
WideCharToMultiByte. Add convert_unicode_to_multibyte_malloc()
and convert_unicode_to_multibyte_dynarr() and use. Add stuff for
alloca() conversion of multibyte/unicode.
alloc.c: Use dfc_external_data_len() in case of unicode coding system.
alloc.c, mule-charset.c: Don't zero out and reinit charset Unicode tables. This fucks up
dump-time loading. Anyway, either we load them at dump time or
run time, never both.
unicode.c: Dump the blank tables as well.
---------------------------------------------------------------
DOCUMENTATION, MOSTLY MULE-RELATED:
---------------------------------------------------------------
EmacsFrame.c, emodules.c, event-Xt.c, fileio.c, input-method-xlib.c, mule-wnnfns.c, redisplay-gtk.c, redisplay-tty.c, redisplay-x.c, regex.c, sysdep.c: Add comment about Mule work needed.
text.h: Add more documentation describing why DFC routines were not written
to return their value. Add some other DFC documentation.
console-msw.c, console-msw.h: Add pointer to docs in win32.c.
emacs.c: Add comments on sources of doc info.
text.c, charset.h, unicode.c, intl-win32.c, intl-encap-win32.c, text.h, file-coding.c, mule-coding.c: Collect background comments and related to text matters and
internationalization, and proposals for work to be done, in text.c
or Internals manual, stuff related to specific textual API's in
text.h, and stuff related to internal implementation of Unicode
conversion in unicode.c. Put lots of pointers to the comments to
make them easier to find.
s/mingw32.h, s/win32-common.h, s/win32-native.h, s/windowsnt.h, win32.c: Add bunches of new documentation on the different kinds of
builds and environments under Windows and how they work.
Collect this info in win32.c. Add pointers to these docs in
the relevant s/* files.
emacs.c: Document places with long comments.
Remove comment about exiting, move to internals manual, put
in pointer.
event-stream.c: Move docs about event queues and focus to internals manual, put
in pointer.
events.h: Move docs about event stream callbacks to internals manual, put
in pointer.
profile.c, redisplay.c, signal.c: Move documentation to the Internals manual.
process-nt.c: Add pointer to comment in win32-native.el.
lisp.h: Add comments about some comment conventions.
lisp.h: Add comment about the second argument.
device-msw.c, redisplay-msw.c: @@#### comments are out-of-date.
---------------------------------------------------------------
PDUMP WORK (MOTIVATED BY UNICODE CHANGES)
---------------------------------------------------------------
alloc.c, buffer.c, bytecode.c, console-impl.h, console.c, device.c, dumper.c, lrecord.h, elhash.c, emodules.h, events.c, extents.c, frame.c, glyphs.c, glyphs.h, mule-charset.c, mule-coding.c, objects.c, profile.c, rangetab.c, redisplay.c, specifier.c, specifier.h, window.c, lstream.c, file-coding.h, file-coding.c: PDUMP:
Properly implement dump_add_root_block(), which never worked before,
and is necessary for dumping Unicode tables.
Pdump name changes for accuracy:
XD_STRUCT_PTR -> XD_BLOCK_PTR.
XD_STRUCT_ARRAY -> XD_BLOCK_ARRAY.
XD_C_STRING -> XD_ASCII_STRING.
*_structure_* -> *_block_*.
lrecord.h: some comments added about
dump_add_root_block() vs dump_add_root_block_ptr().
extents.c: remove incorrect comment about pdump problems with gap array.
---------------------------------------------------------------
ALLOCATION
---------------------------------------------------------------
abbrev.c, alloc.c, bytecode.c, casefiddle.c, device-msw.c, device-x.c, dired-msw.c, doc.c, doprnt.c, dragdrop.c, editfns.c, emodules.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-msw.c, gui-x.c, imgproc.c, intl-win32.c, lread.c, menubar-gtk.c, menubar.c, nt.c, objects-msw.c, objects-x.c, print.c, process-nt.c, process-unix.c, process.c, realpath.c, redisplay.c, search.c, select-common.c, symbols.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: New macros {alloca,xnew}_{itext,{i,ext,raw,bin,asc}bytes} for
more convenient allocation of these commonly requested items.
Modify functions to use alloca_ibytes, alloca_array, alloca_extbytes,
xnew_ibytes, etc. also XREALLOC_ARRAY, xnew.
alloc.c: Rewrite the allocation functions to factor out repeated code.
Add assertions for freeing dumped data.
lisp.h: Moved down and consolidated with other allocation stuff.
lisp.h, dynarr.c: New functions for allocation that's very efficient when mostly in
LIFO order.
lisp.h, text.c, text.h: Factor out some stuff for general use by alloca()-conversion funs.
text.h, lisp.h: Fill out convenience routines for allocating various kinds of
bytes and put them in lisp.h. Use them in place of xmalloc(),
ALLOCA().
text.h: Fill out the convenience functions so the _MALLOC() kinds match
the alloca() kinds.
---------------------------------------------------------------
ERROR-CHECKING
---------------------------------------------------------------
text.h: Create ASSERT_ASCTEXT_ASCII() and ASSERT_ASCTEXT_ASCII_LEN()
from similar Eistring checkers and change the Eistring checkers to
use them instead.
---------------------------------------------------------------
MACROS IN LISP.H
---------------------------------------------------------------
lisp.h: Redo GCPRO declarations. Create a "base" set of functions that can
be used to generate any kind of gcpro sets -- regular, ngcpro,
nngcpro, private ones used in GC_EXTERNAL_LIST_LOOP_2.
buffer.c, callint.c, chartab.c, console-msw.c, device-x.c, dialog-msw.c, dired.c, extents.c, ui-gtk.c, rangetab.c, nt.c, mule-coding.c, minibuf.c, menubar-msw.c, menubar.c, menubar-gtk.c, lread.c, lisp.h, gutter.c, glyphs.c, glyphs-widget.c, fns.c, fileio.c, file-coding.c, specifier.c: Eliminate EXTERNAL_LIST_LOOP, which does not check for circularities.
Use EXTERNAL_LIST_LOOP_2 instead or EXTERNAL_LIST_LOOP_3
or EXTERNAL_PROPERTY_LIST_LOOP_3 or GC_EXTERNAL_LIST_LOOP_2
(new macro). Removed/redid comments on EXTERNAL_LIST_LOOP.
---------------------------------------------------------------
SPACING FIXES
---------------------------------------------------------------
callint.c, hftctl.c, number-gmp.c, process-unix.c: Spacing fixes.
---------------------------------------------------------------
FIX FOR GEOMETRY PROBLEM IN FIRST FRAME
---------------------------------------------------------------
unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by
release 1.5.12 of Cygwin].
toolbar.c: bug fix for problem of initial frame being 77 chars wide on Windows.
will be overridden by my other ws.
---------------------------------------------------------------
FIX FOR LEAKING PROCESS HANDLES:
---------------------------------------------------------------
process-nt.c: Fixes for leaking handles. Inspired by work done by Adrian Aichner
<adrian@xemacs.org>.
---------------------------------------------------------------
FIX FOR CYGWIN BUG (Unicode-related):
---------------------------------------------------------------
unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by
release 1.5.12 of Cygwin].
---------------------------------------------------------------
WARNING FIXES:
---------------------------------------------------------------
console-stream.c: `reinit' is unused.
compiler.h, event-msw.c, frame-msw.c, intl-encap-win32.c, text.h: Add stuff to deal with ANSI-aliasing warnings I got.
regex.c: Gather includes together to avoid warning.
---------------------------------------------------------------
CHANGES TO INITIALIZATION ROUTINES:
---------------------------------------------------------------
buffer.c, emacs.c, console.c, debug.c, device-x.c, device.c, dragdrop.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, font-lock.c, frame-msw.c, glyphs-widget.c, glyphs.c, gui-x.c, insdel.c, lread.c, lstream.c, menubar-gtk.c, menubar-x.c, minibuf.c, mule-wnnfns.c, objects-msw.c, objects.c, print.c, scrollbar-x.c, search.c, select-x.c, text.c, undo.c, unicode.c, window.c, symsinit.h: Call reinit_*() functions directly from emacs.c, for clarity.
Factor out some redundant init code. Move disallowed stuff
that had crept into vars_of_glyphs() into complex_vars_of_glyphs().
Call init_eval_semi_early() from eval.c not in the middle of
vars_of_() in emacs.c since there should be no order dependency
in the latter calls.
---------------------------------------------------------------
ARMAGEDDON:
---------------------------------------------------------------
alloc.c, emacs.c, lisp.h, print.c: Rename inhibit_non_essential_printing_operations to
inhibit_non_essential_conversion_operations.
text.c: Assert on !inhibit_non_essential_conversion_operations.
console-msw.c, print.c: Don't do conversion in SetConsoleTitle or FindWindow to avoid
problems during armageddon. Put #errors for NON_ASCII_INTERNAL_FORMAT
in places where problems would arise.
---------------------------------------------------------------
CHANGES TO THE BUILD PROCEDURE:
---------------------------------------------------------------
config.h.in, s/cxux.h, s/usg5-4-2.h, m/powerpc.h: Add comment about correct ordering of this file.
Rearrange everything to follow this -- put all #undefs together
and before the s&m files. Add undefs for HAVE_ALLOCA, C_ALLOCA,
BROKEN_ALLOCA_IN_FUNCTION_CALLS, STACK_DIRECTION. Remove unused
HAVE_STPCPY, HAVE_GETWD, HAVE_SETLOCALE.
m/gec63.h: Deleted; totally broken, not used at all, not in FSF.
m/7300.h, m/acorn.h, m/alliant-2800.h, m/alliant.h, m/altos.h, m/amdahl.h, m/apollo.h, m/att3b.h, m/aviion.h, m/celerity.h, m/clipper.h, m/cnvrgnt.h, m/convex.h, m/cydra5.h, m/delta.h, m/delta88k.h, m/dpx2.h, m/elxsi.h, m/ews4800r.h, m/gould.h, m/hp300bsd.h, m/hp800.h, m/hp9000s300.h, m/i860.h, m/ibmps2-aix.h, m/ibmrs6000.h, m/ibmrt-aix.h, m/ibmrt.h, m/intel386.h, m/iris4d.h, m/iris5d.h, m/iris6d.h, m/irist.h, m/isi-ov.h, m/luna88k.h, m/m68k.h, m/masscomp.h, m/mg1.h, m/mips-nec.h, m/mips-siemens.h, m/mips.h, m/news.h, m/nh3000.h, m/nh4000.h, m/ns32000.h, m/orion105.h, m/pfa50.h, m/plexus.h, m/pmax.h, m/powerpc.h, m/pyrmips.h, m/sequent-ptx.h, m/sequent.h, m/sgi-challenge.h, m/symmetry.h, m/tad68k.h, m/tahoe.h, m/targon31.h, m/tekxd88.h, m/template.h, m/tower32.h, m/tower32v3.h, m/ustation.h, m/vax.h, m/wicat.h, m/xps100.h: Delete C_ALLOCA, HAVE_ALLOCA, STACK_DIRECTION,
BROKEN_ALLOCA_IN_FUNCTION_CALLS. All of this is auto-detected.
When in doubt, I followed recent FSF sources, which also have
these things deleted.
author | ben |
---|---|
date | Thu, 04 Nov 2004 23:08:28 +0000 |
parents | 094487d1005d |
children | 9fae6227ede5 |
line wrap: on
line source
@c -*-texinfo-*- @c This is part of the XEmacs Lisp Reference Manual. @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. @c See the file lispref.texi for copying conditions. @setfilename ../../info/backups.info @node Backups and Auto-Saving, Buffers, Files, Top @chapter Backups and Auto-Saving Backup files and auto-save files are two methods by which XEmacs tries to protect the user from the consequences of crashes or of the user's own errors. Auto-saving preserves the text from earlier in the current editing session; backup files preserve file contents prior to the current session. @menu * Backup Files:: How backup files are made; how their names are chosen. * Auto-Saving:: How auto-save files are made; how their names are chosen. * Reverting:: @code{revert-buffer}, and how to customize what it does. @end menu @node Backup Files @section Backup Files @cindex backup file A @dfn{backup file} is a copy of the old contents of a file you are editing. XEmacs makes a backup file the first time you save a buffer into its visited file. Normally, this means that the backup file contains the contents of the file as it was before the current editing session. The contents of the backup file normally remain unchanged once it exists. Backups are usually made by renaming the visited file to a new name. Optionally, you can specify that backup files should be made by copying the visited file. This choice makes a difference for files with multiple names; it also can affect whether the edited file remains owned by the original owner or becomes owned by the user editing it. By default, XEmacs makes a single backup file for each file edited. You can alternatively request numbered backups; then each new backup file gets a new name. You can delete old numbered backups when you don't want them any more, or XEmacs can delete them automatically. @menu * Making Backups:: How XEmacs makes backup files, and when. * Rename or Copy:: Two alternatives: renaming the old file or copying it. * Numbered Backups:: Keeping multiple backups for each source file. * Backup Names:: How backup file names are computed; customization. @end menu @node Making Backups @subsection Making Backup Files @defun backup-buffer This function makes a backup of the file visited by the current buffer, if appropriate. It is called by @code{save-buffer} before saving the buffer the first time. @end defun @defvar buffer-backed-up This buffer-local variable indicates whether this buffer's file has been backed up on account of this buffer. If it is non-@code{nil}, then the backup file has been written. Otherwise, the file should be backed up when it is next saved (if backups are enabled). This is a permanent local; @code{kill-local-variables} does not alter it. @end defvar @defopt make-backup-files This variable determines whether or not to make backup files. If it is non-@code{nil}, then XEmacs creates a backup of each file when it is saved for the first time---provided that @code{backup-inhibited} is @code{nil} (see below). The following example shows how to change the @code{make-backup-files} variable only in the @file{RMAIL} buffer and not elsewhere. Setting it @code{nil} stops XEmacs from making backups of the @file{RMAIL} file, which may save disk space. (You would put this code in your @file{.emacs} file.) @smallexample @group (add-hook 'rmail-mode-hook (function (lambda () (make-local-variable 'make-backup-files) (setq make-backup-files nil)))) @end group @end smallexample @end defopt @defvar backup-enable-predicate This variable's value is a function to be called on certain occasions to decide whether a file should have backup files. The function receives one argument, a file name to consider. If the function returns @code{nil}, backups are disabled for that file. Otherwise, the other variables in this section say whether and how to make backups. The default value is this: @example (lambda (name) (or (< (length name) 5) (not (string-equal "/tmp/" (substring name 0 5))))) @end example @end defvar @defvar backup-inhibited If this variable is non-@code{nil}, backups are inhibited. It records the result of testing @code{backup-enable-predicate} on the visited file name. It can also coherently be used by other mechanisms that inhibit backups based on which file is visited. For example, VC sets this variable non-@code{nil} to prevent making backups for files managed with a version control system. This is a permanent local, so that changing the major mode does not lose its value. Major modes should not set this variable---they should set @code{make-backup-files} instead. @end defvar @node Rename or Copy @subsection Backup by Renaming or by Copying? @cindex backup files, how to make them There are two ways that XEmacs can make a backup file: @itemize @bullet @item XEmacs can rename the original file so that it becomes a backup file, and then write the buffer being saved into a new file. After this procedure, any other names (i.e., hard links) of the original file now refer to the backup file. The new file is owned by the user doing the editing, and its group is the default for new files written by the user in that directory. @item XEmacs can copy the original file into a backup file, and then overwrite the original file with new contents. After this procedure, any other names (i.e., hard links) of the original file still refer to the current version of the file. The file's owner and group will be unchanged. @end itemize The first method, renaming, is the default. The variable @code{backup-by-copying}, if non-@code{nil}, says to use the second method, which is to copy the original file and overwrite it with the new buffer contents. The variable @code{file-precious-flag}, if non-@code{nil}, also has this effect (as a sideline of its main significance). @xref{Saving Buffers}. @defvar backup-by-copying If this variable is non-@code{nil}, XEmacs always makes backup files by copying. @end defvar The following two variables, when non-@code{nil}, cause the second method to be used in certain special cases. They have no effect on the treatment of files that don't fall into the special cases. @defvar backup-by-copying-when-linked If this variable is non-@code{nil}, XEmacs makes backups by copying for files with multiple names (hard links). This variable is significant only if @code{backup-by-copying} is @code{nil}, since copying is always used when that variable is non-@code{nil}. @end defvar @defvar backup-by-copying-when-mismatch If this variable is non-@code{nil}, XEmacs makes backups by copying in cases where renaming would change either the owner or the group of the file. The value has no effect when renaming would not alter the owner or group of the file; that is, for files which are owned by the user and whose group matches the default for a new file created there by the user. This variable is significant only if @code{backup-by-copying} is @code{nil}, since copying is always used when that variable is non-@code{nil}. @end defvar @node Numbered Backups @subsection Making and Deleting Numbered Backup Files If a file's name is @file{foo}, the names of its numbered backup versions are @file{foo.~@var{v}~}, for various integers @var{v}, like this: @file{foo.~1~}, @file{foo.~2~}, @file{foo.~3~}, @dots{}, @file{foo.~259~}, and so on. @defopt version-control This variable controls whether to make a single non-numbered backup file or multiple numbered backups. @table @asis @item @code{nil} Make numbered backups if the visited file already has numbered backups; otherwise, do not. @item @code{never} Do not make numbered backups. @item @var{anything else} Make numbered backups. @end table @end defopt The use of numbered backups ultimately leads to a large number of backup versions, which must then be deleted. XEmacs can do this automatically or it can ask the user whether to delete them. @defopt kept-new-versions The value of this variable is the number of newest versions to keep when a new numbered backup is made. The newly made backup is included in the count. The default value is 2. @end defopt @defopt kept-old-versions The value of this variable is the number of oldest versions to keep when a new numbered backup is made. The default value is 2. @end defopt If there are backups numbered 1, 2, 3, 5, and 7, and both of these variables have the value 2, then the backups numbered 1 and 2 are kept as old versions and those numbered 5 and 7 are kept as new versions; backup version 3 is excess. The function @code{find-backup-file-name} (@pxref{Backup Names}) is responsible for determining which backup versions to delete, but does not delete them itself. @defopt delete-old-versions If this variable is non-@code{nil}, then saving a file deletes excess backup versions silently. Otherwise, it asks the user whether to delete them. @end defopt @defopt dired-kept-versions This variable specifies how many of the newest backup versions to keep in the Dired command @kbd{.} (@code{dired-clean-directory}). That's the same thing @code{kept-new-versions} specifies when you make a new backup file. The default value is 2. @end defopt @node Backup Names @subsection Naming Backup Files The functions in this section are documented mainly because you can customize the naming conventions for backup files by redefining them. If you change one, you probably need to change the rest. @defun backup-file-name-p filename This function returns a non-@code{nil} value if @var{filename} is a possible name for a backup file. A file with the name @var{filename} need not exist; the function just checks the name. @smallexample @group (backup-file-name-p "foo") @result{} nil @end group @group (backup-file-name-p "foo~") @result{} 3 @end group @end smallexample The standard definition of this function is as follows: @smallexample @group (defun backup-file-name-p (file) "Return non-nil if FILE is a backup file \ name (numeric or not)..." (string-match "~$" file)) @end group @end smallexample @noindent Thus, the function returns a non-@code{nil} value if the file name ends with a @samp{~}. (We use a backslash to split the documentation string's first line into two lines in the text, but produce just one line in the string itself.) This simple expression is placed in a separate function to make it easy to redefine for customization. @end defun @defun make-backup-file-name filename This function returns a string that is the name to use for a non-numbered backup file for file @var{filename}. On Unix, this is just @var{filename} with a tilde appended. The standard definition of this function is as follows: @smallexample @group (defun make-backup-file-name (file) "Create the non-numeric backup file name for FILE. @dots{}" (concat file "~")) @end group @end smallexample You can change the backup-file naming convention by redefining this function. The following example redefines @code{make-backup-file-name} to prepend a @samp{.} in addition to appending a tilde: @smallexample @group (defun make-backup-file-name (filename) (concat "." filename "~")) @end group @group (make-backup-file-name "backups.texi") @result{} ".backups.texi~" @end group @end smallexample @end defun @defun find-backup-file-name filename This function computes the file name for a new backup file for @var{filename}. It may also propose certain existing backup files for deletion. @code{find-backup-file-name} returns a list whose @sc{car} is the name for the new backup file and whose @sc{cdr} is a list of backup files whose deletion is proposed. Two variables, @code{kept-old-versions} and @code{kept-new-versions}, determine which backup versions should be kept. This function keeps those versions by excluding them from the @sc{cdr} of the value. @xref{Numbered Backups}. In this example, the value says that @file{~rms/foo.~5~} is the name to use for the new backup file, and @file{~rms/foo.~3~} is an ``excess'' version that the caller should consider deleting now. @smallexample @group (find-backup-file-name "~rms/foo") @result{} ("~rms/foo.~5~" "~rms/foo.~3~") @end group @end smallexample @end defun @c Emacs 19 feature @defun file-newest-backup filename This function returns the name of the most recent backup file for @var{filename}, or @code{nil} if that file has no backup files. Some file comparison commands use this function so that they can automatically compare a file with its most recent backup. @end defun @node Auto-Saving @section Auto-Saving @cindex auto-saving XEmacs periodically saves all files that you are visiting; this is called @dfn{auto-saving}. Auto-saving prevents you from losing more than a limited amount of work if the system crashes. By default, auto-saves happen every 300 keystrokes, or after around 30 seconds of idle time. @xref{Auto Save, Auto-Save, Auto-Saving: Protection Against Disasters, xemacs, The XEmacs User's Manual}, for information on auto-save for users. Here we describe the functions used to implement auto-saving and the variables that control them. @defvar buffer-auto-save-file-name This buffer-local variable is the name of the file used for auto-saving the current buffer. It is @code{nil} if the buffer should not be auto-saved. @example @group buffer-auto-save-file-name => "/xcssun/users/rms/lewis/#files.texi#" @end group @end example @end defvar @deffn Command auto-save-mode arg When used interactively without an argument, this command is a toggle switch: it turns on auto-saving of the current buffer if it is off, and vice-versa. With an argument @var{arg}, the command turns auto-saving on if the value of @var{arg} is @code{t}, a nonempty list, or a positive integer. Otherwise, it turns auto-saving off. @end deffn @defun auto-save-file-name-p filename This function returns a non-@code{nil} value if @var{filename} is a string that could be the name of an auto-save file. It works based on knowledge of the naming convention for auto-save files: a name that begins and ends with hash marks (@samp{#}) is a possible auto-save file name. The argument @var{filename} should not contain a directory part. @example @group (make-auto-save-file-name) @result{} "/xcssun/users/rms/lewis/#files.texi#" @end group @group (auto-save-file-name-p "#files.texi#") @result{} 0 @end group @group (auto-save-file-name-p "files.texi") @result{} nil @end group @end example The standard definition of this function is as follows: @example @group (defun auto-save-file-name-p (filename) "Return non-nil if FILENAME can be yielded by..." (string-match "^#.*#$" filename)) @end group @end example This function exists so that you can customize it if you wish to change the naming convention for auto-save files. If you redefine it, be sure to redefine the function @code{make-auto-save-file-name} correspondingly. @end defun @defun make-auto-save-file-name &optional filename This function returns the file name to use for auto-saving the current buffer. This is just the file name with hash marks (@samp{#}) appended and prepended to it. This function does not look at the variable @code{auto-save-visited-file-name} (described below); you should check that before calling this function. @example @group (make-auto-save-file-name) @result{} "/xcssun/users/rms/lewis/#backup.texi#" @end group @end example The standard definition of this function is as follows: @example @group (defun make-auto-save-file-name () "Return file name to use for auto-saves \ of current buffer. @dots{}" (if buffer-file-name @end group @group (concat (file-name-directory buffer-file-name) "#" (file-name-nondirectory buffer-file-name) "#") (expand-file-name (concat "#%" (buffer-name) "#")))) @end group @end example This exists as a separate function so that you can redefine it to customize the naming convention for auto-save files. Be sure to change @code{auto-save-file-name-p} in a corresponding way. @end defun @defvar auto-save-visited-file-name If this variable is non-@code{nil}, XEmacs auto-saves buffers in the files they are visiting. That is, the auto-save is done in the same file that you are editing. Normally, this variable is @code{nil}, so auto-save files have distinct names that are created by @code{make-auto-save-file-name}. When you change the value of this variable, the value does not take effect until the next time auto-save mode is reenabled in any given buffer. If auto-save mode is already enabled, auto-saves continue to go in the same file name until @code{auto-save-mode} is called again. @end defvar @defun recent-auto-save-p This function returns @code{t} if the current buffer has been auto-saved since the last time it was read in or saved. @end defun @defun set-buffer-auto-saved This function marks the current buffer as auto-saved. The buffer will not be auto-saved again until the buffer text is changed again. The function returns @code{nil}. @end defun @defopt auto-save-interval The value of this variable is the number of characters that XEmacs reads from the keyboard between auto-saves. Each time this many more characters are read, auto-saving is done for all buffers in which it is enabled. @end defopt @defopt auto-save-timeout The value of this variable is the number of seconds of idle time that should cause auto-saving. Each time the user pauses for this long, XEmacs auto-saves any buffers that need it. (Actually, the specified timeout is multiplied by a factor depending on the size of the current buffer.) @end defopt @defvar auto-save-hook This normal hook is run whenever an auto-save is about to happen. @end defvar @defopt auto-save-default If this variable is non-@code{nil}, buffers that are visiting files have auto-saving enabled by default. Otherwise, they do not. @end defopt @deffn Command do-auto-save &optional no-message current-only This function auto-saves all buffers that need to be auto-saved. It saves all buffers for which auto-saving is enabled and that have been changed since the previous auto-save. Normally, if any buffers are auto-saved, a message that says @samp{Auto-saving...} is displayed in the echo area while auto-saving is going on. However, if @var{no-message} is non-@code{nil}, the message is inhibited. If @var{current-only} is non-@code{nil}, only the current buffer is auto-saved. @end deffn @defun delete-auto-save-file-if-necessary This function deletes the current buffer's auto-save file if @code{delete-auto-save-files} is non-@code{nil}. It is called every time a buffer is saved. @end defun @defvar delete-auto-save-files This variable is used by the function @code{delete-auto-save-file-if-necessary}. If it is non-@code{nil}, Emacs deletes auto-save files when a true save is done (in the visited file). This saves disk space and unclutters your directory. @end defvar @defun rename-auto-save-file This function adjusts the current buffer's auto-save file name if the visited file name has changed. It also renames an existing auto-save file. If the visited file name has not changed, this function does nothing. @end defun @defvar buffer-saved-size The value of this buffer-local variable is the length of the current buffer as of the last time it was read in, saved, or auto-saved. This is used to detect a substantial decrease in size, and turn off auto-saving in response. If it is -1, that means auto-saving is temporarily shut off in this buffer due to a substantial deletion. Explicitly saving the buffer stores a positive value in this variable, thus reenabling auto-saving. Turning auto-save mode off or on also alters this variable. @end defvar @defvar auto-save-list-file-name This variable (if non-@code{nil}) specifies a file for recording the names of all the auto-save files. Each time XEmacs does auto-saving, it writes two lines into this file for each buffer that has auto-saving enabled. The first line gives the name of the visited file (it's empty if the buffer has none), and the second gives the name of the auto-save file. If XEmacs exits normally, it deletes this file. If XEmacs crashes, you can look in the file to find all the auto-save files that might contain work that was otherwise lost. The @code{recover-session} command uses these files. The default name for this file is in your home directory and starts with @samp{.saves-}. It also contains the XEmacs process @sc{id} and the host name. @end defvar @node Reverting @section Reverting If you have made extensive changes to a file and then change your mind about them, you can get rid of them by reading in the previous version of the file with the @code{revert-buffer} command. @xref{Reverting, , Reverting a Buffer, xemacs, The XEmacs User's Manual}. @deffn Command revert-buffer &optional check-auto-save noconfirm preserve-modes This command replaces the buffer text with the text of the visited file on disk. This action undoes all changes since the file was visited or saved. If the argument @var{check-auto-save} is non-@code{nil}, and the latest auto-save file is more recent than the visited file, @code{revert-buffer} asks the user whether to use that instead. Otherwise, it always uses the text of the visited file itself. Interactively, @var{check-auto-save} is set if there is a numeric prefix argument. Normally, @code{revert-buffer} asks for confirmation before it changes the buffer; but if the argument @var{noconfirm} is non-@code{nil}, @code{revert-buffer} does not ask for confirmation. Optional third argument @var{preserve-modes} non-@code{nil} means don't alter the files modes. Normally we reinitialize them using @code{normal-mode}. Reverting tries to preserve marker positions in the buffer by using the replacement feature of @code{insert-file-contents}. If the buffer contents and the file contents are identical before the revert operation, reverting preserves all the markers. If they are not identical, reverting does change the buffer; then it preserves the markers in the unchanged text (if any) at the beginning and end of the buffer. Preserving any additional markers would be problematical. @end deffn You can customize how @code{revert-buffer} does its work by setting these variables---typically, as buffer-local variables. @defvar revert-buffer-function The value of this variable is the function to use to revert this buffer. If non-@code{nil}, it is called as a function with no arguments to do the work of reverting. If the value is @code{nil}, reverting works the usual way. Modes such as Dired mode, in which the text being edited does not consist of a file's contents but can be regenerated in some other fashion, give this variable a buffer-local value that is a function to regenerate the contents. @end defvar @defvar revert-buffer-insert-file-contents-function The value of this variable, if non-@code{nil}, is the function to use to insert the updated contents when reverting this buffer. The function receives two arguments: first the file name to use; second, @code{t} if the user has asked to read the auto-save file. @end defvar @defvar before-revert-hook This normal hook is run by @code{revert-buffer} before actually inserting the modified contents---but only if @code{revert-buffer-function} is @code{nil}. Font Lock mode uses this hook to record that the buffer contents are no longer fontified. @end defvar @defvar after-revert-hook This normal hook is run by @code{revert-buffer} after actually inserting the modified contents---but only if @code{revert-buffer-function} is @code{nil}. Font Lock mode uses this hook to recompute the fonts for the updated buffer contents. @end defvar