home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / elisp.i14 < prev    next >
Encoding:
GNU Info File  |  1993-06-14  |  50.0 KB  |  1,222 lines

  1. This is Info file elisp, produced by Makeinfo-1.47 from the input file
  2. elisp.texi.
  3.  
  4.    This file documents GNU Emacs Lisp.
  5.  
  6.    This is edition 1.03 of the GNU Emacs Lisp Reference Manual, for
  7. Emacs Version 18.
  8.  
  9.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  10. Cambridge, MA 02139 USA
  11.  
  12.    Copyright (C) 1990 Free Software Foundation, Inc.
  13.  
  14.    Permission is granted to make and distribute verbatim copies of this
  15. manual provided the copyright notice and this permission notice are
  16. preserved on all copies.
  17.  
  18.    Permission is granted to copy and distribute modified versions of
  19. this manual under the conditions for verbatim copying, provided that
  20. the entire resulting derived work is distributed under the terms of a
  21. permission notice identical to this one.
  22.  
  23.    Permission is granted to copy and distribute translations of this
  24. manual into another language, under the above conditions for modified
  25. versions, except that this permission notice may be stated in a
  26. translation approved by the Foundation.
  27.  
  28. 
  29. File: elisp,  Node: Saving Buffers,  Next: Reading from Files,  Prev: Visiting Files,  Up: Files
  30.  
  31. Saving Buffers
  32. ==============
  33.  
  34.    When you edit a file in Emacs, you are actually working on a buffer
  35. that is visiting that file--that is, the contents of the file are
  36. copied into the buffer and the copy is what you edit.  Changes to the
  37. buffer do not change the file until you "save" the buffer, which means
  38. copying the contents of the buffer into the file.
  39.  
  40.  -- Command: save-buffer &optional BACKUP-OPTION
  41.      This function saves the contents of the current buffer in its
  42.      visited file if the buffer has been modified since it was last
  43.      visited or saved. Otherwise it does nothing.
  44.  
  45.      `save-buffer' is responsible for making backup files.  Normally,
  46.      BACKUP-OPTION is `nil', and `save-buffer' makes a backup file only
  47.      if this is the first save or if the buffer was previously
  48.      modified.  Other values for BACKUP-OPTION request the making of
  49.      backup files in other circumstances:
  50.  
  51.         * With an argument of 4 or 64, reflecting 1 or 3 `C-u''s, the
  52.           `save-buffer' function marks this version of the file to be
  53.           backed up when the buffer is next saved.
  54.  
  55.         * With an argument of 16 or 64, reflecting 2 or 3 `C-u''s, the
  56.           `save-buffer' function unconditionally backs up the previous
  57.           version of the file before saving it.
  58.  
  59.  -- Command: save-buffers-kill-emacs &optional KILL-SILENTLY-P
  60.      This function offers to save each buffer that needs to be saved,
  61.      and then kills the Emacs job.  With a non-`nil' value of the
  62.      optional KILL-SILENTLY-P argument, it unconditionally and silently
  63.      saves all the file-visiting buffers, and then kills the job.
  64.  
  65.      The `save-buffers-kill-emacs' function is defined as follows:
  66.  
  67.           (defun save-buffers-kill-emacs (&optional arg)
  68.             "Offer to save each buffer, then kill this Emacs fork..."
  69.             (interactive "P")
  70.             (save-some-buffers arg t)
  71.             (kill-emacs))
  72.  
  73.  -- Command: save-some-buffers &optional SAVE-SILENTLY-P EXITING
  74.      This command saves some modified file-visiting buffers.  Normally
  75.      it asks the user about each buffer.  If the function is called
  76.      with a non-`nil' value of the optional SAVE-SILENTLY-P argument,
  77.      this function saves all the file-visiting buffers without querying
  78.      the user.
  79.  
  80.      The optional EXITING argument, if non-`nil', requests this
  81.      function to offer also to save certain other buffers that are not
  82.      visiting files.  These are buffers that have a non-`nil' local
  83.      value of `buffer-offer-save'.  (A user who says yes to saving one
  84.      of these will be asked to specify a file name to use.)  The
  85.      `save-buffers-kill-emacs' function passes a non-`nil' value for
  86.      this argument.
  87.  
  88.  -- Variable: buffer-offer-save
  89.      When this variable is non-`nil' in a buffer, Emacs offers to save
  90.      the buffer on exit even if the buffer is not visiting a file.  The
  91.      variable is automatically local in all buffers.  Normally, Mail
  92.      mode (used for editing outgoing mail) sets this to `t'.
  93.  
  94.  -- Command: write-file FILENAME
  95.      This function writes the current buffer into file FILENAME, makes
  96.      the buffer visit that file, and marks it not modified.  The buffer
  97.      is renamed to correspond to FILENAME unless that name is already
  98.      in use.
  99.  
  100.  -- Variable: write-file-hooks
  101.      The value of this variable is a list of functions to be called
  102.      before writing out a buffer to its visited file.  If one of them
  103.      returns non-`nil', the file is considered already written and the
  104.      rest of the functions are not called, nor is the usual code for
  105.      writing the file executed.
  106.  
  107.      If the `file-precious-flag' variable is `nil', the file is moved
  108.      to the backup file before any of the hooks are called.  If none of
  109.      the hooks actually write the file, but one does return non-`nil',
  110.      the file will not exist, although the backup will.
  111.  
  112.      Here is an example showing how to add an element to
  113.      `write-file-hooks' but avoid adding it twice:
  114.  
  115.           (or (memq 'my-write-file-hook write-file-hooks)
  116.               (setq write-file-hooks
  117.                     (cons 'my-write-file-hook write-file-hooks)))
  118.  
  119.  -- Variable: file-precious-flag
  120.      If this variable is non-`nil', then `save-buffer' protects against
  121.      I/O errors while saving by renaming the original file to a
  122.      temporary name before writing the new contents of the file.  If
  123.      the new contents are successfully written, the renamed original
  124.      file is deleted. Otherwise, it is renamed back to the original
  125.      name.  This procedure prevents problems such as a lack of disk
  126.      space from resulting in an invalid file.
  127.  
  128.      Some modes set this non-`nil' locally in particular buffers.
  129.  
  130.  -- User Option: require-final-newline
  131.      This variable determines whether files may be written out that do
  132.      *not* end with a newline.  If the value of the variable is `t',
  133.      then Emacs silently puts a newline at the end of the file whenever
  134.      the buffer being saved does not already end in one.  If the value
  135.      of the variable is non-`nil', but not `t', then Emacs asks the
  136.      user whether to add a newline each time the case arises.
  137.  
  138.      If the value of the variable is `nil', then Emacs doesn't add
  139.      newlines at all.  `nil' is the default value, but a few major modes
  140.      change it to `t'.
  141.  
  142. 
  143. File: elisp,  Node: Reading from Files,  Next: Writing to Files,  Prev: Saving Buffers,  Up: Files
  144.  
  145. Reading from Files
  146. ==================
  147.  
  148.    You can copy a file directly from the disk and insert it into a
  149. buffer using the `insert-file-contents' function, or its interactive
  150. variant, `insert-file'.
  151.  
  152.  -- Command: insert-file FILENAME
  153.      This function inserts the contents of file FILENAME into the
  154.      current buffer after point, and sets the mark at the end of the
  155.      inserted text.  An error is signaled if FILENAME is not the name
  156.      of a file that can be read.  This function is for interactive use
  157.      and does little more than call `insert-file-contents'.
  158.  
  159.  -- Function: insert-file-contents FILENAME &optional VISIT
  160.      This function inserts the contents of file FILENAME into the
  161.      current buffer after point. It returns a list of the absolute file
  162.      name and the length of the data inserted.  An error is signaled if
  163.      FILENAME is not the name of a file that can be read.
  164.  
  165.      If VISIT is non-`nil', it also marks the buffer as unmodified and
  166.      sets up various fields in the buffer so that it is visiting the
  167.      file FILENAME: these include the buffer's visited file name and
  168.      its last save file modtime.  This feature is used by
  169.      `find-file-noselect' and you should probably not use it yourself.
  170.  
  171. 
  172. File: elisp,  Node: Writing to Files,  Next: File Locks,  Prev: Reading from Files,  Up: Files
  173.  
  174. Writing to Files
  175. ================
  176.  
  177.    You can write the contents of a buffer, or part of a buffer, directly
  178. to a file on disk using the `append-to-file' and `write-region'
  179. functions.  Don't use these functions to write to files that are being
  180. visited; that could cause confusion in the mechanisms for visiting.
  181.  
  182.  -- Command: append-to-file START END FILENAME
  183.      This function appends the contents of the region delimited by
  184.      START and END in the current buffer to the end of file FILENAME. 
  185.      If that file does not exist, it is created.  This function returns
  186.      `nil'.
  187.  
  188.      An error is signaled if FILENAME specifies a nonwritable file, or
  189.      a nonexistent file in a directory where files cannot be created.
  190.  
  191.  -- Command: write-region START END FILENAME &optional APPEND VISIT
  192.      This function writes the region (of the current buffer) delimited
  193.      by START and END into the file specified by FILENAME.
  194.  
  195.      If APPEND is non-`nil', then the region is appended to the
  196.      existing file contents (if any).
  197.  
  198.      If VISIT is `t', then Emacs establishes an association between the
  199.      buffer and the file: the buffer is then visiting that file. It
  200.      also sets the last file modification time for the current buffer to
  201.      FILENAME's modtime, and marks the buffer as not modified.  This
  202.      feature is used by `write-file' and you should probably not use it
  203.      yourself.
  204.  
  205.      Normally, this function displays a message `Wrote file FILENAME'
  206.      in the echo area.  If VISIT is neither `t' nor `nil', then this
  207.      message is inhibited.  This feature is useful for programs that
  208.      use files for internal purposes, files which the user does not
  209.      need to know about.
  210.  
  211. 
  212. File: elisp,  Node: File Locks,  Next: Information about Files,  Prev: Writing to Files,  Up: Files
  213.  
  214. File Locks
  215. ==========
  216.  
  217.    When two users edit the same file at the same time, they are likely
  218. to interfere with each other.  Emacs tries to prevent this situation
  219. from arising by recording a "file lock" when a file is being modified.
  220. Emacs can then detect the first attempt to modify a buffer visiting a
  221. file that is locked by another Emacs job, and ask the user what to do.
  222.  
  223.    File locks do not work properly when multiple machines can share
  224. filesystems, such as with NFS.  Perhaps a better file locking system
  225. will be implemented in the future.  When file locks do not work, it is
  226. possible for two users to make changes simultaneously, but Emacs will
  227. still be able to warn the user who saves second.  Also, the detection of
  228. modification of a buffer visiting a file changed on disk catches some
  229. cases of simultaneous editing; see *Note Modification Time::.
  230.  
  231.  -- Function: file-locked-p FILENAME
  232.      This function returns `nil' if the file FILENAME is not locked by
  233.      this Emacs process.  It returns `t' if it is locked by this Emacs,
  234.      and it returns the name of the user who has locked it if it is
  235.      locked by someone else.
  236.  
  237.           (file-locked-p "foo")
  238.                => nil
  239.  
  240.  -- Function: lock-buffer &optional FILENAME
  241.      This function locks the file FILENAME, if the current buffer is
  242.      modified.  The argument FILENAME defaults to the current buffer's
  243.      visited file.  Nothing is done if the current buffer is not
  244.      visiting a file, or is not modified.
  245.  
  246.  -- Function: unlock-buffer
  247.      This function unlocks the file being visited in the current buffer,
  248.      if the buffer is modified.  If the buffer is not modified, then
  249.      the file should not be locked, so this function does nothing.  It
  250.      also does nothing if the current buffer is not visiting a file.
  251.  
  252.  -- Function: ask-user-about-lock FILE OTHER-USER
  253.      This function is called when the user tries to modify FILE, but it
  254.      is locked by another user name OTHER-USER.  The value it returns
  255.      controls what Emacs will do with the file:
  256.  
  257.         * A value of `t' tells Emacs to grab the lock on the file.  Then
  258.           this user may edit the file and OTHER-USER loses the lock.
  259.  
  260.         * A value of `nil' tells Emacs to ignore the lock and let this
  261.           user edit the file anyway.
  262.  
  263.         * This function may instead signal a `file-locked' error, in
  264.           which case the change to the buffer which the user was about
  265.           to make does not take place.
  266.  
  267.           The error message for this error looks like this:
  268.  
  269.                error--> File is locked: FILE OTHER-USER
  270.  
  271.           where `file' is the name of the file and OTHER-USER is the
  272.           name of the user who has locked the file.
  273.  
  274.      The default definition of this function asks the user to choose
  275.      what to do.  If you wish, you can replace the `ask-user-about-lock'
  276.      function with your own version that decides in another way.  The
  277.      code for its usual definition is in `userlock.el'.
  278.  
  279. 
  280. File: elisp,  Node: Information about Files,  Next: Contents of Directories,  Prev: File Locks,  Up: Files
  281.  
  282. Information about Files
  283. =======================
  284.  
  285.    The functions described in this section are similar in as much as
  286. they all operate on strings which are interpreted as file names.  All
  287. have names that begin with the word `file'.  These functions all return
  288. information about actual files or directories, so their arguments must
  289. all exist as actual files or directories unless otherwise noted.
  290.  
  291.    Most of the file-oriented functions take a single argument,
  292. FILENAME, which must be a string.  The file name is expanded using
  293. `expand-file-name', so `~' is handled correctly, as are relative file
  294. names (including `../').  Environment variable substitutions, such as
  295. `$HOME', are not recognized by these functions.
  296.  
  297. * Menu:
  298.  
  299. * Testing Accessibility::   Is a given file readable?  Writable?
  300. * Kinds of Files::          Is it a directory?  A link?
  301. * File Attributes::         How large is it?  Any other names?  Etc.
  302.  
  303. 
  304. File: elisp,  Node: Testing Accessibility,  Next: Kinds of Files,  Prev: Information about Files,  Up: Information about Files
  305.  
  306. Testing Accessibility
  307. ---------------------
  308.  
  309.    These functions test for permission to access a file in specific
  310. ways.
  311.  
  312.  -- Function: file-exists-p FILENAME
  313.      This function returns `t' if a file named FILENAME appears to
  314.      exist.  This does not mean you can necessarily read the file, only
  315.      that you can find out its attributes.  (On Unix, this is true if
  316.      the file exists and you have execute permission on the containing
  317.      directories, regardless of the protection of the file itself.)
  318.  
  319.      If the file does not exist, or if fascist access control policies
  320.      prevent you from finding the attributes of the file, this function
  321.      returns `nil'.
  322.  
  323.  -- Function: file-readable-p FILENAME
  324.      This function returns `t' if a file named FILENAME exists and you
  325.      can read it.  It returns `nil' otherwise.
  326.  
  327.           (file-readable-p "files.texi")
  328.                => t
  329.           (file-exists-p "/usr/spool/mqueue")
  330.                => t
  331.           (file-readable-p "/usr/spool/mqueue")
  332.                => nil
  333.  
  334.  -- Function: file-writable-p FILENAME
  335.      This function returns `t' if FILENAME can be written or created by
  336.      you.  It is writable if the file exists and you can write it. It
  337.      is creatable if the file does not exist, but the specified
  338.      directory does exist and you can write in that directory. 
  339.      `file-writable-p' returns `nil' otherwise.
  340.  
  341.      In the third example below, `foo' is not writable because the
  342.      parent directory does not exist, even though the user could create
  343.      it.
  344.  
  345.           (file-writable-p "~rms/foo")
  346.                => t
  347.           (file-writable-p "/foo")
  348.                => nil
  349.           (file-writable-p "~rms/no-such-dir/foo")
  350.                => nil
  351.  
  352.  -- Function: file-newer-than-file-p FILENAME1 FILENAME2
  353.      This functions returns `t' if the file FILENAME1 is newer than
  354.      file FILENAME2.  If FILENAME1 does not exist, it returns `nil'. 
  355.      If FILENAME2 does not exist, it returns `t'.
  356.  
  357.      In the following example, assume that the file `aug-19' was
  358.      written on the 19th, and `aug-20' was written on the 20th.  The
  359.      file `no-file' doesn't exist at all.
  360.  
  361.           (file-newer-than-file-p "aug-19" "aug-20")
  362.                => nil
  363.           (file-newer-than-file-p "aug-20" "aug-19")
  364.                => t
  365.           (file-newer-than-file-p "aug-19" "no-file")
  366.                => t
  367.           (file-newer-than-file-p "no-file" "aug-19")
  368.                => nil
  369.  
  370. 
  371. File: elisp,  Node: Kinds of Files,  Next: File Attributes,  Prev: Testing Accessibility,  Up: Information about Files
  372.  
  373. Distinguishing Kinds of Files
  374. -----------------------------
  375.  
  376.    This section describes how to distinguish directories and symbolic
  377. links from ordinary files.
  378.  
  379.  -- Function: file-symlink-p FILENAME
  380.      If FILENAME is a symbolic link, the `file-symlink-p' function
  381.      returns the file name to which it is linked.  This may be the name
  382.      of a text file, a directory, or even another symbolic link, or of
  383.      no file at all.
  384.  
  385.      If FILENAME is not a symbolic link (or there is no such file),
  386.      `file-symlink-p' returns `nil'.
  387.  
  388.           (file-symlink-p "foo")
  389.                => nil
  390.           (file-symlink-p "sym-link")
  391.                => "foo"
  392.           (file-symlink-p "sym-link2")
  393.                => "sym-link"
  394.           (file-symlink-p "/bin")
  395.                => "/pub/bin"
  396.  
  397.  
  398.  -- Function: file-directory-p FILENAME
  399.      This function returns `t' if FILENAME is the name of an existing
  400.      directory, `nil' otherwise.
  401.  
  402.           (file-directory-p "~rms")
  403.                => t
  404.           (file-directory-p "~rms/lewis/files.texi")
  405.                => nil
  406.           (file-directory-p "~rms/lewis/no-such-file")
  407.                => nil
  408.           (file-directory-p "$HOME")
  409.                => nil
  410.           (file-directory-p (substitute-in-file-name "$HOME"))
  411.                => t
  412.  
  413. 
  414. File: elisp,  Node: File Attributes,  Prev: Kinds of Files,  Up: Information about Files
  415.  
  416. Other Information about Files
  417. -----------------------------
  418.  
  419.    This section describes the functions for getting detailed information
  420. about a file, other than its contents.  This information includes the
  421. mode bits that control access permission, the owner and group numbers,
  422. the number of names, the inode number, the size, and the times of access
  423. and modification.
  424.  
  425.  -- Function: file-modes FILENAME
  426.      This function returns the mode bits of FILENAME, as an integer.
  427.      The mode bits are also called the file permissions, and they
  428.      specify access control in the usual Unix fashion.  If the
  429.      low-order bit is 1, then the file is executable by all users, if
  430.      the second lowest-order bit is 1, then the file is writable by all
  431.      users, etc.
  432.  
  433.      The highest value returnable is 4095 (7777 octal), meaning that
  434.      everyone has read, write, and execute permission, that the SUID bit
  435.      is set for both others and group, and that the sticky bit is set.
  436.  
  437.           (file-modes "~/junk/diffs")
  438.                => 492               ; decimal integer
  439.           (format "%o" 492)
  440.                => 754               ; convert to octal
  441.           
  442.           (set-file-modes "~/junk/diffs" 438)
  443.                => nil
  444.           
  445.           (format "%o" 438)
  446.                => 666               ; convert to octal
  447.           
  448.           % ls -l diffs
  449.             -rw-rw-rw-  1 lewis    0    3063 Oct 30 16:00 diffs
  450.  
  451.  -- Function: file-nlinks FILENAME
  452.      This functions returns the number of names (i.e., hard links) that
  453.      file FILENAME has.  If the file does not exist, then this function
  454.      returns `nil'.  Note that symbolic links have no effect on this
  455.      function, because they are not considered to be names of the files
  456.      they link to.
  457.  
  458.           % ls -l foo*
  459.           -rw-rw-rw-  2 rms             4 Aug 19 01:27 foo
  460.           -rw-rw-rw-  2 rms             4 Aug 19 01:27 foo1
  461.           
  462.           (file-nlinks "foo")
  463.                => 2
  464.           (file-nlinks "doesnt-exist")
  465.                => nil
  466.  
  467.  -- Function: file-attributes FILENAME
  468.      This function returns a list of attributes of file FILENAME.  If
  469.      the specified file cannot be opened, it returns `nil'.
  470.  
  471.      The elements of the list, in order, are:
  472.        1. `t' for a directory, a string for a symbolic link (the name
  473.           linked to), or `nil' for a text file.
  474.  
  475.        2. The number of names the file has.  Alternate names, also
  476.           known as hard links, can be created with `add-name-to-file'
  477.           (*note Changing File Attributes::.).
  478.  
  479.        3. The file's UID.
  480.  
  481.        4. The file's GID.
  482.  
  483.        5. The time of last access, as a list of two integers. The first
  484.           integer has the high-order 16 bits of time, the second has
  485.           the low 16 bits.
  486.  
  487.        6. The time of last modification as a list of two integers (as
  488.           above).
  489.  
  490.        7. The time of last status change as a list of two integers (as
  491.           above).
  492.  
  493.        8. The size of the file in bytes.
  494.  
  495.        9. The file's modes, as a string of ten letters or dashes as in
  496.           `ls -l'.
  497.  
  498.       10. `t' if the file's GID would change if file were deleted and
  499.           recreated; `nil' otherwise.
  500.  
  501.       11. The file's inode number.
  502.  
  503.      For example, here are the file attributes for `files.texi':
  504.  
  505.           (file-attributes "files.texi")
  506.                =>  (nil
  507.                     1
  508.                     2235
  509.                     75
  510.                     (8489 20284)
  511.                     (8489 20284)
  512.                     (8489 20285)
  513.                     14906
  514.                     "-rw-rw-rw-"
  515.                     nil
  516.                     20920)
  517.  
  518.      and here is how the result is interpreted:
  519.  
  520.     `nil'
  521.           is neither a directory nor a symbolic link.
  522.  
  523.     `1'
  524.           has only one name (the name `files.texi' in the current
  525.           default directory).
  526.  
  527.     `2235'
  528.           is owned by the user with UID 2235.
  529.  
  530.     `75'
  531.           is in the group with GID 75.
  532.  
  533.     `(8489 20284)'
  534.           was last accessed on Aug 19 00:09.  Unfortunately, you cannot
  535.           convert this number into a time string in Emacs.
  536.  
  537.     `(8489 20284)'
  538.           was last accessed on Aug 19 00:09.
  539.  
  540.     `(8489 20285)'
  541.           last had its inode changed on Aug 19 00:09.
  542.  
  543.     `14906'
  544.           is 14906 characters long.
  545.  
  546.     `"-rw-rw-rw-"'
  547.           has a mode of read and write access for the owner, group, and
  548.           world.
  549.  
  550.     `nil'
  551.           would retain the same GID if it were recreated.
  552.  
  553.     `20920'
  554.           has an inode number of 20920.
  555.  
  556. 
  557. File: elisp,  Node: Contents of Directories,  Next: Changing File Attributes,  Prev: Information about Files,  Up: Files
  558.  
  559. Contents of Directories
  560. =======================
  561.  
  562.    A directory is a kind of file that contains other files entered under
  563. various names.  Directories are a feature of the file system.
  564.  
  565.    Emacs can list the names of the files in a directory as a Lisp list,
  566. or display the names in a buffer using the `ls' shell command.  In the
  567. latter case, it can optionally display information about each file,
  568. depending on the value of switches passed to the `ls' command.
  569.  
  570.  -- Function: directory-files DIRECTORY &optional FULL-NAME MATCH-REGEXP
  571.      This function returns a list of the names of the files in the
  572.      directory DIRECTORY.
  573.  
  574.      If FULL-NAME is non-`nil', the function returns the files'
  575.      absolute file names.  Otherwise, it returns just the names
  576.      relative to the specified directory.
  577.  
  578.      If MATCH-REGEXP is non-`nil', function returns only those file
  579.      names that contain that regular expression--the other file names
  580.      are discarded from the list.
  581.  
  582.           (directory-files "~lewis")
  583.                => ("#foo#" "#foo.el#" "." ".."
  584.                    "dired-mods.el" "files.texi" "files.texi.~1~")
  585.  
  586.      An error is signaled if DIRECTORY is not the name of a directory
  587.      that can be read.
  588.  
  589.  -- Function: file-name-all-versions FILE DIRNAME
  590.      This function returns a list of all versions of the file named
  591.      FILE in directory DIRNAME.
  592.  
  593.  -- Command: list-directory FILESPEC &optional VERBOSE
  594.      This command displays a list of files in or matching FILESPEC. It
  595.      calls the shell command `ls', passing it options under the control
  596.      of VERBOSE.
  597.  
  598.      The argument FILESPEC may be either a directory name or a file
  599.      name containing optional wildcards.  Wildcards are processed by the
  600.      shell.
  601.  
  602.      The options passed to `ls' are the value of
  603.      `list-directory-verbose-switches' if VERBOSE is non-`nil';
  604.      `list-directory-brief-switches' otherwise. Interactively, the raw
  605.      prefix argument is used for VERBOSE.
  606.  
  607.  -- Variable: list-directory-brief-switches
  608.      This variable contains switches for `list-directory' to pass to
  609.      `ls' for a short or "brief" listing.  The default value is `"-CF"'.
  610.  
  611.  -- Variable: list-directory-verbose-switches
  612.      This variable contains switches for `list-directory' to pass to
  613.      `ls' for a verbose or "long" listing.  The default value is `"-l"'.
  614.  
  615. 
  616. File: elisp,  Node: Changing File Attributes,  Next: File Names,  Prev: Contents of Directories,  Up: Files
  617.  
  618. Changing File Names and Attributes
  619. ==================================
  620.  
  621.    The functions in this section rename, copy, delete, link, and set the
  622. modes of files.
  623.  
  624.    In the functions that have an argument NEWNAME, if a file by the
  625. name of NEWNAME already exists, the actions taken depend on the value
  626. of the argument OK-IF-ALREADY-EXISTS:
  627.  
  628.    * A `file-already-exists' error is signaled if OK-IF-ALREADY-EXISTS
  629.      is `nil'.
  630.  
  631.    * Confirmation is requested if OK-IF-ALREADY-EXISTS is a number.
  632.  
  633.    * No confirmation is requested if OK-IF-ALREADY-EXISTS is any other
  634.      value, in which case the old file is removed.
  635.  
  636.  -- Function: add-name-to-file OLDNAME NEWNAME &optional
  637.           OK-IF-ALREADY-EXISTS
  638.      This function gives the file named OLDNAME the additional name
  639.      NEWNAME.  This means that NEWNAME will be a new "hard link" to
  640.      OLDNAME.
  641.  
  642.      In the first part of the following example, we list two files,
  643.      `foo' and `foo3'.
  644.  
  645.           % ls -l fo*
  646.           -rw-rw-rw-  1 rms            29 Aug 18 20:32 foo
  647.           -rw-rw-rw-  1 rms            24 Aug 18 20:31 foo3
  648.  
  649.      Then we evaluate the form `(add-name-to-file "~/lewis/foo"
  650.      "~/lewis/foo2")'.  Again we list the files.  This shows two names,
  651.      `foo' and `foo2'.
  652.  
  653.           (add-name-to-file "~/lewis/foo1" "~/lewis/foo2")
  654.                => nil
  655.           
  656.           % ls -l fo*
  657.           -rw-rw-rw-  2 rms            29 Aug 18 20:32 foo
  658.           -rw-rw-rw-  2 rms            29 Aug 18 20:32 foo2
  659.           -rw-rw-rw-  1 rms            24 Aug 18 20:31 foo3
  660.  
  661.      Finally, we evaluate `(add-name-to-file "~/lewis/foo"
  662.      "~/lewis/foo3" t)', and list the files again.  Now there are three
  663.      names for one file: `foo', `foo2', and `foo3'.  The old contents
  664.      of `foo3' are lost.
  665.  
  666.           (add-name-to-file "~/lewis/foo1" "~/lewis/foo3")
  667.                => nil
  668.           
  669.           % ls -l fo*
  670.           -rw-rw-rw-  3 rms            29 Aug 18 20:32 foo
  671.           -rw-rw-rw-  3 rms            29 Aug 18 20:32 foo2
  672.           -rw-rw-rw-  3 rms            29 Aug 18 20:32 foo3
  673.  
  674.      This function is meaningless on VMS, where multiple names for one
  675.      file are not allowed.
  676.  
  677.      See also `file-nlinks' in *Note Information about Files::.
  678.  
  679.  -- Command: rename-file FILENAME NEWNAME &optional OK-IF-ALREADY-EXISTS
  680.      This command renames the file FILENAME as NEWNAME.
  681.  
  682.      If FILENAME has additional names aside from FILENAME, it continues
  683.      to have those names.  In fact, adding the name NEWNAME with
  684.      `add-name-to-file' and then deleting FILENAME has the same effect
  685.      as renaming, aside from momentary intermediate states.
  686.  
  687.      In an interactive call, this function prompts for FILENAME and
  688.      NEWNAME in the minibuffer; also, it requests confirmation if
  689.      NEWNAME already exists.
  690.  
  691.  -- Command: copy-file OLDNAME NEWNAME &optional OK-IF-EXISTS TIME
  692.      This command copies the file OLDNAME to NEWNAME.  An error is
  693.      signaled if OLDNAME does not exist.
  694.  
  695.      If TIME is non-`nil', then this functions gives the new file the
  696.      same last-modified time that the old one has.  (This works on only
  697.      some operating systems.)
  698.  
  699.      In an interactive call, this function prompts for FILENAME and
  700.      NEWNAME in the minibuffer; also, it requests confirmation if
  701.      NEWNAME already exists.
  702.  
  703.  -- Command: delete-file FILENAME
  704.      This command deletes the file FILENAME, like the shell command `rm
  705.      FILENAME'.  If the file has multiple names, it continues to exist
  706.      under the other names.
  707.  
  708.      A suitable kind of `file-error' error is signaled if the file does
  709.      not exist, or is not deletable.  (In Unix, a file is deletable if
  710.      its directory is writable.)
  711.  
  712.  -- Command: make-symbolic-link FILENAME NEWNAME &optional OK-IF-EXISTS
  713.      This command makes a symbolic link to FILENAME, named NEWNAME. 
  714.      This is like the shell command `ln -s FILENAME NEWNAME'.
  715.  
  716.      In an interactive call, FILENAME and NEWNAME are read in the
  717.      minibuffer, and OK-IF-EXISTS is set to the numeric prefix argument.
  718.  
  719.  -- Function: set-file-modes FILENAME MODE
  720.      This function sets mode bits of FILENAME to MODE (which must be a
  721.      integer).  Only the 12 low bits of MODE are used.
  722.  
  723. 
  724. File: elisp,  Node: File Names,  Prev: Changing File Attributes,  Up: Files
  725.  
  726. File Names
  727. ==========
  728.  
  729.    Files are generally referred to by their names, in Emacs as
  730. elsewhere. File names in Emacs are represented as strings.  The
  731. functions that operate on a file all expect a file name argument.
  732.  
  733.    In addition to operating on files themselves, Emacs Lisp programs
  734. often need to operate on the names; i.e., to take them apart and to use
  735. part of a name to construct related file names.  This section describes
  736. how to manipulate file names.
  737.  
  738.    The functions in this section do not actually access files, so they
  739. can operate on file names that do not refer to an existing file or
  740. directory.
  741.  
  742.    On VMS, all these functions understand both VMS file name syntax and
  743. Unix syntax.  This is so that all the standard Lisp libraries can
  744. specify file names in Unix syntax and work properly on VMS without
  745. change.
  746.  
  747. * Menu:
  748.  
  749. * File Name Components::  The directory part of a file name, and the rest.
  750. * Directory Names::       A directory's name as a directory
  751.                             is different from its name as a file.
  752. * Relative File Names::   Some file names are relative to a current directory.
  753. * File Name Expansion::   Converting relative file names to absolute ones.
  754. * Unique File Names::     Generating names for temporary files.
  755. * File Name Completion::  Finding the completions for a given file name.
  756.  
  757. 
  758. File: elisp,  Node: File Name Components,  Next: Directory Names,  Up: File Names
  759.  
  760. File Name Components
  761. --------------------
  762.  
  763.    The operating system groups files into directories.  To specify a
  764. file, you must specify the directory, and the file's name in that
  765. directory.  Therefore, a file name in Emacs is considered to have two
  766. main parts: the "directory name" part, and the "nondirectory" part (or
  767. "file name within the directory").  Either part may be empty. 
  768. Concatenating these two parts reproduces the original file name.
  769.  
  770.    On Unix, the directory part is everything up to and including the
  771. last slash; the nondirectory part is the rest.  The rules in VMS syntax
  772. are complicated.
  773.  
  774.    For some purposes, the nondirectory part is further subdivided into
  775. the name and the version number.  On Unix, only backup files have
  776. version numbers in their names; on VMS, every file has a version number,
  777. but most of the time the file name actually used in Emacs omits the
  778. version number.  Version numbers are found mostly in directory lists.
  779.  
  780.  -- Function: file-name-directory FILENAME
  781.      This function returns the directory part of FILENAME (or `nil' if
  782.      FILENAME does not include a directory part).  On Unix, the
  783.      function returns a string ending in a slash.  On VMS, it returns a
  784.      string ending in one of the three characters `:', `]', or `>'.
  785.  
  786.           (file-name-directory "lewis/foo")     ; Unix example
  787.                => "lewis/"
  788.           (file-name-directory "foo")           ; Unix example
  789.                => nil
  790.           (file-name-directory "[X]FOO.TMP")    ; VMS example
  791.                => "[X]"
  792.  
  793.  -- Function: file-name-nondirectory FILENAME
  794.      This function returns the nondirectory part of FILENAME.
  795.  
  796.           (file-name-nondirectory "lewis/foo")
  797.                => "foo"
  798.           (file-name-nondirectory "foo")
  799.                => "foo"
  800.           ;; The following example is accurate only on VMS.
  801.           (file-name-nondirectory "[X]FOO.TMP")
  802.                => "FOO.TMP"
  803.  
  804.  -- Function: file-name-sans-versions FILENAME
  805.      This function returns FILENAME without any file version numbers,
  806.      backup version numbers, or trailing tildes.
  807.  
  808.           (file-name-sans-versions "~rms/foo.~1~")
  809.                => "~rms/foo"
  810.           (file-name-sans-versions "~rms/foo~")
  811.                => "~rms/foo"
  812.           (file-name-sans-versions "~rms/foo")
  813.                => "~rms/foo"
  814.           ;; The following example applies to VMS only.
  815.           (file-name-sans-versions "foo;23")
  816.                => "foo"
  817.  
  818. 
  819. File: elisp,  Node: Directory Names,  Next: Relative File Names,  Prev: File Name Components,  Up: File Names
  820.  
  821. Directory Names
  822. ---------------
  823.  
  824.    A "directory name" is the name of a directory.  A directory is a
  825. kind of file, and it has a file name, which is related to the directory
  826. name but not identical to it.  (This is not quite the same as the usual
  827. Unix terminology.)  These two different names for the same entity are
  828. related by a syntactic transformation.  On Unix, this is simple: a
  829. directory name ends in a slash, whereas the directory's name as a file
  830. lacks that slash.  On VMS, the relationship is more complicated.
  831.  
  832.    The difference between a directory name and its name as a file is
  833. subtle but crucial.  When an Emacs variable or function argument is
  834. described as being a directory name, a file name of a directory is not
  835. acceptable.
  836.  
  837.    All of these functions take a single argument, FILENAME, which must
  838. be a string.  Environment variable substitutions such as `$HOME', and
  839. the symbols `~', and `..', are *not* expanded.  Use `expand-file-name'
  840. or `substitute-in-file-name' for that (*note File Name Expansion::.).
  841.  
  842.  -- Function: file-name-as-directory FILENAME
  843.      This function returns a string representing FILENAME in a form
  844.      that the operating system will interpret as the name of a
  845.      directory.  In Unix, this means that a slash is appended to the
  846.      string.  On VMS, the function converts a string of the form
  847.      `[X]Y.DIR.1' to the form `[X.Y]'.
  848.  
  849.           (file-name-as-directory "~rms/lewis")
  850.                => "~rms/lewis/"
  851.  
  852.  -- Function: directory-file-name DIRNAME
  853.      This function returns a string representing DIRNAME in a form that
  854.      the operating system will interpret as the name of a file.  On
  855.      Unix, this means that a final slash is removed from the string. 
  856.      On VMS, the function converts a string of the form `[X.Y]' to
  857.      `[X]Y.DIR.1'.
  858.  
  859.           (directory-file-name "~lewis/")
  860.                => "~lewis"
  861.  
  862. 
  863. File: elisp,  Node: Relative File Names,  Next: File Name Expansion,  Prev: Directory Names,  Up: File Names
  864.  
  865. Absolute and Relative File Names
  866. --------------------------------
  867.  
  868.    All the directories in the file system form a tree starting at the
  869. root directory.  A file name can specify all the directory names
  870. starting from the root of the tree; then it is called an "absolute"
  871. file name.  Or it can specify the position of the file in the tree
  872. relative to a default directory; then it is called an "relative" file
  873. name.  On Unix, an absolute file name starts with a slash or a tilde
  874. (`~'), and a relative one does not.  The rules on VMS are complicated.
  875.  
  876.  -- Function: file-name-absolute-p FILENAME
  877.      This function returns `t' if file FILENAME is an absolute file
  878.      name, `nil' otherwise.  On VMS, this function understands both
  879.      Unix syntax and VMS syntax.
  880.  
  881.           (file-name-absolute-p "~rms/foo")
  882.                => t
  883.           (file-name-absolute-p "rms/foo")
  884.                => nil
  885.           (file-name-absolute-p "$HOME")
  886.                => nil
  887.           (file-name-absolute-p "/user/rms/foo")
  888.                => t
  889.  
  890. 
  891. File: elisp,  Node: File Name Expansion,  Next: Unique File Names,  Prev: Relative File Names,  Up: File Names
  892.  
  893. Functions that Expand Filenames
  894. -------------------------------
  895.  
  896.    "Expansion" of a file name means converting a relative file name to
  897. an absolute one.  Since this is done relative to a default directory,
  898. you must specify the default directory name as well as the file name to
  899. be expanded.  Expansion also canonicalizes file names by eliminating
  900. redundancies such as `./' and `NAME/../'.
  901.  
  902.  -- Function: expand-file-name FILENAME &optional DIRECTORY
  903.      This function converts FILENAME to an absolute file name.  If
  904.      DIRECTORY is supplied, it is the directory to start with if
  905.      FILENAME is relative.  Otherwise, the current buffer's value of
  906.      `default-directory' is used.  For example:
  907.  
  908.           (expand-file-name "foo")
  909.                => "/xcssun/users/rms/lewis/foo"
  910.           (expand-file-name "../foo")
  911.                => "/xcssun/users/rms/foo"
  912.           (expand-file-name "foo" "/usr/spool")
  913.                => "/usr/spool/foo"
  914.           (expand-file-name "$HOME/foo")
  915.                => "/xcssun/users/rms/lewis/$HOME/foo"
  916.  
  917.      Filenames containing `.' or `..' are simplified to their canonical
  918.      form:
  919.  
  920.           (expand-file-name "bar/../foo")
  921.                => "/xcssun/users/rms/lewis/foo"
  922.  
  923.      `~/' is expanded into the user's home directory.  A `/' or `~'
  924.      following a `/' is taken to be the start of an absolute file name
  925.      that overrides what precedes it, so everything before that `/' or
  926.      `~' is deleted.  For example:
  927.  
  928.           (expand-file-name "/a1/gnu//usr/local/lib/emacs/etc/MACHINES")
  929.                => "/usr/local/lib/emacs/etc/MACHINES"
  930.           (expand-file-name "/a1/gnu/~/foo")
  931.                => "/xcssun/users/rms/foo"
  932.  
  933.      In both cases, `/a1/gnu/' has been discarded because an absolute
  934.      file name follows it.
  935.  
  936.      Note that `expand-file-name' does *not* expand environment
  937.      variables; that is done only by `substitute-in-file-name'.
  938.  
  939.  -- Variable: default-directory
  940.      The value of this buffer-local variable is the default directory
  941.      for the current buffer.  It is local in every buffer.
  942.      `expand-file-name' uses the default directory when its second
  943.      argument is `nil'.
  944.  
  945.      On Unix systems, the value is always a string ending with a slash.
  946.  
  947.           default-directory
  948.                => "/user/lewis/manual/"
  949.  
  950.  -- Function: substitute-in-file-name FILENAME
  951.      This function replaces environment variables names in FILENAME
  952.      with the values to which they are set by the operating system.
  953.      Following standard Unix shell syntax, `$' is the prefix to
  954.      substitute an environment variable value.
  955.  
  956.      The environment variable name is the series of alphanumeric
  957.      characters (including underscores) that follow the `$'.  If the
  958.      character following the `$' is a `{', then the variable name is
  959.      everything up to the matching `}'.
  960.  
  961.      Here we assume that the environment variable `HOME', which holds
  962.      the user's home directory name, has the value `/xcssun/users/rms'.
  963.  
  964.           (substitute-in-file-name "$HOME/foo")
  965.                => "/xcssun/users/rms/foo"
  966.  
  967.      If a `~' or a `/' appears following a `/', after substitution,
  968.      everything before the following `/' is discarded:
  969.  
  970.           (substitute-in-file-name "bar/~/foo")
  971.                => "~/foo"
  972.           (substitute-in-file-name "/usr/local/$HOME/foo")
  973.                => "/xcssun/users/rms/foo"
  974.  
  975.      On VMS, `$' substitution is not done, so this function does nothing
  976.      on VMS except discard superfluous initial components as shown
  977.      above.
  978.  
  979. 
  980. File: elisp,  Node: Unique File Names,  Next: File Name Completion,  Prev: File Name Expansion,  Up: File Names
  981.  
  982. Generating Unique File Names
  983. ----------------------------
  984.  
  985.    Some programs need to write temporary files.  Here is the usual way
  986. to construct a name for such a file:
  987.  
  988.      (concat "/tmp/" (make-temp-name NAME-OF-APPLICATION))
  989.  
  990. The directory `/tmp/' is chosen because that is the standard place on
  991. Unix for temporary files.  The task of `make-temp-name' is to prevent
  992. two different users or two different jobs from trying to use the same
  993. name.
  994.  
  995.  -- Function: make-temp-name STRING
  996.      This function generates string that can be used as a unique name.
  997.      The name will start with the prefix STRING, and finish with a
  998.      number that is different in each Emacs job.
  999.  
  1000.           (make-temp-name "foo")
  1001.                => "foo021304"
  1002.           (make-temp-name "foo")
  1003.                => "foo021304"
  1004.  
  1005.      To prevent conflicts among different application libraries run in
  1006.      the same Emacs, each application should have its own STRING.  The
  1007.      number added to the end of the name distinguishes between the same
  1008.      application running in different Emacses.
  1009.  
  1010. 
  1011. File: elisp,  Node: File Name Completion,  Prev: Unique File Names,  Up: File Names
  1012.  
  1013. File Name Completion
  1014. --------------------
  1015.  
  1016.    This section describes low-level subroutines for completing a file
  1017. name.  For other completion functions, see *Note Completion::.
  1018.  
  1019.  -- Function: file-name-all-completions PARTIAL-FILENAME DIRECTORY
  1020.      This function returns a list of all possible completions for a file
  1021.      whose name starts with PARTIAL-FILENAME in directory DIRECTORY. 
  1022.      The order of the completions is the order of the files in the
  1023.      directory, which is unpredictable and conveys no useful
  1024.      information.
  1025.  
  1026.      The argument PARTIAL-FILENAME must be a file name containing no
  1027.      directory part and no slash.  The current buffer's default
  1028.      directory is prepended to DIRECTORY, if DIRECTORY is not an
  1029.      absolute file name.
  1030.  
  1031.      In the following example, suppose that the current default
  1032.      directory, `~rms/lewis', has five files whose names begin with `f':
  1033.      `foo', `file~', `file.c', `file.c.~1~', and `file.c.~2~'.
  1034.  
  1035.           (file-name-all-completions "f" "")
  1036.                => ("foo" "file~" "file.c.~2~" "file.c.~1~" "file.c")
  1037.           
  1038.           (file-name-all-completions "fo" "")
  1039.                => ("foo")
  1040.  
  1041.  -- Function: file-name-completion FILENAME DIRECTORY
  1042.      This function completes the file name FILENAME in directory
  1043.      DIRECTORY.  It returns the longest prefix common to all file names
  1044.      in directory DIRECTORY that start with FILENAME.
  1045.  
  1046.      If only one match exists and FILENAME matches it exactly, the
  1047.      function returns `t'.  The function returns `nil' if directory
  1048.      DIRECTORY contains no name starting with FILENAME.
  1049.  
  1050.      In the following example, suppose that the current default
  1051.      directory has five files whose names begin with `f': `foo',
  1052.      `file~', `file.c', `file.c.~1~', and `file.c.~2~'.
  1053.  
  1054.           (file-name-completion "fi" "")
  1055.                => "file"
  1056.           
  1057.           (file-name-completion "file.c.~1" "")
  1058.                => "file.c.~1~"
  1059.           
  1060.           (file-name-completion "file.c.~1~" "")
  1061.                => t
  1062.           
  1063.           (file-name-completion "file.c.~3" "")
  1064.                => nil
  1065.  
  1066.  -- User Option: completion-ignored-extensions
  1067.      `file-name-completion' usually ignores file names that end in any
  1068.      string in this list.  It does not ignore them when all the possible
  1069.      completions end in one of these suffixes or when a buffer showing
  1070.      all possible completions is displayed.
  1071.  
  1072.      A typical value might look like this:
  1073.  
  1074.           completion-ignored-extensions
  1075.                => (".o" ".elc" "~" ".dvi")
  1076.  
  1077. 
  1078. File: elisp,  Node: Backups and Auto-Saving,  Next: Buffers,  Prev: Files,  Up: Top
  1079.  
  1080. Backups and Auto-Saving
  1081. ***********************
  1082.  
  1083.    Backup files and auto-save files are two methods by which Emacs tries
  1084. to protect the user from the consequences of crashes or of the user's
  1085. own errors.  Auto-saving preserves the text from earlier in the current
  1086. editing session; backup files preserve file contents prior to the
  1087. current session.
  1088.  
  1089. * Menu:
  1090.  
  1091. * Backup Files::   How backup files are made; how their names are chosen.
  1092. * Auto-Saving::    How auto-save files are made; how their names are chosen.
  1093. * Reverting::      `revert-buffer', and how to customize what it does.
  1094.  
  1095. 
  1096. File: elisp,  Node: Backup Files,  Next: Auto-Saving,  Prev: Backups and Auto-Saving,  Up: Backups and Auto-Saving
  1097.  
  1098. Backup Files
  1099. ============
  1100.  
  1101.    A "backup file" is a copy of the old contents of a file you are
  1102. editing.  Emacs makes a backup file the first time you save a buffer
  1103. into its visited file.  Normally, this means that the backup file
  1104. contains the contents of the file as it was before the current editing
  1105. session.  The contents of the backup file normally remain unchanged once
  1106. it exists.
  1107.  
  1108.    Backups are usually made by renaming the visited file to a new name.
  1109. Optionally, you can specify that backup files should be made by copying
  1110. the visited file.  This choice makes a difference for files with
  1111. multiple names; it also can affect whether the edited file remains owned
  1112. by the original owner or becomes owned by the user editing it.
  1113.  
  1114.    By default, Emacs makes a single backup file for each file edited.
  1115. You can alternatively request numbered backups; then each new backup
  1116. file gets a new name.  You can delete old numbered backups when you
  1117. don't want them any more, or Emacs can delete them automatically.
  1118.  
  1119. * Menu:
  1120.  
  1121. * Making Backups::     How Emacs makes backup files, and when.
  1122. * Rename or Copy::     Two alternatives: renaming the old file or copying it.
  1123. * Numbered Backups::   Keeping multiple backups for each source file.
  1124. * Backup Names::       How backup file names are computed; customization.
  1125.  
  1126. 
  1127. File: elisp,  Node: Making Backups,  Next: Rename or Copy,  Prev: Backup Files,  Up: Backup Files
  1128.  
  1129. Making Backup Files
  1130. -------------------
  1131.  
  1132.  -- Function: backup-buffer
  1133.      This function makes a backup of the file visited by the current
  1134.      buffer, if appropriate.  It is called by `save-buffer' before
  1135.      saving the buffer the first time.
  1136.  
  1137.  -- Variable: buffer-backed-up
  1138.      This buffer-local variable indicates whether this buffer's file has
  1139.      been backed up on account of this buffer.  If it is non-`nil', then
  1140.      the backup file has been written.  Otherwise, the file should be
  1141.      backed up when it is next saved (if backup files are enabled).
  1142.  
  1143.  -- Variable: make-backup-files
  1144.      This variable determines whether or not backup files will be
  1145.      created. If it is non-`nil', then Emacs will create a backup of
  1146.      each file when it is saved for the first time.
  1147.  
  1148.      The following example shows how to change the `make-backup-files'
  1149.      variable only in the `RMAIL' buffer and not elsewhere.  Setting it
  1150.      `nil' stops Emacs from making backups of the `RMAIL' file, which
  1151.      may save disk space.  (You would put this code in your `.emacs'
  1152.      file.)
  1153.  
  1154.           (setq rmail-mode-hook
  1155.                 (function (lambda ()
  1156.                             (make-local-variable 'make-backup-files)
  1157.                             (setq make-backup-files nil)))
  1158.  
  1159. 
  1160. File: elisp,  Node: Rename or Copy,  Next: Numbered Backups,  Prev: Making Backups,  Up: Backup Files
  1161.  
  1162. Backup by Renaming or by Copying?
  1163. ---------------------------------
  1164.  
  1165.    There are two ways that Emacs can make a backup file:
  1166.  
  1167.    * Emacs can rename the original file so that it becomes a backup
  1168.      file, and then write the buffer being saved into a new file.  In
  1169.      this case, any other names (i.e., hard links) of the original file
  1170.      will now refer to the backup file.  The new file will be owned by
  1171.      the user doing the editing, and its group will be the default for
  1172.      the user or the directory.
  1173.  
  1174.    * Emacs can copy the original file into a backup file, and then
  1175.      overwrite the original file with new contents.  In this case, any
  1176.      other names (i.e., hard links) of the original file will still
  1177.      refer to the current version of the file.  The file's owner and
  1178.      group will be unchanged.
  1179.  
  1180.    The first method, renaming, is the default.
  1181.  
  1182.    The variable `backup-by-copying', if non-`nil', says to use the
  1183. second method, which is to copy the original file and overwrite it with
  1184. the new buffer contents.  The variable `file-precious-flag', if
  1185. non-`nil', also has this effect (as a sideline of its main
  1186. significance).  *Note Saving Buffers::.
  1187.  
  1188.    The variables `backup-by-copying-when-linked' and
  1189. `backup-by-copying-when-mismatch', if non-`nil', cause the second
  1190. method to be used in certain special cases.  They have no effect on the
  1191. treatment of files that don't fall into the special cases.
  1192.  
  1193.  -- Variable: backup-by-copying
  1194.      This variable controls whether to make backup files by copying. 
  1195.      If it is non-`nil', then Emacs always copies the current contents
  1196.      of the file into the backup file before writing the buffer to be
  1197.      saved to the file.  (In many circumstances, this has the same
  1198.      effect as `file-precious-flag'.)
  1199.  
  1200.  -- Variable: backup-by-copying-when-linked
  1201.      This variable controls whether to make backups by copying for files
  1202.      with multiple names (hard links).  If it is non-`nil', then Emacs
  1203.      will use copying to create backups for those files.
  1204.  
  1205.      This variable is significant only if `backup-by-copying' is `nil',
  1206.      since copying is always used when that variable is non-`nil'.
  1207.  
  1208.  -- Variable: backup-by-copying-when-mismatch
  1209.      This variable controls whether to make backups by copying when
  1210.      renaming would cause either the owner or the group of the file to
  1211.      change.  If it is non-`nil' then Emacs will create backups by
  1212.      copying in such cases.
  1213.  
  1214.      The value has no effect when renaming would not result in changing
  1215.      the owner or group of the file; that is, for files which are owned
  1216.      by the user and whose group matches the default for a new file
  1217.      created there by the user.
  1218.  
  1219.      This variable is significant only if `backup-by-copying' is `nil',
  1220.      since copying is always used when that variable is non-`nil'.
  1221.  
  1222.