# HG changeset patch # User Chong Yidong # Date 1295058739 18000 # Node ID 704fa1a3d5b48d4f6cfe5cf14008e00f4b1af5d3 # Parent d67e8472ae651ce05a28540fdc84d6d927b6e9a7 Make last-resort backup file in .emacs.d (Bug#6953). * lisp/files.el (backup-buffer): Make last-resort backup file in .emacs.d. * lisp/subr.el (locate-user-emacs-file): If .emacs.d does not exist, make it with permission 700. * doc/emacs/files.texi (Backup Names): Document the new location of the last-resort backup file. diff -r d67e8472ae65 -r 704fa1a3d5b4 doc/emacs/ChangeLog --- a/doc/emacs/ChangeLog Fri Jan 14 13:08:53 2011 +0900 +++ b/doc/emacs/ChangeLog Fri Jan 14 21:32:19 2011 -0500 @@ -1,3 +1,8 @@ +2011-01-15 Chong Yidong + + * files.texi (Backup Names): Document the new location of the + last-resort backup file. + 2011-01-08 Chong Yidong * files.texi (File Aliases): Move directory-abbrev-alist doc from Lisp diff -r d67e8472ae65 -r 704fa1a3d5b4 doc/emacs/files.texi --- a/doc/emacs/files.texi Fri Jan 14 13:08:53 2011 +0900 +++ b/doc/emacs/files.texi Fri Jan 14 21:32:19 2011 -0500 @@ -566,10 +566,10 @@ appending @samp{~} to the file name being edited; thus, the backup file for @file{eval.c} would be @file{eval.c~}. - If access control stops Emacs from writing backup files under the usual -names, it writes the backup file as @file{%backup%~} in your home -directory. Only one such file can exist, so only the most recently -made such backup is available. + If access control stops Emacs from writing backup files under the +usual names, it writes the backup file as @file{~/.emacs.d/%backup%~}. +Only one such file can exist, so only the most recently made such +backup is available. Emacs can also make @dfn{numbered backup files}. Numbered backup file names contain @samp{.~}, the number, and another @samp{~} after diff -r d67e8472ae65 -r 704fa1a3d5b4 etc/NEWS --- a/etc/NEWS Fri Jan 14 13:08:53 2011 +0900 +++ b/etc/NEWS Fri Jan 14 21:32:19 2011 -0500 @@ -26,6 +26,10 @@ * Changes in Emacs 23.3 ++++ +** The last-resort backup file `%backup%~' is now written to +`user-emacs-directory', instead of the user's home directory. + * Editing Changes in Emacs 23.3 diff -r d67e8472ae65 -r 704fa1a3d5b4 lisp/ChangeLog --- a/lisp/ChangeLog Fri Jan 14 13:08:53 2011 +0900 +++ b/lisp/ChangeLog Fri Jan 14 21:32:19 2011 -0500 @@ -1,3 +1,11 @@ +2011-01-15 Mark Diekhans + + * files.el (backup-buffer): Make last-resort backup file in + .emacs.d (Bug#6953). + + * subr.el (locate-user-emacs-file): If .emacs.d does not exist, + make it with permission 700. + 2011-01-14 Kenichi Handa * mail/rmailmm.el (rmail-mime-insert-header): Set diff -r d67e8472ae65 -r 704fa1a3d5b4 lisp/files.el --- a/lisp/files.el Fri Jan 14 13:08:53 2011 +0900 +++ b/lisp/files.el Fri Jan 14 21:32:19 2011 -0500 @@ -3683,10 +3683,9 @@ (rename-file real-file-name backupname t) (setq setmodes (cons modes backupname))) (file-error - ;; If trouble writing the backup, write it in ~. - (setq backupname (expand-file-name - (convert-standard-filename - "~/%backup%~"))) + ;; If trouble writing the backup, write it in + ;; .emacs.d/%backup%. + (setq backupname (locate-user-emacs-file "%backup%~")) (message "Cannot write backup file; backing up in %s" backupname) (sleep-for 1) diff -r d67e8472ae65 -r 704fa1a3d5b4 lisp/subr.el --- a/lisp/subr.el Fri Jan 14 13:08:53 2011 +0900 +++ b/lisp/subr.el Fri Jan 14 21:32:19 2011 -0500 @@ -2340,11 +2340,16 @@ ;; unless we're in batch mode or dumping Emacs (or noninteractive purify-flag - (file-accessible-directory-p (directory-file-name user-emacs-directory)) - (make-directory user-emacs-directory)) + (file-accessible-directory-p + (directory-file-name user-emacs-directory)) + (let ((umask (default-file-modes))) + (unwind-protect + (progn + (set-default-file-modes ?\700) + (make-directory user-emacs-directory)) + (set-default-file-modes umask)))) (abbreviate-file-name (expand-file-name new-name user-emacs-directory)))))) - ;;;; Misc. useful functions.