用pulse实现Emacs的淡入淡出效果
各种“现代”的IDE都会有一些眩的动画效果,那“土的掉渣”的Emacs有没有这样的功能呢?
去年在使用cedet的cvs版本的时候,我随便试了一下semantic的semantic-complete-jump-local,这个命令可以跳到当前文件的tag,我发现这个命令在跳到对应的tag后,竟然把那个tag对应的区域淡入淡出了一下,效果非常的眩。前阵子无聊,跟了一下那个命令的代码,最终发现这个效果是有cedet的pulse.el提供的,其实它的原理很简单,就是定时渐变一下颜色而已。我录了一段视频,来演示这个淡入淡出的效果,演示的主要是goto-line,semantic-complete-jump-local,switch-to-other-buffer的淡入淡出的效果,视频是用vnc2swf录制的,它需要你用vnc客户端连上服务器后,在里面操作,所以操作速度有点慢,视频里的淡入淡出效果不是很理想(如果哪位同志知道linux下有更好的视频录制工具,欢迎告诉我)。
pulse-momentary-highlight-one-line可以淡入淡出一行,pulse-momentary-highlight-region淡入淡出一个区域。pulse-toggle-integration-advice,可以使得goto-line,exchange-point-and-mark,find-tag等命令也加上淡入淡出的效果。
如果你想在你的程序里面使用淡入淡出效果,直接调用上面的pulse-momentary-highlight-one-line和pulse-momentary-highlight-region函数,也可以为你的命令增加advice,比如,
1 2 3 4 | (defadvice ido-switch-buffer (after pulse-advice activate) "Cause the current line of new buffer to pulse when the cursor gets there." (when (and pulse-command-advice-flag (interactive-p)) (pulse-momentary-highlight-one-line (point)))) |
这样每次切换到新的buffer后,都会淡入淡出当前行,说到这里,你是不是有点担心这可能会降低你的操作效率,不用担心,如果正在淡入淡出时,你按任何键都会终止这个效果,不会降低你的操作效率。
我的pulse配置在这里,配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ;; -*- Emacs-Lisp -*- ;; Time-stamp: <2010-02-25 19:35:15 Thursday by ahei> (require 'pulse) (defadvice exchange-point-and-mark-nomark (after pulse-advice activate) "Cause the line that is `goto'd to pulse when the cursor gets there." (when (and pulse-command-advice-flag (interactive-p) (> (abs (- (point) (mark))) 400)) (pulse-momentary-highlight-one-line (point)))) (defadvice switch-to-buffer (after pulse-advice activate) "Cause the current line of new buffer to pulse when the cursor gets there." (when (and pulse-command-advice-flag (interactive-p)) (pulse-momentary-highlight-one-line (point)))) (defadvice ido-switch-buffer (after pulse-advice activate) "Cause the current line of new buffer to pulse when the cursor gets there." (when (and pulse-command-advice-flag (interactive-p)) (pulse-momentary-highlight-one-line (point)))) (defadvice switch-to-other-buffer (after pulse-advice activate) "Cause the current line of new buffer to pulse when the cursor gets there." (when (and pulse-command-advice-flag (interactive-p)) (pulse-momentary-highlight-one-line (point)))) (defadvice visit-.emacs (after pulse-advice activate) "Cause the current line of .emacs buffer to pulse when the cursor gets there." (when (and pulse-command-advice-flag (interactive-p)) (pulse-momentary-highlight-one-line (point)))) (defadvice beginning-of-buffer (after pulse-advice activate) "Cause the current line of buffer to pulse when the cursor gets there." (when (and pulse-command-advice-flag (interactive-p)) (pulse-momentary-highlight-one-line (point)))) (pulse-toggle-integration-advice (if window-system 1 -1)) |
后记
更炫的Emacs动画效果请看用性感的尾巴highlight-tail标记最近的修改。

loading...
屏幕录像可以试试这个 http://recordmydesktop.sourceforge.net/
[回复]
ahei 回复:
二月 26th, 2010 at 1:30 上午
谢谢,我试试
[回复]
ahei 回复:
二月 26th, 2010 at 6:55 上午
@transtone, 我试了,这个软件确实不错,效率很高,不过它只能生成ogg格式的,而我找了半天没找到能把ogg转换成swf或gif格式的软件。
[回复]
so cool
[回复]
ahei 回复:
二月 26th, 2010 at 1:25 上午
谢谢!
[回复]
看看 higlight-tail
[回复]
ahei 回复:
二月 26th, 2010 at 1:45 上午
very good! 多谢! 人民群众的力量果然是非常强大! 我过会小小研究一下
[回复]
ahei 回复:
二月 26th, 2010 at 11:36 上午
@wd, 呵呵,我写了一篇文章介绍highlight-tail,用性感的尾巴highlight-tail标记最近的修改。
[回复]
在我的emacs23.1.1版本中使用这个功能在且换buffer或goto-line时会引起buffer中的所有文本行跳烁直到淡入淡出效果消失,但在22版本则没有问题。这中跳烁影响到了阅读文件,我现在只是简单把pulse关掉。
[回复]
wolfhuang 回复:
四月 22nd, 2010 at 4:23 上午
@wolfhuang, 系统是Debian 5.0
[回复]
ahei 回复:
四月 22nd, 2010 at 5:30 上午
@wolfhuang, 有一点点小闪烁,无所谓的,我的也有一点小小的闪烁,基本看不到的。
[回复]
wolfhuang 回复:
四月 24th, 2010 at 6:10 上午
@wolfhuang, 我的闪烁挺厉害的,我安装完了显卡驱动就不闪了,现在可以正常用pulse了。
[回复]
ahei 回复:
四月 24th, 2010 at 10:41 上午
@wolfhuang, 那就好
[回复]
你好,我已经迷失在你的网页中了,请问emacs可以实现阅读fortran代码的时候,当鼠标停在某个function上是自动提示这个函数的定义么?
[回复]
请教一下,为什么我在终端模式下没有淡出效果,然而在GUI中有呢?
配置里关于pulse的什么都没有配,只是一些绑定跳转的快捷键设置
[回复]
ahei 回复:
二月 19th, 2012 at 2:55 下午
@old_bear, 终端下就不具备这个能力阿
[回复]
ffmpeg -y -f x11grab -s 640×480 -r 10 -i :2.0+0+0 output.avi
[回复]
@cfy
ffmpeg -y -f x11grab -s 640×480 -r 10 -i :1.0+0+0 output.avi
ahei,这个抓取不错。我自己试过
[回复]
ahei 回复:
五月 12th, 2012 at 12:20 下午
@cfy, 谢谢推荐,这个命令是不错,但是录的都不太清楚啊,我用-r 65535试了,都不行
[回复]