标题:A bug(?) in linum mode and my resolution
取消只看楼主
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
结帖率:100%
 问题点数:0 回复次数:1 
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 编辑 ]
搜索更多相关主题的帖子: max win resolution because decided 
2012-10-23 19:56
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
得分:0 
以下是引用madfrogme在2012-10-23 20:13:23的发言:

原来如此,今天学了4招,试了一下,果然管用,版主威武

举一反三 真是我们学习的榜样啊。。
2012-10-23 20:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-383900-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.873376 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved