Emacs安装和设置tabbar

点击打开链接


Emacs是用Buffer来组织编辑区域的,一个Buffer就代表一个文件或者一个临时编辑区域,我们可以用一些函数来切换到前一个或后一个Buffer,也可以列出所有的Buffer来进行选择。一些现代编辑器都支持一种特性,那就是Tab,用标签来列出所有的文件并可以方便地在文件之间切换,直观而方便。万能的Emacs当然也可以做到这个。

增加标签特性需要tabbar.el,emacswiki上可以下载到这个插件:

http://www.emacswiki.org/emacs/tabbar.el

放在任意目录并把这个目录添加到载入列表中,比如我们把tabbar.el放在~/.mylisp/下:

[python]  view plain copy print ?
  1. ;;main plugin path  
  2. (add-to-list 'load-path "~/.mylisp/")  
 

然后require这个插件并打开tabbar模式:

[python]  view plain copy print ?
  1. (require 'tabbar)  
  2. (tabbar-mode 1)  
 

进行一些快捷键设置:

[python]  view plain copy print ?
  1. (global-set-key [(meta j)] 'tabbar-backward)  
  2. (global-set-key [(meta k)] 'tabbar-forward)  
 

重新启动Emacs或eval-buffer就可以看到tabbar了:

 

 

默认的tabbar样式很难看,而且字体太小,不容易看清楚,我们接下来需要做的就是修改它的样式和配色。

下面使用一段网友菩提老祖给出的代码:

在.emacs下加入:

[python]  view plain copy print ?
  1. ;; 设置tabbar外观  
  2. ;; 设置默认主题: 字体, 背景和前景颜色,大小  
  3. (set-face-attribute 'tabbar-default-face nil  
  4.                     :family "DejaVu Sans Mono"  
  5.                     :background "gray80"  
  6.                     :foreground "gray30"  
  7.                     :height 1.0  
  8.                     )  
  9. ;; 设置左边按钮外观:外框框边大小和颜色  
  10. (set-face-attribute 'tabbar-button-face nil  
  11.                     :inherit 'tabbar-default  
  12.                     :box '(:line-width 1 :color "yellow70")  
  13.                     )  
  14. ;; 设置当前tab外观:颜色,字体,外框大小和颜色  
  15. (set-face-attribute 'tabbar-selected-face nil  
  16.                     :inherit 'tabbar-default  
  17.                     :foreground "DarkGreen"  
  18.                     :background "LightGoldenrod"  
  19.                     :box '(:line-width 2 :color "DarkGoldenrod")  
  20.                     :overline "black"  
  21.                     :underline "black"  
  22.                     :weight 'bold  
  23.                     )  
  24. ;; 设置非当前tab外观:外框大小和颜色  
  25. (set-face-attribute 'tabbar-unselected-face nil  
  26.                     :inherit 'tabbar-default  
  27.                     :box '(:line-width 2 :color "#00B2BF")  
  28.                     )  
 

 

现在我们的tabbar外观变成这样:

可以看出,已经几乎完成了,美中不足的是左边的几个按钮尺寸不正确,还需要修正。

打开~/.mylisp/tabbar.el,可以在里面找到类似这样的内容:

 

[python]  view plain copy print ?
  1. (defconst tabbar-home-button-enabled-image  
  2.   '((:type pbm :ascent center :data "/  
  3. P2  
  4. 10 10  
  5. 255  
  6. 184 184 184 184 0 184 184 184 184 184 184 184 184 0 0 0 184 184 184 184  
  7. 184 184 0 0 0 0 0 184 184 184 184 0 0 0 0 0 0 0 184 184 184 184 255 0 0  
  8. 0 255 255 255 184 184 0 0 0 0 0 0 0 184 184 184 184 0 0 0 0 0 255 255 184  
  9. 184 184 184 0 0 0 255 255 184 184 184 184 184 184 0 255 255 184 184 184  
  10. 184 184 184 184 184 255 184 184 184 184  
  11. "))  
  12.   "Default image for the enabled home button.")  
 

 

 

这部分就是设定home-button的图像,同样,另外几个按钮的图像也可以找到:

tabbar-home-button-disabled-image

tabbar-scroll-left-button-enabled-image

tabbar-scroll-left-button-disabled-image

tabbar-scroll-right-button-enabled-image

tabbar-scroll-right-button-disabled-image

 

这种图片的格式是pbm,pbm是Portable Bitmap Format(便携位图格式)的缩写,该系列共有三种格式:

PBM 位图黑白位图

PGM 灰度位图

PPM 带颜色的像素位图

文件的前两个字节指明了该文件到底属于哪种格式:

Magic Number 类型                编码

P1     Portable bitmap ASCII

P2     Portable graymap ASCII

P3     Portable pixmap ASCII

P4     Portable bitmap Binary

P5     Portable graymap Binary

P6     Portable pixmap Binary

如果编码是ASCII的话文件的内容就由直接可读的数字组成,数字之间用空格隔开。

我们修改后的tabbar高度变为20像素,宽度没变,减去原来的10像素那么上下分别加宽5像素。

也就是增加5 * 10 = 30个数字,5 * 10 = 10个数字。

修改tabbar里每个图片的数据块

P2保持不变,接下来的两个数字分别是宽度和高度,那么原来的"10 10"就要修改为"10 19",255为白色的值,保持为原来的255.然后在描述各个像素的数据前后分别加上50个184,保持和原来的颜色一样。

tabbar-home-button-enabled-image的那段就变为:

[python]  view plain copy print ?
  1. (defconst tabbar-home-button-enabled-image  
  2.   '((:type pbm :ascent center :data "/  
  3. P2  
  4. 10 20  
  5. 255  
  6. 184 184 184 184 184 184 184 184 184 184   
  7. 184 184 184 184 184 184 184 184 184 184   
  8. 184 184 184 184 184 184 184 184 184 184   
  9. 184 184 184 184 184 184 184 184 184 184   
  10. 184 184 184 184 184 184 184 184 184 184   
  11. 184 184 184 184 0 184 184 184 184 184 184 184 184 0 0 0 184 184 184 184  
  12. 184 184 0 0 0 0 0 184 184 184 184 0 0 0 0 0 0 0 184 184 184 184 255 0 0  
  13. 0 255 255 255 184 184 0 0 0 0 0 0 0 184 184 184 184 0 0 0 0 0 255 255 184  
  14. 184 184 184 0 0 0 255 255 184 184 184 184 184 184 0 255 255 184 184 184  
  15. 184 184 184 184 184 255 184 184 184 184  
  16. 184 184 184 184 184 184 184 184 184 184   
  17. 184 184 184 184 184 184 184 184 184 184   
  18. 184 184 184 184 184 184 184 184 184 184   
  19. 184 184 184 184 184 184 184 184 184 184   
  20. 184 184 184 184 184 184 184 184 184 184   
  21. "))  
  22.   "Default image for the enabled home button.")  
 
其他部分也照着这样修改就行了,最后的效果如图:

 


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值