From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: Re: Change backup system Date: Tue, 29 Jul 2008 02:29:07 -0700 (PDT) Organization: http://groups.google.com Message-ID: <72c3a15c-8d73-4bb7-a297-2632cffd647c@r15g2000prd.googlegroups.com> References: <3d30c6e7-d266-4b5b-a397-b9180a0acd88@y21g2000hsf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1217324567 31190 80.91.229.12 (29 Jul 2008 09:42:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 29 Jul 2008 09:42:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 29 11:43:35 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KNljy-0003SI-6r for geh-help-gnu-emacs@m.gmane.org; Tue, 29 Jul 2008 11:43:34 +0200 Original-Received: from localhost ([127.0.0.1]:35562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KNlj3-0001Qw-Gw for geh-help-gnu-emacs@m.gmane.org; Tue, 29 Jul 2008 05:42:37 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!r15g2000prd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 78 Original-NNTP-Posting-Host: 24.6.97.120 Original-X-Trace: posting.google.com 1217323748 3023 127.0.0.1 (29 Jul 2008 09:29:08 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 29 Jul 2008 09:29:08 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r15g2000prd.googlegroups.com; posting-host=24.6.97.120; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:160670 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:56018 Archived-At: On Jul 28, 12:00 pm, Florian Lindner 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 =E2=80=9C/Users/jane/web/xyz/myfile.txt= =E2=80=9D, and your backup root is =E2=80=9C/Users/jane/.emacs.d/emacs-backup=E2=80=9D= , then the backup will be at =E2=80=9C/Users/jane/.emacs.d/emacs-backup/Users/jane/web= / xyz/myfile.txt~=E2=80=9D. 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 =E2=80=9C!=E2=80=9D characters in place of the directo= ry separator. For example, if you are editing a file at =E2=80=9C/Users/jane/w= eb/ xyz/myfile.txt=E2=80=9D, and your backup dir is set at =E2=80=9C/Users/jane= /.emacs.d/ emacs-backup=E2=80=9D, then the backup file will be at: =E2=80=9C/Users/jan= e/.emacs.d/ emacs-backup/Users!jane!web!emacs!myfile.txt~=E2=80=9D. If you use long fil= e 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 =E2=88=91 http://xahlee.org/ =E2=98=84