[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Should `revert-buffer' preserve text-scaling by default?
From: |
Karl Fogel |
Subject: |
Should `revert-buffer' preserve text-scaling by default? |
Date: |
Fri, 29 Nov 2019 14:24:14 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Currently, when you do `revert-buffer' it will discard any text scale changes
done in that buffer (i.e., done via "C-x C-+" / `text-scale-adjust').
The effect -- unexpected to me at least -- is that when I revert a buffer whose
text size I have increased, the text suddenly shrinks down again (to whatever
the default text scale was).
Before I "fix" this, I'd like to know if others consider it a bug or a feature.
The reason the text scale currently gets reverted is that text-scaling happens
to be implemented via the minor mode `text-scale-mode'. Since `revert-buffer'
doesn't preserve modes by default, text-scaling is lost when one reverts.
There is an optional `preserve-modes' argument to `revert-buffer', but I don't
think that just making wrapper that sets that argument to non-nil is a good
solution here, because that would preserve *all* the modes. From the user's
point of view, the fact that text-scaling happens to be implemented via a minor
mode is irrelevant and is probably not something most users are even aware of.
Text-scaling is more like a magnifying glass (or reducing glass) that one
places over the text of a particular buffer. Reverting the buffer to its
original content is something that happens "under" the glass -- there's no
reason reverting should change the magnification/reduction level.
We could fix this by making `revert-buffer--default' preserve `text-scale-mode'
and `text-scale-amount', either unconditionally or conditionally based on a new
variable `revert-buffer-preserve-text-scale'. I would be fine with either
solution; if conditional, I would opt for `revert-buffer-preserve-text-scale'
being true by default. (Note that if someone has written a custom
`revert-buffer-function' to be used instead of `revert-buffer--default', then
we should let their custom function decide what to do about text-scaling; it
can choose whether or not to honor a `revert-buffer-preserve-text-scale'
variable.)
Before I go down this road, I'd like to know if anyone thinks text-scaling is
just another minor mode and should be bound together with other modes via the
existing `preserve-modes' flag to `revert-buffer'. I think the opposite: that
is, I think text-scaling should be treated specially, for the reasons given
above. I just wanted to check here before writing any code.
Best regards,
-Karl
- Should `revert-buffer' preserve text-scaling by default?,
Karl Fogel <=