unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Change backup system
@ 2008-07-28 19:00 Florian Lindner
  2008-07-28 19:20 ` Evans Winner
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Florian Lindner @ 2008-07-28 19:00 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

can I (I suppose I can, it's Emacs) and how can I change the way Emacs
backup files. The default is to create a filename~ in the same folder.

My idea is to copy the file to another folder. When I edit and save ~/
text/file.txt the backup is saved in ~/.emacs.d/backup/home/florian/
text/file.txt.n with n being a number incremted form 1 to x each save.

Can I configure Emacs like that?

Thanks,

Florian


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change backup system
  2008-07-28 19:00 Change backup system Florian Lindner
@ 2008-07-28 19:20 ` Evans Winner
  2008-07-28 19:57 ` Peter Dyballa
  2008-07-29  9:29 ` Xah
  2 siblings, 0 replies; 6+ messages in thread
From: Evans Winner @ 2008-07-28 19:20 UTC (permalink / raw)
  To: help-gnu-emacs

Florian Lindner <Florian.Lindner@xgm.de> writes:

    My idea is to copy the file to another folder. When I
    edit and save ~/ text/file.txt the backup is saved in
    ~/.emacs.d/backup/home/florian/ text/file.txt.n with n
    being a number incremted form 1 to x each save.

I have a directory called ~/bu and this in my .emacs
(thought I am not sure which versions of Emacs it works
with):

(setq version-control t)              ; Numbered backups.
(setq backup-directory-alist          ; Backup directory          
      `(("." .                        
	 ,(expand-file-name "~/bu"))))

I don't know if this is exactly what you mean....  I
occasionally clean out old stuff from my ~/bu directory.

The files are named like this:

  !home!thorne!hacking!litmus!mla.tmac.~3~

with bang-path kinda names and the number at the end a
version number.

Here is some documentation about those variables:

,----[ C-h v version-control RET ]
| version-control is a variable defined in `/home/usr/local/share/emacs/23.0.60/lisp/files.elc'.
| Its value is t
| 
|   This variable is safe as a file local variable if its value
|   satisfies the predicate `(lambda (x) (or (booleanp x) (equal x (quote never))))'.
| 
| Documentation:
| Control use of version numbers for backup files.
| When t, make numeric backup versions unconditionally.
| When nil, make them for files that have some already.
| The value `never' means do not make them.
| 
| You can customize this variable.
`----

,----[ C-h v backup-directory-alist RET ]
| backup-directory-alist is a variable defined in `/home/usr/local/share/emacs/23.0.60/lisp/files.elc'.
| Its value is 
| (("." . "/home/thorne/bu"))
| 
| 
| Documentation:
| Alist of filename patterns and backup directory names.
| Each element looks like (REGEXP . DIRECTORY).  Backups of files with
| names matching REGEXP will be made in DIRECTORY.  DIRECTORY may be
| relative or absolute.  If it is absolute, so that all matching files
| are backed up into the same directory, the file names in this
| directory will be the full name of the file backed up with all
| directory separators changed to `!' to prevent clashes.  This will not
| work correctly if your filesystem truncates the resulting name.
| 
| For the common case of all backups going into one directory, the alist
| should contain a single element pairing "." with the appropriate
| directory name.
| 
| If this variable is nil, or it fails to match a filename, the backup
| is made in the original file's directory.
| 
| On MS-DOS filesystems without long names this variable is always
| ignored.
| 
| You can customize this variable.
`----


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change backup system
  2008-07-28 19:00 Change backup system Florian Lindner
  2008-07-28 19:20 ` Evans Winner
@ 2008-07-28 19:57 ` Peter Dyballa
  2008-07-28 20:18   ` Thierry Volpiatto
  2008-07-29  9:29 ` Xah
  2 siblings, 1 reply; 6+ messages in thread
From: Peter Dyballa @ 2008-07-28 19:57 UTC (permalink / raw)
  To: Florian Lindner; +Cc: help-gnu-emacs


Am 28.07.2008 um 21:00 schrieb Florian Lindner:

> Can I configure Emacs like that?

(setq auto-save-interval 125)
;; Backups to central location
(setq make-backup-files         t ; backup my files
       backup-by-copying         t ; don't clobber sym-links
;      backup-directory-alist   '(("." . (concat (user-emacs- 
directory "/Sicherungen")))) ; don't litter
       delete-old-versions       t
       kept-new-versions         6
       kept-old-versions         2
       version-control           t ; use versioned backups
       vc-make-backup-files      t ; make backups for cvs projects
       vc-follow-symlinks        t)
