$buffer-backup - Buffer backup file name
$buffer-backup FileName
$buffer-backup is automatically set to the file name the current buffer's file would be backed up to if required. If the current buffer has no file name the variable will be set to "".
The value depends on whether DOS compliant file names are being used (see $system(5)), whether multiple backups are being kept (see $kept-versions(5)) and the setting of the environment variables $MEBACKUPPATH and $MEBACKUPSUB. The variable does not take into consideration the current setting of the buffer's backup(2m) mode which determine whether a backup will be made.
The environment variable $MEBACKUPPATH can be used to change the location of the backup files, it can also be used to prepend the backup filename with a string. $MEBACKUPPATH can specify an absolute path (e.g. "c:/temp/mebackup/") or a relative path (e.g. "mebackup/" which will move all backup files into a sub-directory automatically in the files directory).
The trailing '/' is important as the file name is simple appended, i.e. is creating a backup for "c:/foo/bar.txt" and $MEBACKUPPATH is set the "backup" the backup file name will be "c:/foo/backupbar.txt".
The environment variable $MEBACKUPSUB can be used to substitute strings within the backup filename for another. The format of the value is a list of sed(1) string substitutions, i.e.
$MEBACKUPSUB="s/from1/to1/ s/from2/to2/ s/fr..."
The 3 divide characters do not have to be '/'s, they can be any character as long as they are the same, e.g. "sXfrom1Xto1X". When define MicroEmacs performs a simple search for string "from1" (i.e. no regex support) and replaces any match with the string "to1" etc.
The following example compares the differences between the current version and the bucked up version using the diff(3) macro. The diff-changes macro is defined in tools.emf.
define-macro diff-changes !if &seq $buffer-fname "" ml-write "[Current buffer has no file name]" !abort !endif !if &bmod "edit" !if &iseq @mc1 "Save buffer first [y/n]? " "nNyY" "y" save-buffer !endif !endif ; get the real file name - this only has effect on unix, copes with symbolic links set-variable #l0 &stat "a" $buffer-fname ; get the backup name set-variable #l1 $buffer-backup diff #l1 #l0 !emacro
The variable $buffer-backup can not be set, any attempt to set it will result in an error.
On Windows and DOS platforms if the $MEBACKUPPATH and $MEBACKUPSUB variables are used all remaining ':' characters are changed to '/'s as these are illegal in the middle of a filename.
(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12