Emacs text-scale-adjust causes line numbers column to incrementally shrink and disappear

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

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

Method 3

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)


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x