0

In GNU Emacs 27.2 is there a way to change the text font size of a single buffer without changing all open instances of that buffer (in different frames)?

In my version of emacs, when I use Ctrl+MouseWheel up/down it enlarges or reduces the font size for all instances of the current buffer. I'm interested in just instance of the buffer (in one frame) to be resized.

What I've tried

Searching I found SO question/answer

I looked for a solution to my question and found this article which indicates that the feature I'm looking for is not supported. See https://www.emacswiki.org/emacs/SetFonts it says:

You can resize (text-scale) the text in a buffer (in all windows showing it), or you can resize the default font of a frame.

I also found this question/answer:

Is it possible to change the font size in specific buffers? This explains how a buffer's text can be resized in all frames (that have the buffer open). Basically, I already have this working with Ctrl+MouseWheel up/down.

Why?

Why do I want to do this? you might ask. I have a daily notes file in which I use emacs outline mode. I'll put (in some cases) a large (100+ lines) of a log file for my records and easy grep'ing for problems in the future. The outline mode makes it trivial to collapse a large log so I can focus on my notes.

However, when I'm studying a log file I want smaller font; so I want one frame for notes and a separate frame for studying a log file.

2 Answers 2

1

I don't think you can: text-scale-mode-amount is a property of the buffer (i.e. a buffer-local variable). If the buffer is shown in two different windows (in the same or different frames), it's still the same buffer, so the text scale will apply to the buffer in whatever window(s) it is shown.

So the trick is to use a different buffer. That is possible with an indirect buffer - see Indirect buffers[1] in the Emacs Lisp Reference manual. make-indirect-buffer will create an indirect buffer that shares the text with the original buffer (so if you make changes to the text in one, the changes are reflected in the other), but it is a different buffer with its own local variables, so you can adjust the text scale in one without affecting the other.


[1] I can't get to the online manual at the moment. I'll provide a link eventually I was able to get to the online manual eventually and provide a link, but the better way to read the manual in any case is through Info in Emacs itself: C-h i g(elisp)Indirect RET will take you there.

1
  • This worked perfectly. I used make-indirect-buffer and then switched to it and then my Ctrl+MouseWheel up/down worked as expected and it did not change the font in my other frame! Thanks!
    – PatS
    Feb 17, 2023 at 19:05
0

Your question isn't clear, and seems to combine multiple questions or other bits of info.

Wrt this bit of info (is it a question?):

Searching - I searched for the zoom-in/out feature: At https://www.emacswiki.org/emacs/SetFonts it says:

You can resize (text-scale) the text in a buffer (in all windows showing it), or you can resize the default font of a frame.

But I haven't been able to get it to work (yet).

What does "work" or not "work" mean here? Zooming a frame in and out works fine. That is, it does what its doc says. But who knows what you mean by saying it doesn't work for you?

And is zooming a frame in and out (all its windows) even related to your main/other question? I have no idea, but I didn't think so, or I would have suggested zooming a frame in & out (which works by changing the frame's default font size.

So if it is what you're looking for then that's my answer: do that. Now you say you've tried and failed to make it "work". Or perhaps what it did isn't what you expected or wanted? How are we to know?

2
  • I'll see if I an update the wording of my question to address the issues you brought up.
    – PatS
    Feb 21, 2023 at 3:39
  • Zooming a frame really should have said zooming a buffer's text font size affects all instances of the buffer in all frames that the buffer exists in. I can see why this wasn't clear.
    – PatS
    Feb 21, 2023 at 3:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.