[英]EMACS :: linum-mode and size of font (unreadable line numbers)
When using linum-mode in emacs and when increase font by Mx text-scale-increase
, there is the one thing that bothers me.当在 emacs 中使用 linum-mode 并且通过
Mx text-scale-increase
增加字体时,有一件事情困扰着我。 Font for line numbers have same size as reading and don't fit into left-margin
on left side of buffer!行号的字体与阅读的大小相同,并且不适合缓冲区
left-margin
!
1 Normal font-size, OK 1正常字体大小,OK
2 Increased font-size, no longer readable FUUUUU 2增加字体大小,不再可读 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
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
根据user78810的回答,这可以轻松完成: 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): dotspacemacs/user-config
在您的 emacs 配置中添加以下行(或添加到您的dotspacemacs/user-config
函数,如果您使用的是 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.它似乎有效,至少在 24.5 下是有效的。
I would comment on the solution based on customize-face
if I could.如果可以的话,我会评论基于
customize-face
的解决方案。 It works well for me.这对我来说很有用。 The actual face is
linum
rather than linum-mode
, at least in my emacs-24.3.1
.实际的面孔是
linum
而不是linum-mode
,至少在我的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.在自定义缓冲区中,我单击“显示所有属性”,然后将面高度设置为 100 个点。 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.如果您可以接受行号的固定大小的面(对我来说也是如此),那么基于
customize-face
的解决方案很简单。
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.您可以禁用
linum-mode
并使用display-line-numbers-mode
而不是 Emacs 的一部分,因为版本 26 并且在增加字体大小时可以很好地缩放。
Eg your config can look like:例如,您的配置可能如下所示:
;; (global-linum-mode 1)
(global-display-line-numbers-mode)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.