help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs allways asking to delete excess backup file


From: Xah
Subject: Re: emacs allways asking to delete excess backup file
Date: Fri, 2 May 2008 07:51:42 -0700 (PDT)
User-agent: G2/1.0

You might be intrested in the following:

• How to set emacs so that all backups are directed into one folder?
(such as at a directory "~/myBackups")

Use the following lisp code in init file:

; return a backup file path of a give file path
; with full directory mirroring from a root dir
; non-existant dir will be created
(defun my-backup-file-name (fpath)
  "Return a new file path of a given file path.
If the new path's directories does not exist, create them."
  (let (backup-root bpath)
    (setq backup-root "~/.emacs.d/emacs-backup")
    (setq bpath (concat backup-root fpath "~"))
    (make-directory (file-name-directory bpath) bpath)
    bpath
  )
)
(setq make-backup-file-name-function 'my-backup-file-name)

The above will mirror all directories at the given backup dir. For
example, if you are editing a file “/Users/jane/web/xyz/myfile.txt”,
and your backup root is “/Users/jane/.emacs.d/emacs-backup”, then the
backup will be at “/Users/jane/.emacs.d/emacs-backup/Users/jane/web/
xyz/myfile.txt~”.

If you want all backup to be flat in a dir, use the following:

(setq backup-directory-alist '(("" . "~/.emacs.d/emacs-backup")))

This will create backup files flat in the given dir, and the backup
file names will have “!” characters in place of the directory
separator. For example, if you are editing a file at “/Users/jane/web/
xyz/myfile.txt”, and your backup dir is set at “/Users/jane/.emacs.d/
emacs-backup”, then the backup file will be at: “/Users/jane/.emacs.d/
emacs-backup/Users!jane!web!emacs!myfile.txt~”. If you use long file
names or many nested dirs, this scheme will reach file name length
limit quickly.

  Xah
  address@hidden
∑ http://xahlee.org/

☄


On May 2, 6:08 am, TheLonelyStar <address@hidden> wrote:
> I hate thos *~ files all over my filesystem, I therefor added the following
> to my .emacs:
>
> ;; Enable backup files.
> (setq make-backup-files t)
>
> ;; Enable versioning with default values (keep five last versions, I think!)
> (setq version-control t)
>
> ;; Save all backup file in this directory.
> (setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))
>
> Now emacs always askes me, if it should delete excess backup file when I
> save a file ...
> Can I make emacs to just do it without asking?
>
> Thanks!
> Nathan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]