Subject: bug#52508: [PATCH] Option for vc-delete-file to keep file on disk

From: Eli Zaretskii <[email-masked]>
Date: Wed, 15 Dec 2021 16:14:14 +0200

> From: Ashwin Kafle <[email-masked]>
> Date: Wed, 15 Dec 2021 10:23:42 +0000
> Cc: Ashwin Kafle <[email-masked]>, Dmitry Gutov <[email-masked]>
> 
> I've created the attached patch to have vc-delete file to keep files on
> disk using a prefix argument. I've only tested it for vc-git.

Thanks, sounds useful.

A few minor comments below, mainly to the documentation parts:

> * doc/emacs/vc1-xtra.texi: Document the change.
> * lisp/vc/vc-git.el: Make git leave files on disk.
> * lisp/vc/vc.el: Change vc-delete-file to accept optional prefix argument.

Our conventions are to use the ChangeLog style of these entries, which
means they should state the function names where the changes are made,
not just the file names.

> --- a/doc/emacs/vc1-xtra.texi
> +++ b/doc/emacs/vc1-xtra.texi
> @@ -122,7 +122,8 @@ VC Delete/Rename
>    If you wish to delete a version-controlled file, use the command
>  @kbd{M-x vc-delete-file}.  This prompts for the file name, and deletes
>  it via the version control system.  The file is removed from the
> -working tree, and in the VC Directory buffer
> +working tree, and in the VC Directory buffer. If you give a prefix argument,
                                               ^^
We leave 2 spaces between sentences, per US English conventions.

> +*** 'C-x v x' accepts a prefix argument to keep file on disk

Period at the end of the heading, please.

> +Previously 'C-x v x' always deleted the selected file. Now if you give it
> +prefix argument, it will keep the buffer and file on disk intact.

Two spaces between sentences.

> -(defun vc-delete-file (file)
> +(defun vc-delete-file (file &optional keep-file)
>    "Delete file and mark it as such in the version control system.
>  If called interactively, read FILE, defaulting to the current
> -buffer's file name if it's under version control."
> -  (interactive (list (read-file-name "VC delete file: " nil
> -                                     (when (vc-backend buffer-file-name)
> -                                       buffer-file-name)
> -                                     t)))
> +buffer's file name if it's under version control.
> +If a prefix argument is given (optional argument KEEP-FILE) then
> +don't delete the file from the disk"

Period missing at the end of the last sentence.

> -	(let ((backup-inhibited nil))
> +	(let ((backup-inhibited nil)
> +              ;; if you don't set this, then for some reason, the file is never brought back
> +              (backup-by-copying t))

Wouldn't it be better to understand why this mystery happens?

Also, please start the comment with a capital letter and end it with a
period.