When using linum-mode in emacs and when increase font by Mx text-scale-increase
, there is the one thing that bothers me. Font for line numbers have same size as reading and don't fit into left-margin
on left side of buffer!
1 Normal font-size, OK
2 Increased font-size, no longer readable FUUUUU
What I'd really like to have:
When increase/decrease font I want one of these to work
then don't change font for left-margin but increase/decrease spacing between line numbers
Does anybody have some suggestions? Thanks, guys
Have a look at these two links:
It works quite well enough for my needs.
Examples:
1
The easiest, most straightforward solution I've seen is to set the line numbers to a fixed height. This can be accomplished easily, in accordance with user78810 's answer: https://unix.stackexchange.com/questions/29786/font-size-issues-with-emacs-in-linum-mode/146781#146781
To wit, add the following line in your emacs config (or to your dotspacemacs/user-config
function, if you're using spacemacs):
(eval-after-load "linum"
'(set-face-attribute 'linum nil :height 100))
M-x customize-face [RETURN] linum-mode
I think I can fix that problem with the following code:
(require 'linum)
(defun linum-update-window-scale-fix (win)
"fix linum for scaled text"
(set-window-margins win
(ceiling (* (if (boundp 'text-scale-mode-step)
(expt text-scale-mode-step
text-scale-mode-amount) 1)
(if (car (window-margins))
(car (window-margins)) 1)
))))
(advice-add #'linum-update-window :after #'linum-update-window-scale-fix)
It seems to work, at least with 24.5.
I would comment on the solution based on customize-face
if I could. It works well for me. The actual face is linum
rather than linum-mode
, at least in my emacs-24.3.1
. In the customization buffer, I clicked on "Show all attributes" and then set the face height to 100 tenths of a point. If a fixed-size face for the line numbers is acceptable to you (as it is to me) the solution based on customize-face
is straightforward.
You can disable linum-mode
and use display-line-numbers-mode
instead which is part of Emacs since version 26 and scales well when increasing font size.
Eg your config can look like:
;; (global-linum-mode 1)
(global-display-line-numbers-mode)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.