[Top][All Lists]

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

Re: emacs changed file's own user and file permission

From: Xah Lee
Subject: Re: emacs changed file's own user and file permission
Date: Mon, 10 Dec 2007 17:18:46 -0800 (PST)
User-agent: G2/1.0

On Dec 10, 3:07 pm, Jason Rumney <address@hidden> wrote:
> On 10 Dec, 18:42,XahLee<address@hidden> wrote:
> > * Create options so that emacs backup will be all directed into a user
> > specified directory.
> Do you mean backup-directory-alist?

Thanks. That's very nice, i didn't know about it.

i just tried it and the file is backed up as for example:

i think this is not a robust solution because in principle the file
name length would quickly reach its limit. Another problem in
principle is that it uses a fixed char, requiring the presumation that
the char does not happen file names. (if the char does happen in file
names, that means the backup files can no longer be simply mapped to
the original names)

just to be complete, the code is:
(setq backup-directory-alist '(("" . "/Users/xah/emacs_backup")))

and the alternative solution, which create all the dirs instead of the
“!” and i think should be build in into emacs, is:

; make backup to a designated dir, mirroring the full path
(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 "/Users/xah/emacs_backup")
    (setq bpath (concat backup-root fpath "~"))
    (make-directory (file-name-directory bpath) bpath)
(setq make-backup-file-name-function 'my-backup-file-name)

(setq backup-by-copying t)


reply via email to

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