| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1868 人关注过本帖
标题: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
快速回复:A bug(?) in linum mode and my resolution
数据加载中...
 
   



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

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