A bug(?) in linum mode and my resolution
A bug(?) in linum mode and my resolution;; Author: zklhp
;; QQ: 493165744 Email: zklhp*At*
When I use linum mode, I find that the left margin seems to be fixed even the text is scaled.
This seems to be a bug because in linum mode the width of left margin is decided like this.
(setq width (max width (length str)))
To solve this bug I prefer to defadvice linum-update-window. Here is my work.
程序代码:
(defadvice linum-update-window (after fix-scale-bugs (win) activate compile) "fix the bug when scale text" (interactive) (if (memq 'text-scale-mode minor-mode-list) (progn (let ((width (car (window-margins win)))) (setq width (ceiling (* width (expt text-scale-mode-step text-scale-mode-amount)))) (set-window-margins win width (cdr (window-margins win))) ;; (message "%d" width) ) ) ) )
上面那个有warning 稍微改了下
程序代码:
(defadvice linum-update-window (after fix-scale-bugs (win) activate compile) "fix the bug when scale text" (interactive) (if (memq 'text-scale-mode minor-mode-list) (progn (let ((width (car (window-margins win)))) (defvar text-scale-mode-step) (defvar text-scale-mode-amount) (setq width (ceiling (* width (expt text-scale-mode-step text-scale-mode-amount)))) (set-window-margins win width (cdr (window-margins win))) ) ) ) )
[ 本帖最后由 zklhp 于 2012-10-27 22:04 编辑 ]