Subject: Re: bug#58005: 13.1.4; Can't work with indirect buffers

From: Ikumi Keita <[email-masked]>
Date: Tue, 23 Apr 2024 19:48:50 +0900

[ Please keep Cc: [email-masked] when you reply so that the record remains in the bug tracker. ]

>>>>> Vangelis Evangelou <[email-masked]> writes:

> Regarding `TeX-master-file', I don't know what is the correct order that
> the various conditions need to be checked. There might be a situation where
> the file is shared between two master files. As far as I can tell, auctex
> allows for this by setting TeX-master to 'shared as a local variable. In
> that case you might want to have the main buffer set to one of the master
> files and the indirect buffer set to the other master file. Is that a
> desirable functionality? I personally don't use that options.

It isn't clear for me, too :-) In theory, base buffer and cloned buffer
can have different master file as you say and the user can make use of
that duality. However, the user must remember which buffer has which
master file in that case, between buffers with identical contents. That
doesn't seem a useful feature to me.

> I think there is a simpler way to approach this. We should have the
> function check at the beginning if the buffer is indirect, and switch
> temporarily to the base buffer before doing the rest of the operations.

This can be a solution, indeed.

> This is perhaps simpler, but does not allow for the situation I mentioned
> above with the two masters. The way to do that is with
>   (with-current-buffer
>      (or (buffer-base-buffer) (current-buffer)))
> at the beginning of the function. There is also another function that is
> affected: `TeX-normal-mode' which calls `normal-mode'. In the documentation
> is says:
> If invoked in a buffer that doesn’t visit a file, this function
> processes only the major mode specification in the -*- line and
> the local variables spec.
> I found that it doesn't correctly set the local variables if
> TeX-normal-mode is run on the indirect buffer.

OK.

> I attach the updated patch. I have tested this, and it works for me. Please
> let me know what you think.

A brief testing didn't show fatal behavior. Here are two notes I noticed:
1. In indirect buffer, preview-latex doesn't work. All preview images
   appear in the base buffer.
2. TeX Fold mode works independently in indirect and base buffers.

I suppose there will be dissatisfied users about item 1. Do you have any
good idea about it?
Item 2 can be a useful feature rather than a shortcoming, whereas some
users want to inherit the folded appearance when they clone a buffer.

Maybe we should regard these points as feature and announce them as
"known limitations".

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW