help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UI glitch with text-scale-increase / text-scale-decrease with linum


From: Gauthier Segay
Subject: Re: UI glitch with text-scale-increase / text-scale-decrease with linum / nlinum
Date: Mon, 9 Feb 2015 18:22:25 +0100

Hey, that works!

Thanks

On Mon, Feb 9, 2015 at 6:01 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> I disabled my theme/font settings (to ensure it doesn't interfere),
>> patched the file, recompiled the extensions, but I still notice the
>> same issue happening.
>
> Duh!  I diff'd the wrong file.  Here's the patch I had tested.
>
>
>         Stefan
>
>
> diff --git a/packages/nlinum/nlinum.el b/packages/nlinum/nlinum.el
> index 82e274c..67b3717 100644
> --- a/packages/nlinum/nlinum.el
> +++ b/packages/nlinum/nlinum.el
> @@ -1,6 +1,6 @@
>  ;;; nlinum.el --- Show line numbers in the margin  -*- lexical-binding: t -*-
>
> -;; Copyright (C) 2012, 2014  Free Software Foundation, Inc.
> +;; Copyright (C) 2012, 2014, 2015  Free Software Foundation, Inc.
>
>  ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
>  ;; Keywords: convenience
> @@ -54,6 +54,7 @@ Linum mode is a buffer-local minor mode."
>    :lighter nil ;; (" NLinum" nlinum--desc)
>    (jit-lock-unregister #'nlinum--region)
>    (remove-hook 'window-configuration-change-hook #'nlinum--setup-window t)
> +  (remove-hook 'text-scale-mode-hook #'nlinum--setup-window t)
>    (remove-hook 'after-change-functions #'nlinum--after-change t)
>    (kill-local-variable 'nlinum--line-number-cache)
>    (remove-overlays (point-min) (point-max) 'nlinum t)
> @@ -63,6 +64,7 @@ Linum mode is a buffer-local minor mode."
>      ;; FIXME: Another approach would be to make the mode permanent-local,
>      ;; which might indeed be preferable.
>      (add-hook 'change-major-mode-hook (lambda () (nlinum-mode -1)))
> +    (add-hook 'text-scale-mode-hook #'nlinum--setup-window nil t)
>      (add-hook 'window-configuration-change-hook #'nlinum--setup-window nil t)
>      (add-hook 'after-change-functions #'nlinum--after-change nil t)
>      (jit-lock-register #'nlinum--region t))
> @@ -71,14 +73,24 @@ Linum mode is a buffer-local minor mode."
>  (defun nlinum--face-height (face)
>    (aref (font-info (face-font face)) 2))
>
> +(defun nlinum--face-width (face)        ;New info only in Emacs>=25.
> +  (let ((fi (font-info (face-font face))))
> +    (when (> (length fi) 11)
> +      (let ((width (aref fi 11)))
> +        (if (<= width 0)
> +            (aref fi 10)
> +          width)))))
> +
>  (defun nlinum--setup-window ()
>    (let ((width (if (display-graphic-p)
>                     (ceiling
> -                    ;; We'd really want to check the widths rather than the
> -                    ;; heights, but it's a start.
> -                    (/ (* nlinum--width 1.0
> -                          (nlinum--face-height 'linum))
> -                       (frame-char-height)))
> +                    (let ((width (nlinum--face-width 'linum)))
> +                      (if width
> +                          (/ (* nlinum--width 1.0 width)
> +                             (frame-char-width))
> +                        (/ (* nlinum--width 1.0
> +                              (nlinum--face-height 'linum))
> +                           (frame-char-height)))))
>                   nlinum--width)))
>      (set-window-margins nil (if nlinum-mode width)
>                          (cdr (window-margins)))))
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]