From: Alex Kost <alezost@gmail.com>
To: Nick Helm <nick@tenpoint.co.nz>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Changing name format for backup files
Date: Fri, 15 Jan 2016 12:53:29 +0300 [thread overview]
Message-ID: <877fjbnp7q.fsf@gmail.com> (raw)
In-Reply-To: <m28u3r5tqd.fsf@tenpoint.co.nz> (Nick Helm's message of "Fri, 15 Jan 2016 17:53:14 +1300")
Nick Helm (2016-01-15 07:53 +0300) wrote:
>> 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 ~.
Oh great, I didn't notice :filter-return before. It can be very useful, thanks!
--
Alex
prev parent reply other threads:[~2016-01-15 9:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-11 22:21 Changing name format for backup files Nick Helm
2016-01-11 23:26 ` Óscar Fuentes
2016-01-12 22:32 ` Nick Helm
2016-01-13 14:34 ` Alex Kost
2016-01-15 4:53 ` Nick Helm
2016-01-15 9:53 ` Alex Kost [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877fjbnp7q.fsf@gmail.com \
--to=alezost@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=nick@tenpoint.co.nz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).