Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am using Emacs 23. linum-mode works well if using with default settings.

But if I increase the font size, the numbers cannot be displayed. It seems the the frame to display the line numbers is not increased as the font size of the line number increases.

Anyone know how this can be fixed?

share|improve this question
1  
Annoying, isn't it... I posted a similar question a while back... Emacs text-scale-adjust causes line numbers column to incrementally shrink and disappear ... There has been no resolution yet, though Gilles thinks it is a bug in the implementation ... Maybe someone can pick up on it here.... –  Peter.O Jan 24 '12 at 2:44

2 Answers 2

up vote 2 down vote accepted

Here is a work-around which works well enough on my setup, but my emacs knowledge is rather limited, and I'm not sure how it will behave in someone else's setup, but here it is:

Because the line number column does not change width while the font size does change, the approach I've taken is to prevent the line-number's font size from becoming any wider than its column.

I haven't find a way (ie. a function) to determine the necessary height of the line-number column for a particular scale, so I've built a list based on empirical data from a rather standard emacs. The list is scaled relative to text-scale-mode-step = 1.04 ... Also, text-scale-mode-amount needs to be initalized, because it seems to only be triggered by text-scale functions, but is needed as 0 for a firs-time calculation by the workaround function.

EDIT: Zoom-Out now scales properly, but I'm stil looking for a better way to assess/control the line-number column's font height, so if someone has any ideas about it, I'd appreciate hearing about it.

;; This script is set for a `text-scale-mode-step` of `1.04`
(setq text-scale-mode-step 1.04)
;;
;; List: `Sub-Zoom Font Heights per text-scale-mode-step`  
;;   eg.  For a default font-height of 120 just remove the leading `160 150 140 130` 
(defvar sub-zoom-ht (list 160 150 140 130 120 120 110 100 100  90  80  80  80  80  70  70  60  60  50  50  50  40  40  40  30  20  20  20  20  20  20  10  10  10  10  10  10  10  10  10  10   5   5   5   5   5   2   2   2   2   2   2   2   2   1   1   1   1   1   1   1   1   1   1   1   1))
(defvar sub-zoom-len (safe-length sub-zoom-ht))
(defvar def-zoom-ht (car sub-zoom-ht))
(set-face-attribute 'default nil :height def-zoom-ht)

(defun text-scale-adjust-zAp ()
   (interactive)
   (text-scale-adjust 0)
   (set-face-attribute 'linum nil :height def-zoom-ht)
 )
(global-set-key [C-kp-multiply] 'text-scale-adjust-zAp)

(defun text-scale-decrease-zAp ()
   (interactive)
   (if (not (boundp 'text-scale-mode-amount)) ;; first-time init  
              (setq  text-scale-mode-amount 0))
   (setq text-scale (round (/ (* 1 text-scale-mode-amount) 
                                   text-scale-mode-step)))
   (if (> text-scale (- 1 sub-zoom-len))
       (progn
         (text-scale-decrease text-scale-mode-step)
         (if (<= 0 text-scale-mode-amount)
             (set-face-attribute 'linum nil :height def-zoom-ht)
           (if (> 0 text-scale-mode-amount)
               (set-face-attribute 'linum nil :height 
                                     (elt sub-zoom-ht (- 0 text-scale)))))))
)
(global-set-key [C-kp-subtract] 'text-scale-decrease-zAp)

(defun text-scale-increase-zAp ()
   (interactive)
   (if (not (boundp 'text-scale-mode-amount)) ;; first-time init  
              (setq  text-scale-mode-amount 0))
   (setq text-scale (round (/ (* 1 text-scale-mode-amount) 
                                   text-scale-mode-step)))
   (if (< text-scale 85)
       (progn
         (text-scale-increase text-scale-mode-step)
         (if (< (- 0 text-scale-mode-step) text-scale-mode-amount)
             (set-face-attribute 'linum nil :height def-zoom-ht)
           (if (> 0 text-scale-mode-amount)
               (set-face-attribute 'linum nil :height 
                                     (elt sub-zoom-ht (- 0 text-scale)))))))
)
(global-set-key [C-kp-add] 'text-scale-increase-zAp)


;; Zoom font via Numeric Keypad
(global-set-key [C-kp-multiply] 'text-scale-adjust-zAp)
(global-set-key [C-kp-subtract] 'text-scale-decrease-zAp)
(global-set-key [C-kp-add]      'text-scale-increase-zAp)

;; Zoomf font via Control Mouse Wheel
(global-set-key (kbd "<C-mouse-4>") 'text-scale-increase-zAp)
(global-set-key (kbd "<C-mouse-5>") 'text-scale-decrease-zAp)
share|improve this answer

You can just define the linum size in your init config so it doesnt depend on default-face:

(set-face-attribute 'linum nil :height 100)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.