[Top][All Lists]

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

Re: Changing name format for backup files

From: Nick Helm
Subject: Re: Changing name format for backup files
Date: Fri, 15 Jan 2016 17:53:14 +1300
User-agent: mu4e 0.9.15; emacs 24.5.1

> When I was messing with backing up, I also noticed this thing.  So what
> I did is: I just replaced `make-backup-file-name-1' with my own
> `utl-make-backup-file-name-1' function¹ that does what I need:
>   (advice-add 'make-backup-file-name-1
>     :override 'utl-make-backup-file-name-1)
> I didn't follow this thread closely, so I'm sorry if this reply is useless.

Ok, this is a good excuse to learn to use advice. This is what I tried:

   (defun nick-add-prefix-dot (file)
      "Inject a prefix dot into file name FILE."
      (concat (file-name-directory file) "." (file-name-nondirectory file)))

   (defun nick-auto-save-file-name-p (file)
       "Return non-nil if FILE is an auto-save file name."
       (string-match "\\`\\.#.*#\\'" file))

   (advice-add 'make-backup-file-name-1 :filter-return #'nick-add-prefix-dot)
   (advice-add 'make-auto-save-file-name :filter-return #'nick-add-prefix-dot)
   (advice-add 'auto-save-file-name-p :override #'nick-auto-save-file-name-p)

Which seems to work well. I don't think `backup-file-name-p' doesn't
need override advice in this case as it only checks that files end with ~.

reply via email to

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