(setq backup-directory-alist    '(("." . "~/.emacs.d/ 
Sicherungen"))) ;don't litter

--
Mit friedvollen Grüßen

   Pete     === -Q
              ==<__/% >>
_____________(_)____@_____________________________






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change backup system
  2008-07-28 19:57 ` Peter Dyballa
@ 2008-07-28 20:18   ` Thierry Volpiatto
  0 siblings, 0 replies; 6+ messages in thread
From: Thierry Volpiatto @ 2008-07-28 20:18 UTC (permalink / raw)
  To: Peter Dyballa; +Cc: Florian Lindner, help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

> Am 28.07.2008 um 21:00 schrieb Florian Lindner:
>
>> Can I configure Emacs like that?
>
> (setq auto-save-interval 125)
> ;; Backups to central location
> (setq make-backup-files         t ; backup my files
>       backup-by-copying         t ; don't clobber sym-links
> ;      backup-directory-alist   '(("." . (concat (user-emacs-
> directory "/Sicherungen")))) ; don't litter
>       delete-old-versions       t
>       kept-new-versions         6
>       kept-old-versions         2
>       version-control           t ; use versioned backups
>       vc-make-backup-files      t ; make backups for cvs projects
>       vc-follow-symlinks        t)
> (setq backup-directory-alist    '(("." . "~/.emacs.d/
> Sicherungen"))) ;don't litter

And when you /su::/etc (for example) if you add that lines:

,----
| (setq tramp-backup-directory-alist backup-directory-alist)
| (setq auto-save-file-name-transforms nil)
`----

when you edit files in /etc you will have also the backups in your
`backup-directory-alist' directory.

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change backup system
  2008-07-28 19:00 Change backup system Florian Lindner
  2008-07-28 19:20 ` Evans Winner
  2008-07-28 19:57 ` Peter Dyballa
@ 2008-07-29  9:29 ` Xah
  2008-07-29 18:12   ` Florian Lindner
  2 siblings, 1 reply; 6+ messages in thread
From: Xah @ 2008-07-29  9:29 UTC (permalink / raw)
  To: help-gnu-emacs

On Jul 28, 12:00 pm, Florian Lindner <Florian.Lind...@xgm.de> wrote:
> Hello,
>
> can I (I suppose I can, it's Emacs) and how can I change the way Emacs
> backup files. The default is to create a filename~ in the same folder.
>
> My idea is to copy the file to another folder. When I edit and save ~/
> text/file.txt the backup is saved in ~/.emacs.d/backup/home/florian/
> text/file.txt.n with n being a number incremted form 1 to x each save.
>
> Can I configure Emacs like that?


Yes. I have the code that does exactly what you want.

----------------------------------

Q: 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.

------------------

The above is a excerpt from:

http://xahlee.org/emacs/emacs_adv_tips.html

The page is part of my emacs and elisp tutorial at

http://xahlee.org/emacs/emacs.html

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change backup system
  2008-07-29  9:29 ` Xah
@ 2008-07-29 18:12   ` Florian Lindner
  0 siblings, 0 replies; 6+ messages in thread
From: Florian Lindner @ 2008-07-29 18:12 UTC (permalink / raw)
  To: help-gnu-emacs

On 29 Jul., 11:29, Xah <xah...@gmail.com> wrote:
> On Jul 28, 12:00 pm, Florian Lindner <Florian.Lind...@xgm.de> wrote:
>
> > Hello,
>
> > can I (I suppose I can, it's Emacs) and how can I change the way Emacs
> > backup files. The default is to create a filename~ in the same folder.
>
> > My idea is to copy the file to another folder. When I edit and save ~/
> > text/file.txt the backup is saved in ~/.emacs.d/backup/home/florian/
> > text/file.txt.n with n being a number incremted form 1 to x each save.
>
> > Can I configure Emacs like that?
>
> Yes. I have the code that does exactly what you want.

[...]

I have now:

(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/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
      version-control t
      delete-old-versions t
      kept-new-versions 6
      kept-old-versions 2)

The my-backup-file-name works as you have described but it seems not
to cooperate with the numbered backups (version-control t). There is
always the first backup saved and never modified.
BTW: What is difference between kept-new-versions and kept-old-
versions?

Thanks,

Florian


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-07-29 18:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-28 19:00 Change backup system Florian Lindner
2008-07-28 19:20 ` Evans Winner
2008-07-28 19:57 ` Peter Dyballa
2008-07-28 20:18   ` Thierry Volpiatto
2008-07-29  9:29 ` Xah
2008-07-29 18:12   ` Florian Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).