EMACS :: linum 模式和字体大小(不可读的行号)

发布于 2025-01-05 15:57:40 字数 717 浏览 1 评论 0原文

当在 emacs 中使用 linum-mode 以及通过 Mx text-scale-increase 增加字体时,有一件事困扰着我。行号的字体与阅读的大小相同,并且不适合到缓冲区左侧的left-margin

1 正常字体大小,OK一切正常

2 字体大小增大,不再可读 FUUUUU在此处输入图像描述


我真正想要的有:

增加/减少字体时,我希望其中之一起作用

  1. ,然后增加/减少左边距的宽度(resp。 left-fringe) 相应地
  2. 然后不要更改左边距的字体但增加/减少行号之间的间距

    有人有什么建议吗? 谢谢,伙计们

When using linum-mode in emacs and when increase font by M-x 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, OKEverything works as should be

2
Increased font-size, no longer readable FUUUUUenter image description here


What I'd really like to have:

When increase/decrease font I want one of these to work

  1. then increase/decrease width of left-margin (resp. left-fringe) accordingly
  2. then don't change font for left-margin but increase/decrease spacing between line numbers

    Does anybody have some suggestions?
    Thanks, guys

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

無處可尋 2025-01-12 15:57:41

我想我可以用下面的代码解决这个问题:

(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)

它似乎可以工作,至少在 24.5 上是这样。

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.

神经大条 2025-01-12 15:57:41

如果可以的话,我会评论基于 customize-face 的解决方案。这对我来说效果很好。实际的面孔是 linum 而不是 linum-mode,至少在我的 emacs-24.3.1 中是这样。在自定义缓冲区中,我单击“显示所有属性”,然后将面高度设置为十分之 100 点。如果您可以接受行号的固定大小的面(就像我一样),那么基于 customize-face 的解决方案非常简单。

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.

み青杉依旧 2025-01-12 15:57:41

您可以禁用 linum-mode 并使用 display-line-numbers-mode 来代替,它是自版本 26 以来 Emacs 的一部分,并且在增加字体大小时可以很好地缩放。

例如,您的配置可能如下所示:

;; (global-linum-mode 1)
(global-display-line-numbers-mode)

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.

E.g. your config can look like:

;; (global-linum-mode 1)
(global-display-line-numbers-mode)
避讳 2025-01-12 15:57:40

看一下这两个链接:

  1. 我对同一问题的疑问
  2. 我的此问题的解决方法

它可以很好地满足我的需求。

示例:

在此处输入图像描述
1
在此处输入图像描述

Have a look at these two links:

  1. my question on the same issue
  2. my workaround for this issue

It works quite well enough for my needs.

Examples:

enter image description here
1
enter image description here

完美的未来在梦里 2025-01-12 15:57:40

我见过的最简单、最直接的解决方案是将行号设置为固定高度。根据 user78810 的回答,这可以轻松完成:https://unix.stackexchange.com/questions/ 29786/font-size-issues-with-emacs-in-linum-mode/146781#146781

也就是说,在您的 emacs 配置中添加以下行(如果您使用的是 spacemacs,则添加到您的 dotspacemacs/user-config 函数中):

(eval-after-load "linum"
  '(set-face-attribute 'linum nil :height 100))

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))
溺孤伤于心 2025-01-12 15:57:40
M-x customize-face [RETURN] linum-mode
M-x customize-face [RETURN] linum-mode
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文