Subject: bug#12507: Have I mentioned how much I hate Debbugs?

From: Karl Fogel <[email-masked]>
Date: Mon, 01 Oct 2012 16:23:55 -0500

"Drew Adams" <[email-masked]> writes:
>What I would prefer is a general solution, along the lines I suggested (in my
>mail of 9/28): extend the general `version-control' to let users specify backup
>for particular files.  I proposed adding an option like this, as one way to do
>that:
>
>(defcustom version-control-overrides ()
>  "Control the use of version numbers for backing up specific files.
>Each entry is of the form (REGEXP-OR-VARIABLE . VALUE), where:
>REGEXP-OR-VARIABLE is a regexp matching file names or the name of a
> file name-valued variable.
>VALUE has the same meaning as the value of option `version-control,
> but affects only the files whose names match REGEXP."
>  :type '(repeat (cons :tag "File & when"
>                  (choice
>                   (regexp   :tag "File-name regexp")
>                   (variable :tag "File-name variable"))
>                  (choice
>                   (const :tag "Never"       never)
>                   (const :tag "If existing" nil)
>                   (other :tag "Always"      t))))
>  :group 'backup :group 'vc)
>
>Then, to handle the file that is the value of variable `bookmark-file' you would
>just add an entry like this: (bookmark-file . t).

I like this general solution.

>We could do what I suggested in my message of 9/29:
>
>d> 3. Provide for optional backups, but if the user chooses not
>d>    to back up, then do not visit the file.
>d>
>d> With #3, the user would pay the price that Stefan mentions for
>d> visiting the file only when s?he chooses backup.
>
>I based that on my understanding (still asking the question though, since I'm
>not sure) that you cannot back up the file unless you visit it.  Stefan's
>objection, and the reason we moved away from `write-file', is that a user might
>not want to visit the file, since that has some additional effects (e.g. asking
>for confirmation if some other process modified the file).

One thing I'm confused by:

Why does backing up a file have anything to do with visiting it?
Backing up just means making a copy.  There is no reason why visiting
the file in a buffer is necessary for that (surely `copy-file' does not
visit the file, for example).

Yet in this discussion, the assumption is that to get backups, we have
to also visit the file.

>But those effects are anyway desirable, IF you want to back up the
>file.  So it seems to me that what we want is to either (a) visit the
>file and do `save-buffer' or `write-file or equivalent IF the option
>value says to back up the file, or (b) do what we do not IF NOT.

Hmm, this feels like a workaround.  Instead, let's get to the bottom of
why backing up and visiting are linked at all.

>In any case, it sounds like we have all agreed at least on the need of
>a way for a user to say whether or not s?he wants backups.
>`bookmark-version-control' does not do that - it controls only whether
>to use ordinary backups or numeric backups.  So I think the first step
>is to add an option so that a user can express that choice.

Yes, but...

Is it worth it to have even `bookmark-version-control' at all?  The
number of people who need backups on this file must be small, since most
users presumably do not edit it directly nor even know where it is.

A more general solution might be `bookmark-before-save-hook'.  The few
people who want backups can DTRT in the hook, and bookmark's code
wouldn't need to worry about this at all.

K