Subject: bug#40967: 27.0.50; vc-diff in indirect buffers

From: Phil Sainty <[email-masked]>
Date: Wed, 17 Jun 2020 00:08:40 +1200

On 30/04/20 6:13 am, Dmitry Gutov wrote:
> On 29.04.2020 21:01, Nathan Moreau wrote:
>> open any file-under-version-control
>> M-x clone-indirect-buffer
>> In the new buffer, run vc-diff fails with `vc-deduce-fileset:
>> Buffer [...] is not associated with a file`
>
> I'm not sure we really want to support that workflow. Or else
> a lot of commands would have to be changed the same way,
> inside and outside of VC.
>
> But opinions welcome.

FWIW, we did the same thing for `diff-buffer-with-file' quite
recently:

https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=1bcf5d02da96784a04034b4c0aba8fdfa1413c4e

Personally I'd be ok with seeing piecemeal changes to commands
like these to enable certain common workflows to DTRT with
indirect buffers.  I think there will likely be a subset of
commands which are of higher value than others, and so there
might not be such a vast number of things which are very useful
to change in practice.  (Or maybe it's a slippery slope.)

Something like the following might be convenient:

 (defun buffer-base-buffer-file-name (&optional buffer)
   "Like `buffer-file-name', but also supporting indirect buffers."
   (buffer-file-name
    (or (buffer-base-buffer buffer) buffer (current-buffer))))

-Phil