Gyom I used to have M-0, M-+ and M– bound to ordinary ‘text-scale-adjust’ commands, but I found it quite annoying to have to zoom in each buffer separately. This globalized-mode hack is not very elegant, but it works fo me.
See Also: SetFonts#ChangingFontSize for more information and solutions.
Note that using, at the same time, commands from the original text-scale-mode and from this globalized mode yields strange results due to the way buffer-local variables are handled. What we would need here is a way to undo the make-variable-buffer-local statement of face-remap.el, in order for the adjustments to be properly perceived by everyone, but I don’t know how to get that at all.
Until then, this globalized version will be just fine for me !
(define-globalized-minor-mode global-text-scale-mode text-scale-mode (lambda () (text-scale-mode 1))) (defun global-text-scale-adjust (inc) (interactive) (text-scale-set 1) (kill-local-variable 'text-scale-mode-amount) (setq-default text-scale-mode-amount (+ text-scale-mode-amount inc)) (global-text-scale-mode 1) )
(global-set-key (kbd "M-0") '(lambda () (interactive) (global-text-scale-adjust (- text-scale-mode-amount)) (global-text-scale-mode -1))) (global-set-key (kbd "M-+") '(lambda () (interactive) (global-text-scale-adjust 1))) (global-set-key (kbd "M--") '(lambda () (interactive) (global-text-scale-adjust -1)))
A far better way to get the same effect is to cutomize the size of the default face to make the size of the default font larger. I assume that’s what you want since you talk of zooming each buffer separately. Note that you must use a whole number for the size; this specifies the absolute size of the face. If you don’t use a whole number, then that means a relative size, but since the default font doesn’t inherit from anything, there’s nothing for it to be relative to!
But there are problems with your code. Firstly it confuses some major modes, Notmuch Hello mode being an example. Secondly you can tune the resizing to exactly what you want. Thirdly you won’t normally have to bother about zooming at all because Emacs will start up with the font size you want. And, of course, you won’t get the strange effects you talk about.
That having been said, I think your code ought to work, without casing strange effects, but that you are running into bug #1785 in the font remapping routines.
If you read my original post you will see that I suggested doing this in your init file. I always think of that first because I’m not much into using customization. However I found that bug #1785 scuppers that too!
I hope you find this helpful. — Bernard Hurley
(defadvice text-scale-increase (around all-buffers (arg) activate) (dolist (buffer (buffer-list)) (with-current-buffer buffer ad-do-it)))