Subject: Re: bug#35166: 27.0.50; Buffer state inconsistent after vc-retrieve-tag

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 22 Jun 2021 19:30:01 +0200

Mauro Aranda <[email-masked]> writes:

> Suppose the following workflow for exploring code, under version
> control:
> 1. Start emacs: emacs -Q.
> 2. Visit a directory in Dired mode, e.g. C-x d "emacs/lisp/eshell".
> 3. Navigate to a file, and type 'v'.
> 4. While exploring, one may wish to switch branch, so type:
> C-x v r BRANCH-NAME
>
> I find the following to be inconsistent:
>
> 'vc-retrieve-tag' makes an effort to preserve the modes in the file.
> So it preserves View mode.  But the file is no longer read-only.

I can confirm that this behaviour is still present in Emacs 28.

> This way, the buffer ends up being writable, but with View mode
> enabled, and I find it a little confusing.  I understand if that is to
> respect 'revert-buffer' design, as I infer from this message: [1]
> https://lists.gnu.org/archive/html/emacs-devel/2004-09/msg00002.html

I think this was changed in:

commit 90e118abf2dcc4aca4d7a7642247fa488554351e
Author:     Luc Teirlinck <[email-masked]>
AuthorDate: Fri Sep 3 22:28:10 2004 +0000

    (auto-revert-handler): Bind `buffer-read-only' locally around the call
    to `revert-buffer'.

Reversion now preserves buffer-readedness, if I understand correctly.

> Please, consider either improving what 'vc-retrieve-tag' does, regarding the
> previous state of the buffer, or improving the documentation about this
> behavior.  Or, if you think I'm plain wrong, please explain me the
> reasons, since I would like to understand more of it.

I think it would make sense for `vc-retrieve-tag' to preserve the
readedness of the buffer.  Anybody got any comments here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no