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

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

Re: Redifine make-backup-file-name has no effect


From: Jan Djärv
Subject: Re: Redifine make-backup-file-name has no effect
Date: Fri, 26 Oct 2001 15:27:48 +0200

Eli Zaretskii wrote:
> 
> > From: Jan Djarv <Jan.Djarv@epl.ericsson.se>
> > Date: Fri, 26 Oct 2001 10:23:14 +0200 (MEST)
> >
> > In emacs 19 and 20 theses functions worked fine to make backup file name to 
> > be
> > .BAK.file instead of file~.  In 21.1 these do nothing, file~ is always 
> > created
> > regardless of what make-backup-file-name is or what the variable
> > make-backup-file-name-function is set to.
> 
> Before Emacs 21.1, redefining these functions was dangerous and had
> subtle misfeatures as side-effects.  Emacs 21.1 introduces
> user-customizable options `backup-directory-alist' and
> `make-backup-file-name-function'; please use them instead of what you
> did before.
> 
> If you already tried to customize `make-backup-file-name-function' and
> it didn't work, please send the details (how did you define the
> replacement function, how did you set the value of
> `make-backup-file-name-function' to point to your replacement, and
> what did Emacs do in response.

The function I tried:
(defun jhd_make-backup-file-name (file)
  "Create the non-numeric backup file name for FILE. This is a separate
function so you can redefine it for customization."
  (if buffer-file-name
      (concat (file-name-directory buffer-file-name)
              ".BAK."
              (file-name-nondirectory buffer-file-name))
    (expand-file-name (concat ".BAK.%" (buffer-name) "#"))))

I set the variable make-backup-file-name-function with customize, save for
future sessions, exit emacs, check my .emacs:

(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(cperl-auto-newline t)
 '(cperl-continued-statement-offset 0)
 '(cperl-extra-newline-before-brace t)
 '(cperl-syntaxify-by-font-lock nil)
 '(cperl-tab-always-indent nil)
 '(font-lock-global-modes nil)
 '(imenu-sort-function (quote imenu--sort-by-name))
 '(make-backup-file-name-function (quote jhd_make-backup-file-name))
 '(scroll-bar-mode (quote right)))

Start emacs 21.1 again, see in *scratch* if the function is loaded correctly:
  (jhd_make-backup-file-name "file")
  "/vobs/wbts/cps/slh/test/.BAK.%*scratch*#"

open a file called link-all, modify it, save it and ls -a:
% ls -a
./  ../  link-all  link-all~

        Jan D.



reply via email to

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