首页 > Elisp, 中级, 好玩的 > 用pulse实现Emacs的淡入淡出效果

用pulse实现Emacs的淡入淡出效果

2010年2月25日 ahei 发表评论 阅读评论

各种“现代”的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标记最近的修改

分享家:Addthis中国
GD Star Rating
loading...
用pulse实现Emacs的淡入淡出效果, 9.6 out of 10 based on 8 ratings 标签:ahei, buffer, CEDET, cursor, DEA, ede, Emacs, highlight, highlight-tail, IDE, linux, lisp, org, pulse, semantic, vi, 淡入淡出, 配置, 配色, 配色, 颜色

相关日志

分类: Elisp, 中级, 好玩的
  1. transtone
    2010年2月25日23:24 | #1

    屏幕录像可以试试这个 http://recordmydesktop.sourceforge.net/

    [回复]

    ahei 回复:

    谢谢,我试试

    [回复]

    ahei 回复:

    @transtone, 我试了,这个软件确实不错,效率很高,不过它只能生成ogg格式的,而我找了半天没找到能把ogg转换成swf或gif格式的软件。

    [回复]

  2. meteor1113
    2010年2月26日01:04 | #2

    so cool

    [回复]

    ahei 回复:

    谢谢!

    [回复]

  3. 2010年2月26日01:37 | #3

    看看 higlight-tail

    [回复]

    ahei 回复:

    very good! 多谢! 人民群众的力量果然是非常强大! 我过会小小研究一下

    [回复]

    ahei 回复:

    @wd, 呵呵,我写了一篇文章介绍highlight-tail,用性感的尾巴highlight-tail标记最近的修改

    [回复]

  4. wolfhuang
    2010年4月22日04:21 | #4

    在我的emacs23.1.1版本中使用这个功能在且换buffer或goto-line时会引起buffer中的所有文本行跳烁直到淡入淡出效果消失,但在22版本则没有问题。这中跳烁影响到了阅读文件,我现在只是简单把pulse关掉。

    [回复]

    wolfhuang 回复:

    @wolfhuang, 系统是Debian 5.0

    [回复]

    ahei 回复:

    @wolfhuang, 有一点点小闪烁,无所谓的,我的也有一点小小的闪烁,基本看不到的。

    [回复]

    wolfhuang 回复:

    @wolfhuang, 我的闪烁挺厉害的,我安装完了显卡驱动就不闪了,现在可以正常用pulse了。

    [回复]

    ahei 回复:

    @wolfhuang, 那就好

    [回复]

  5. lxping
    2011年7月2日19:36 | #5

    你好,我已经迷失在你的网页中了,请问emacs可以实现阅读fortran代码的时候,当鼠标停在某个function上是自动提示这个函数的定义么?

    [回复]

  6. old_bear
    2012年2月19日13:49 | #6

    请教一下,为什么我在终端模式下没有淡出效果,然而在GUI中有呢?
    配置里关于pulse的什么都没有配,只是一些绑定跳转的快捷键设置

    [回复]

    ahei 回复:

    @old_bear, 终端下就不具备这个能力阿

    [回复]

  7. cfy
    2012年5月11日22:37 | #7

    ffmpeg -y -f x11grab -s 640×480 -r 10 -i :2.0+0+0 output.avi

    [回复]

  8. cfy
    2012年5月11日22:38 | #8

    @cfy
    ffmpeg -y -f x11grab -s 640×480 -r 10 -i :1.0+0+0 output.avi
    ahei,这个抓取不错。我自己试过

    [回复]

    ahei 回复:

    @cfy, 谢谢推荐,这个命令是不错,但是录的都不太清楚啊,我用-r 65535试了,都不行

    [回复]

  1. 2010年3月19日05:26 | #1
  2. 2010年4月26日07:23 | #2
  3. 2011年7月16日22:18 | #3
:wink: :-| :-x :twisted: :) 8-O :( :roll: :-P :oops: :-o :mrgreen: :lol: :idea: :-D :evil: :cry: 8) :arrow: :-? :?: :!: