9

I've set up emacs to display line numbers (global-linum-mode 1), and it works until I start enlarging the text via text-scale-adjust

The line numbers column starts to shrink, and disappears entirely after a few increments.
When it has fully disappeared, further increments have no more effect on the left edge.

Is this a know issue? Is there a workaround?

Using GNU Emacs 23.1.1 in Ubuntu 10.04.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Peter.O
  • 32,916
  • When I do this in Emacs 23.1, the numbers on the left scale with the rest of the text and eventually get too big for the space they are in (making it hard to see them) but the column they are in remains the same size. Is this the same behavior you are seeing or are you seeing something else? – Steven D Feb 16 '11 at 20:10
  • 1
    Like Steven, what I observe is that the line numbers column stays the same width in pixels (so it becomes too small to fit the characters if you call text-scale-adjust with a positive argument). This looks like a bug in the implementation of the left-margin text property. I haven't investigated further. – Gilles 'SO- stop being evil' Feb 16 '11 at 22:18
  • Thanks Steven and Gilles... It seems to be the same behaviour.. My line-number col does not narrow (as I first thought. It just looked that way as the text got larger (black ln-nb-col, and charcoal "wrap-indicator" margin). The line-numbers do a tectonic disappearing act "under" the nargin and buffer proper.. (a bug it seems) – Peter.O Feb 17 '11 at 16:06
  • I was able to fix it with this solution to a related problem: http://unix.stackexchange.com/a/237023/139097 – Pablo Machón Oct 18 '15 at 18:58

3 Answers3

5

Here is a workaround. It works on my emacs 23.1.1. This same question came up again (months later), and I'd learnt a bit about elisp in the mean time, so I had a go at it. See the following link for my answer there. Font size issues with Emacs in linum-mode.

Peter.O
  • 32,916
  • Could you check-mark your answer, or are you waiting for other answers? – Stéphane Gimenez Feb 13 '12 at 18:37
  • I'd be quite happy with another answer. The method works, but is really a workaround which has a couple of issues I'd rather it didn't have: like hard coding font size steps (it should tap into something more direclt, but I don't know what that is... and the bottom section doesn't refresh properly when jumping from large font size back to normal. Pressing any key causes a refresh, but there must be a better way (and again, I don't know how).. And it really doesn't address the original issue; that of the line-number column not changing its width in sync with the zoom scale. – Peter.O Feb 14 '12 at 04:20
4

The easiest, most straightforward solution I've seen just to set the line numbers to a fixed height. This can be accomplished easily, in accordance with user78810's answer: Font size issues with Emacs in linum-mode

To wit, add the following line in your emacs config (or to your dotspacemacs/user-config function, if you're spacing out evil style):

(eval-after-load "linum"
  '(set-face-attribute 'linum nil :height 100))
Shon
  • 161
  • 1
  • 8
2

Here's my solution. May want to change line-number face which used for display-line-numbers-mode to linum.

(defun post-text-scale-callback ()
  ;; fix line number text size
  (let ((new-size (floor (* (face-attribute 'default :height)
                            (expt text-scale-mode-step text-scale-mode-amount)))))
    (set-face-attribute 'line-number nil :height new-size)
    (set-face-attribute 'line-number-current-line nil :height new-size)))

(add-hook 'text-scale-mode-hook 'post-text-scale-callback)

ctietze
  • 103
  • 4
Tyler
  • 121