Sunday, December 10, 2006

30分钟快速上手Emacs (初级)

简介

没有听说过 Emacs 吗?没有关系,花上30分钟就能了解和熟悉这个古老而强大 的编辑器。他被很多人称作世界上最强大的编辑器。用户从无数高手到IT民工到 普通文本编辑器用户,可以符合几乎所有人的需求。甚至可以在 Emacs 里运行 音乐播放器、网页浏览器等等,Emacs 更像是一个操作平台。

使用 Emacs 可以完全抛弃鼠标,不必在打字的同时把手移开键盘找鼠标,不必在 一大堆深藏不露的菜单里寻找那些常用功能,也不必被一条条工具栏遮挡视线。 大多数的 Windows 编辑器都有一条菜单栏,n条工具栏。菜单里有无数选项,很 多选项都会弹出一个对话框,这个对话框又会带有层层叠叠的标签,每个标签里 又有很多输入框很多按钮。一个简单的把所有字母大写的命令就要在菜单里翻半 天,说不定还找不到,而他们的帮助信息又总是不知所云。而 Emacs 的大多数操 作都可以通过快捷键或直接输入命令完成,而且有着极好的帮助系统,可以通过 多种方式找到你想要的命令或按键。

不要被 Emacs 简单的外观和与众不同的操作方式迷惑,上手 Emacs 并不是什么 难事,看一遍 Tutorial 就可以了,Emacs23 已经带着多种语言版本的快速指南, 包括中文。仍然觉得 Tutor 太长?那可以继续看本文。

按键说明

首先说明一下,Emacs 的按键表示方法。最常用的是 Ctrl 和 Alt 的组合键, 分别用 C 和 M 表示,比如:

  • C-x 就是 Ctrl+x,
  • M-x 就是 Alt+x,
  • C-M-f 就是 Ctrl+Alt+f,
  • M-% 就是 Alt+%,实际上是 Alt+Shift+5
  • C-x C-f 就是 Ctrl+x 然后再按 Ctrl+f,中间可以一直按着 Ctrl 也可以松 开,无所谓间隔多长时间。

这样你就可以简单的用 C 和 M 表示 ctrl 和 alt 了。Shift 可以用 S 表示。

键盘上的特殊按键用<>表示,比如回车,空格,方向键上, 等等,一看就知道什么意思。

不必追究为什么把 alt 写为 M,因为你这次只有30分钟时间。

下载及安装

Windows 用户

Windows 用户可以去 http://ntemacs.sf.net 下载可执行文件或者源代码。建议 下载Emacs23.x 。这是一个 7zip 的自动解压缩包,解压到你喜欢的目录就可以 了。

到这里你大概用了5分钟,当然,下载和解压缩时间不算在内。:)

Linux 用户 (windows 用户可以忽略)

可以下载 CVS 的 Emacs 代码,编译一下就好了。下载 CVS Emacs23:

$ cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co -r emacs-unicode-2 emacs

编译:

$ cd emacs $ ./configure —enable-font-backend —with-xft —with-freetype —with-gtk

注意 configure 的输出,是否缺少什么东西,没有问题的话就可以 make:

$ make bootstrap

运行一下 src/emacs 如果没有问题的话就可以安装到默认路径:

$ sudo make install

常用命令

启动和退出

Windows 用户可以用 Emacs bin 目录下的 runemacs.exe 启动,Linux 用户键 入 emacs & 就可以了。

启动 Emacs 后应该能看到这个界面:

jasonal CVS Emacs 23 Emacs23 Startup GUI

退出 Emacs 按 C-x C-c (就是 Ctrl+x 接着按 Ctrl+c)。

打开和保存文件

启动 Emacs 后,按 C-x C-f,minibuffer (就是 Emacs 最下面一条) 会提示路 径,你可以在这里输入路径名和文件名,或者回车看到这个目录列表。可以 用方向键移动光标到文件名上回车打开文件,或者在子目录上进入子 目录,在 .. 上进入上一层目录。

打开文件后像往常一样编辑,随便按字母键输入一些字符。按 C-x C-s 保存文件。按 C-x k 回车关闭这个 buffer。

小结:按键说明

这里可以看到很多 C-x 开头的组合键,这些通常都是 Emacs 预先定义,全局性 的命令。按了 C-x 不动,一秒钟后 minibuffer 提示 C-x- ,表示 Emacs 正在 等待用户按下一个键。如果你想取消这次按键,可以接下去按 C-g,minibuffer 提示 C-x C-g is undefined 也就是说 Emacs 什么都没有执行。C-g 一般都是取 消命令,取消按键。如果按了 C-x C-h 就会出现一个帮助 buffer,里面是以 C-x 开头的按键帮助。C-h 是一个帮助按键。如何获得更多的帮助,会在之后的 小节介绍。C-c 开头的按键通常是用户自定义的按键和扩展包或扩展模式定义的 按键,同样也可以获得帮助信息。

选定区域,剪切、复制、粘贴

好了,到现在为止你大概一共花了 10 分钟吧。

你可以用鼠标拖选一块区域。当然,最好用键盘。按 C-@,minibuffer 提示 Mark set,设定了一个 mark。然后移动光标,这时候你就选定了光标和 Mark 之 间的区域。什么都看不到?你可以按 C-w,这块区域就消失了,C-w 是剪切。按 C-x u 可以撤销上一次的剪切,C-x u 是取消。你肯定想看到你到底选中了哪块 区域,可以按M-x 然后输入 transient-mark-mode ,回车。这次你就可以看到你 选中了哪块区域了。M-x 是执行 Emacs 命令。

【插播广告】如果是德语键盘,在 Windows 下很可能按不出 C-@, 而 C-又被输入法占去了。所以最好自己设定 set-mark 的按键。比如把 C-" 设为 mark 命令。按 C-: (ctrl-冒号) 输入下面这句话,然后回车:

(global-set-key (kbd "C-\"") 'set-mark-command)

可以在你的.emacs文件里加入类似的语句

【广告结束】

Emacs 有一个很有用的功能,在你选定了区域之后按 C-x C-x 可以交换光标 (point) 和 Mark 的位置,这样你就可以修改调整你选定的区域了。

按 C-g 取消选定的区域。

重新用 C-@ 选定一块区域,按 M-w,这是复制,移动光标到别处,按 C-y,这是 粘贴。紧接着再按一次 M-y,这时可以看到粘贴的内容变成了上一次剪切的内容。 再按 M-y 又变成之前一次复制的内容。

C-k 可以剪切一行。连续的 C-k 会把剪切的内容放在一起,一次 C-y 就可以把 之前的 n 行一起贴上。

C-x u 可以撤销,不过这个撤销和常规 windows 程序的撤销不太一样。按了 C-x u 撤销后,如果移动一下光标,再按一次 C-x u,可以撤销之前的撤销命令。 这样相当于是 redu。

小结:

  • C-@ 选定区域
  • C-w 剪切
  • M-w 复制
  • C-y 粘贴
  • M-y 粘贴剪贴板之前的内容
  • C-k 剪切一行
  • C-x u 撤销

查找

其他 windows 程序的查找通常会跳出一个对话框,这很讨厌,会遮住文本内容, 有时候我就会忘了我到底要找什么。Emacs 就不会这样。按 C-s 是查找, minibuffer 提示 I-search: 接下来你可以输入你要找的词,比如想找 windows, 输入 w,Emacs 开始找到 w,光标移动到 w 上,接着输入 i,Emacs 找到 wi, 并注意到Emacs 会同时高亮所有的 wi,接着输入 n,Emacs 找到 win,等等。这 就是 incremetal search,它的好处是,你想要找 windows,但实际上你只要输 入 win 就能定位到 windows 上了,不需要继续输入 dows 了。继续按 C-s 找下 一个匹配的。C-r 往回查找。按回车或者方向键结束本次查找,再按两次 C-s 重 复上次查找,按 C-g 取消查找,光标回到原处。

C-s 或 C-r 也可以用作光标定位,比如想要移到前面 Emacs 处,就可以 C-r Emacs,效率很高,可以说是指哪打哪。

如果查找输入的全是小写,那么这次查找是大小写不敏感的,如果输入字符中有 大写字母,那么这次查找就是大小写敏感的。很智能吧。

C-M-s 或 C-M-r 是正则表达式查找。或者在 C-s 之后按 M-r 也可以切换到正则 表达式查找。这里不仔细讲 Emacs 的正则表达式是怎么样的。那样会多花一个小 时。

替换

M-% 是 query-replace,输入查找内容和替换内容,然后 Emacs 会询问是否要 替换,y 替换,n 不替换,! 替换光标之后所有,q 结束,? 可以得到帮助。

Emacs 的替换有一个很好的特性,可以只在选定区域内进行替换。这样就可以放 心大胆地使用 ! 替换所用,而不用担心超出范围了。

C-M-% 是正则表达式的替换。

小结:

  • C-s 和 C-r 向前向后查找
  • C-% 替换
  • C-M-s 和 C-M-r 向前向后正则表达式查找
  • C-M-% 正则表达式替换

寻求帮助

到这里你用了大概20分钟,基本的文本编辑功能都有了。

接着你可以自己摸索了。

Emacs 提供了极其强大的帮助系统。

C-h t 是一个 tutorial,现在也有不同语言的 tutorial。按 M-x 输入 help-with-tutorial-spec-language 可以选择不同的语言。按 Emacs 可 以帮你补全命令。按两次 会有补全的提示。

C-h a 是 apropos command,你可以输入几个简单的单词,Emacs 可以帮你找到 相应的命令,这个帮助非常好用。比如你想把一个单词全部大写,但不知道该怎 么做,可以 C-h a 输入 upcase word 或者 up word,Emacs 就会找到几个命令, 其中一个是 upcase-word,并且对应的按键是 M-u,你只要把光标移动到单词前 按 M-u 就可以了。

C-h k 是描述某个按键会执行什么。例如你要看看 M-; 是干什么的,按 C-h k, 接着按 M-; 你就会看到 M-; 会运行 comment-dwim,dwim 是 do what i mean 的缩写,这个命令会注释或反注释你选定的区域,如果没有选定区域,会在这一 行后面加上注释。很聪明的命令吧。

C-h c 简单描述某个按键执行什么。

C-h f 描述某个函数

C-h v 描述某个变量

C-h 会提供很多很多帮助信息,C-h ? 会显示有哪些帮助信息。

简单配置

Emacs 有超强的可配置性,1000个人可以有1000种配置,可以有自己的键绑定, 有自定义的函数,有自己喜欢的扩展包。配置放在 home 目录下的 .emacs 里, Emacs 启动的时候会自动读取这个文件。启动 Emacs 后,C-x C-f ~/.emacs 会 打开 .emacs 文件,如果不存在的话就是新建这个文件。home 目录在哪里呢? 可以 M-x getenv home 得到 home 的位置。Linux 系统很好理解。 Windows 系统,会默认放在 C:\Documents and Settings\username\Application Data 下,有几种方法可以指定 home 的位置:

  • 在 我的电脑->属性->高级->环境变量 里添加一个 HOME 环境变量,指定位 置。
  • 在注册表 [HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs] (如果没有 GNU 或 Emacs,添加一个即可) 添加 HOME 字符串变量,值为指定的 home 路径。

Emacs 配置使用的语言是 Elisp,Emacs 附带非常详细的 Elisp 手册,可以通 过 M-x info 得到。配置 .emacs 一般只需要几个简单语句,比如:

  • (setq variable-name value) 设置变量值,例如 (setq transient-mark-mode t) 设置选定区域范围高亮
  • (require 'extension) 安装一个扩展包。
  • (load "file-name") 使用一个 .el 文件
  • (global-set-key (kbd "C-c f") 'function-name) 全局自定义键绑定
  • (define-key dired-mode (kbd "j") 'dired-next-line) 局部键绑定,只在 dired-mode 起作用
  • (if ...) 一些简单的判断语句

这里提供一个简单的 .emacs 文件: quick.emacs.el

你可以把它复制到你的 home 目录下并改名为 .emacs 注意有个.

或者用 runemacs.exe -q -l quick.emacs.el 来指定 emacs 使用这个配置文件。

总结

到这里差不多就是30分钟吧,介绍一些文本编辑的基本操作。只是为了说明上手 Emacs 其实很简单,而且几乎每一样操作都有比普通 Windows 文本编辑器更好 的特性,比如可以任意调整已选定的区域,更好的复制粘贴机制,更好的撤销机 制,更好的 isearch 查找方式,可以在区域内替换,强大得多的帮助系统,没 有任何限制的扩展性。用了几天或几个星期后就会觉得其他的编辑是多么麻烦和 弱小。

相关链接:

Sunday, December 03, 2006

viper-mode in Emacs

Maybe you are disappointed at the cursor move around feature in Emacs and envy or miss the hjkl in vim.

But don't worry. There is a viper-mode in Emacs, which emulates vi behavioral in Emacs.
I have tried it. That is really attractive. It has added four states that are equivalent to VIM modes: Emacs-state, vi-state, insert-state and replace-state. Press C-z to toggle vi-state and emacs-state. Normally we don't need the Emacs-state when editing files, but it's still necessary for the major modes like info- and dired-mode that has lots of its own key bindings. We have all the powerful emacs features in insert-state, and meanwhile can move around conveniently in vi-state as in VIM.

Here is the installation of viper-mode. In ~/.emacs , add following lines:

(setq viper-mode t)
(require 'viper)
The configuration of viper-mode is stored in ~/.viper , add following lines:

(setq-default viper-mode t
viper-expert-level '5
;; ex-style don't allow you to move cross lines.
viper-ex-style-editing nil
viper-ex-style-motion nil
viper-auto-indent t
viper-inhibit-startup-message t
viper-eletric-mode t
viper-always t
viper-want-ctl-h-help t
viper-want-emacs-keys-in-insert t
viper-want-emacs-keys-in-vi t
viper-vi-style-in-minibuffer nil
viper-no-multiple-ESC t
viper-case-fold-search t
viper-re-search t
viper-re-query-replace t
viper-syntax-preference 'emacs
viper-delete-backwards-in-replace t
viper-parse-sexp-ignore-comments nil
viper-ESC-moves-cursor-back nil)

(define-key viper-vi-global-user-map "\C-f" 'forward-char)
(define-key viper-vi-global-user-map "\C-b" 'backward-char)
(define-key viper-vi-global-user-map "\M-v" 'scroll-down)
(define-key viper-vi-global-user-map "\C-v" 'scroll-up)
(define-key viper-vi-global-user-map "\C-y" 'yank)
(define-key viper-vi-global-user-map "\C-e"
(or (command-remapping 'move-end-of-line) 'move-end-of-line))

;; I don't like the default face in viper minibuffer
(setq viper-minibuffer-vi-face nil
viper-minibuffer-emacs-face nil)
del.icio.us Tags:

Friday, October 27, 2006

Emacs font set for Windows

Emacs 字体设置 (win32)

Download fontset-win.el

只在我自己机器上的 Emacs 23 试验过,仅供参考

;; 预设了几种字体设置:
;; huangq-fontset-courier ;; Courier New + 新宋体
;; huangq-fontset-monaco ;; Monaco + 新宋体
;; huangq-fontset-lucida ;; Lucida Sans Typewriter + 新宋体
;; huangq-fontset-dejavu ;; DejaVu Sans Mono+ 新宋体
;; huangq-fontset-consolas ;; Consolas + 微软雅黑
;; huangq-fontset-consolas0 ;; Consolas + 新宋体

;; .emacs 字体设置:
;; (huangq-fontset-monaco 15)

;; 看累了切换字体:
;; M-x huangq-fontset-dejavu 或其他

;; 改变字体大小:
;; C-x s FONTSIZE

;; 当然字体文件要自己准备着

相关链接:
getting CVS emacs23
Emacs for windows 注册表配置
Strange fontset for Emacs23 (奇怪的Emacs23字体设置)


del.icio.us Tags:

Sunday, October 22, 2006

Browser comparison

浏览器比较

updated on 23.10.2006: Firefox 2.0 is now available: http://releases.mozilla.org/pub/mozilla.org/firefox/releases/2.0/

In a word, IE7 has the largest memory usage and can only block popup ads. Firefox 1.5.0.7 with Adblock and Greasemonkey performs much better. Firefox 2.0 is more expectable.

比较对象: Mozilla Firefox 1.5.0.7 , IE7.0.5370.11, Opera 9.02

Mozilla Firefox 装了 Adblock, Greasemonkey, Tab mix lite, Google toolbar, Gmail notifier, IE tab 等插件。
IE7 和 Opera 裸奔,使用默认配置。

用这三个浏览器分别打开5个网页: Live Space, www.sina.com.cn, espn.go.com, Google Reader, Google Mail.

资源消耗:
IE7 最多,物理内存和虚拟内存分别高达 190 Mbyte 和 175 Mbyte.
相比之下 Firefox 和 Opera 则要小得多。
Opera 物理内存和虚拟内存分别是 102 Mbyte 和 106 Mbyte.
Firefox 物理内存和虚拟内存分别是 76 Mbyte 和 75 Mbyte.
见图(点击放大)
browser comparison

广告拦截能力:都能拦截弹出窗口。
Firefox 装了 Adblock 和 一个专门拦截新浪广告的user script, 可以截杀页面上的所有 Flash 和 js 广告。
Opera 和 Firefox 一样,由于天生的不兼容性,能够避免大部分 IE 专用的广告。
IE7,浮云,页面内所有广告都能准确显示。。。

结论:继续使用 Firefox !


del.icio.us Tags:

Thursday, October 19, 2006

XKeymacs

XKeymacs - 推荐给 Win32 下的 Emacser

可以在大多数的 Windows 程序里使用 Emacs 的键绑定,比如在 Word 里用 M-t 交换两个单词,用C-x C-s 保存文件。

可以很方便的禁用或编辑某个快捷键,比如在 Firefox 里仍然用 C-t 开新 tab。

Windows 里的全新体验,很有趣。如果觉得操作不习惯,可以在任何时候 C-q 禁用 XKeymacs.

下载地址:http://www.cam.hi-ho.ne.jp/oishi/indexen.html

又是一个日本人的软件,日本人对 Emacs 的热情和贡献真是挺大的。
del.icio.us Tags:

Friday, September 29, 2006

Trick in query-replace-regexp

使用 query-replace-regexp 的小技巧

query-replace-regexp C-M-%

eg. a). delete a blank line

C-M-% ^\s-* C-q C-j [RET][RET]

^ means beginning of a line.
\s- means any white space.
C-q C-j is to insert a new line in the minibuffer. Likely wise, you can use C-q C-i to insert a TAB, etc.
Note, there should be no space between "^\s-*" and "C-q C-j" in the this example!

eg. b). Insert a series of continued number in the beginning of each line.

C-M-% ^ [RET] \# [RET]

\# means the number of replacements, starting with zero.

eg. a). change (2) (3) (4) (5) ... into (4) (5) (6) (7) ...

C-M-% (\([0-9]+\)) [RET] (\,(+ \#1 2)) [RET]

\#1 means convert the match \1 into number. The match \1 is string by default.
\, followed by a lisp expression. So from here you can do almost whatever you want. Yeah!
del.icio.us Tags:

Monday, September 25, 2006

Have to abandon MSVDM for the second time

I love the virtual work space under linux X. I hoped the MSVDM (Microsoft virtual desktop manager) could do the same job as well. However, it let me down again.
The first time it is because it didn't work quite well with ATnote. This time I found it might have bugs in switching work spaces when using different wallpapers for different work spaces. Sometimes the wallpapers were gone. Plus, there are also bugs even in cooperating with Excel. The menu in excel is disappeared when switching to another desktop.
I hate this poor M$ tool.

Saturday, September 09, 2006

Wildcards in Microsoft Word compared with Regular Expressions

在Word里使用部分正则表达式

作为一套昂贵的字处理软件,Word里竟然不可用正则表达式,实在令人发指。不过他的查找替换里可以使用通配符(Wildcards),可以实现一部分的正则表达式功能。

例如:把所有email地址改写 mailto:xxx@gmail.com 的形式,可以用以下操作:
Ctrl-H
more
Use wildcards
Find what: ([a-zA-Z0-9.+_-]@\@[a-zA-Z0-9]@.[a-z]@)
Replace with: mailto:\1
然后替换就可以了。

一些常用的正则表达式(已含所有的 MS Word 可用的通配符)

含义 GNU grep GNU Emacs Perl MS Word
任何单个字符 . . . ?
符合其中的任一字符 [...] [...] [...] [...]
符合除此之外的任一字符 [^...] [^...] [^...] [!...]
子表达式 \(re\) \(re\) ( re) (re)
表达式重复多次 re\{...\} re\{...\} re{...} re{...}
表达式出现0或1次 re\? re? re?
表达式出现0或多次 re* re* re*
表达式出现1或多次 re\+ re + re+ re@
表达式出现0或1次(lazy mode) re?? re??
表达式出现0或多次(lazy mode) re*? re*?
表达式出现1或多次(lazy mode) re +? re+?
单词起始 \ < \< <
单词结尾< /td> \> \> >
单词边界(起始或结尾) \b \b \b
非单词边界 \B \B \B
任意字符串 .* .* .* *
行首 ^ ^ ^
行末 $ $ $
换行符 \n C-q C-j \n ^13
”或“ re\|re re\ |re re|re
引用上次找到的内容 不知道 \& 不知道 ^&
引用被括号捕获的内容 \digit \digit \digit \digit

** 注:re 代表一个正则表达式 (RegExp)
*** MS Word里多次匹配,最少是一次,没有0次。
*** \digit 指 \后面加数字 如 \1 \2
*** 正则表达式里括号子表达式可以嵌套使用,Word里好像不行


del.icio.us Tags:

Tuesday, August 01, 2006

code-publish.el for MSN space

(for Emacs)
This is my first elisp program. It can convert program codes into html with font style and color format. The html codes can be pasted directly onto Microsoft Live Space (MSN Space).

Version 0.2:
Add background color.
Related link: http://jasonal.spaces.live.com/blog/cns!E9B3AD00B7B35ECC!1446.entry
Download: code-publish.v0.2.el

Version 0.1:
Screenshots here: test code
click here to download code-publish.el


del.icio.us Tags:

Thursday, July 27, 2006

Shortcuts, Hotkeys

* Hot-keys, Shortcuts, 快捷键

** HoeKey

占用内存非常小,只有几百K。用HoeKey可以方便地用快捷键运行一些常用程序。另外一个牛X的用处是执行一些特殊操作,比如最小化窗口,总在最前,窗口透明等等。
Example:

~F4=Transparency ; Win+F4 Set current window to be
=AlwaysOnTop ; transparent and on top

~32=Run|D:\Program Files\Mozilla Firefox\firefox.exe|3
; Win+Space Start Firefox maximized

~34=Msg||274|61472 ; win+PageDown minimize current window


Screen-shot:


** Run

Windows自带的Win+R。msconfig, regedit这些当然是最常用的了。此外还可以通过设置环境变量的方法极大的扩充win+R的功能,也就是把link加入Path里。比如把Quick Launch加入到Environment Variable的PATH里,快速启动里面的东西就可以全部用Win+R执行了。还可以另外搞个目录,加到PATH里,目录里面放
些自己喜欢的快捷方式,可以是程序,文档,图片,文件夹等等。


** TC (Total Commander)

除了在wincmd.ini的[Shortcuts]里面定义快捷键之外,还可以利用Start Menu和Hotlist。

比如用指定的编辑器(e.g. gvim)打开光标所在的文件:

screen-shot:

- 先加一个子目录(Add submenu) "&Open with..." &amp;amp;amp;amp;O意思是此条对应键名是O
- 再在此目录下加入条目(Add Item) "&Vim"
- 条目对应的命令(Command)是gvim的可执行文件
- 命令参数(Parameters): %P%N. %P是光标所在的目录路径,%N是光标所在的文件名。所有能用的参数都可以在Help里找到。
- OK

这样在TC里看到一个文件后,按Alt-s o v 就可以用gvim打开这个文件了。有点像Emacs的按键风格,哈哈。

再比如利用Hotlist运行常用程序:

screen-shot

方法基本同上,设置Hotlist是Ctrl-d c,运行Xygwin就是Ctrl-d x x 了。


** Firefox

利用收藏夹的别名实现快速搜索。

Screen-shot:

例如在维基百科里搜索可以这样定义:
- Name: 随意
- Location: http://zh.wikipedia.org/wiki/Special:Search?search=%s
- Keyword: wc

这样只要在地址栏里输入 wc firefox 就可以快速定位到维基百科的Firefox页.

** TypeAndRun

刚开始用的,感觉还不错,只是占用内存5M以上,不是很爽。在Settings->Registry 选中 Shell integration ("Add TypeAndRun..."context menu),在右键菜单里增加一个 Add TypeAndRun,把选中的程序或文档或目录等等添加到它的别名里。如果连鼠标右键也不想动,可以在TC的StartMenu里添加一个条目,Command是TypeAndRun的可执行文件,参数是 --add=%P%N

** AutoHotKey

一种Script语言,相比HoeKey复杂点,功能更强大,占用内存4M左右,大了一点。想要用的话看他的Wiki。

PS: 参考多篇文章,不一一说明出处了。只要google一下软件名就能找到相应的网站

Monday, July 17, 2006

Free Linux CDs


TheLinuxStore.ca 正在进行一项新的计划,将 Linux和开源软件传送到全世界。你将可以免费获得你所喜欢的Linux光盘包括SUSE, Fedora, Mandriva, Gentoo, Debian, Knoppix。其他的软件(当然是开源的)也可以写上。当然愿意的话你也可以捐助几美元来获取它。

Related links:
solidot新闻


del.icio.us Tags:

Wednesday, June 28, 2006

500GHz! Developed by IBM

An unbelievable speed of 500GHz!!!

When cooled to -268.5C, using liquid helium, it is able to perform a speed of 500 GHz! Even at room temperature they can be running at 350 GHz.

Other than standard silicon chips, these chips are manufactured using Si-Ge technology.

Germanium is already added to the silicon chips used in mobile phones to make them operate more efficiently.

Adding the element allows chips to run faster and use less power. Importantly, they can also be fabricated using existing silicon techniques.

The team believes it is possible to make chips run at 1,000 Ghz, or one Terahertz, at room temperature.

OK. After some digging. This is a transistor which can be switched at 500GHz. It could probably be used in RF usage. The largest advantage is it uses SiGe. This technology is relative cheaper than others in high frequency transistor.

Related Links:
http://news.bbc.co.uk/1/hi/technology/5099584.stm

del.icio.us Tags:

Sunday, June 18, 2006

Strange fontset for Emacs23

奇怪的Emacs23字体设置

sourceforge
下载了最新的预编译Emacs23 for Windows。这个版本应该是支持Unicode,中文GBK字库。但是用了原先Emacs22的设置,却不能显示所有的GBK汉字,比如“镕”,显示为一个方框。
后来在newsmth上找了一下,必须把中文字体设置为新宋体,用以下代码:

(create-fontset-from-fontset-spec
"-outline-Courier New-normal-r-*-*-17-97-96-96-c-*-fontset-chinese")
(set-fontset-font
"fontset-default" nil
"-outline-新宋体-*-r-*-*-20-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-chinese" 'kana
"-outline-新宋体-*-r-*-*-20-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-chinese" 'han
"-outline-新宋体-*-r-*-*-20-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-chinese" 'cjk-misc
"-outline-新宋体-*-r-*-*-20-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-chinese" 'symbol
"-outline-新宋体-*-r-*-*-20-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-default-font "fontset-chinese")

但是发现直接把这段写在.emacs里不起作用,启动后必须重新编译这段代码才行。相当诡异,因为其他人只要直接这样设置就可以了。难道是因为XP英文系统就不行吗?

后来再次试了一下,把这段字体设置写入fontset.el,然后在.emacs里load就可以了,需要注意的是,必须在设置了语言环境之后再load。有可能XP中文的默认语言环境已经是chinese-gbk了,所以就可以直接设置字体?


(add-to-list 'load-path "~/emacs.configuration")
(setq w32-charset-info-alist
(cons
'("gbk" w32-charset-gb2312 . 936) w32-charset-info-alist))
(set-w32-system-coding-system 'chinese-gbk)
(set-keyboard-coding-system 'chinese-gbk)
(set-language-environment 'chinese-gbk)
(setq locale-coding-system 'chinese-gbk)
(setq current-language-environment "Chinese-GBK")
(set-selection-coding-system 'chinese-gbk)
(set-language-environment 'chinese-gbk)
(setq current-language-environment "Chinese-GBK")

(load "fontset")

使用Courier New 17号和新宋体20号,字体看起来都比较大,不费眼力,而且汉字的宽度正好是字母的两倍。

相关链接:


del.icio.us Tags:

improvement for dired-single

改进一下dired-single返回上层目录的功能

Improvement for going back to parent directory (using dired-single).

在.emacs里改一下dired-single设置代码:
(require 'dired-single)
(define-key dired-mode-map (kbd "RET") 'joc-dired-single-buffer)
(define-key dired-mode-map (kbd ".")
;; type . to go back to the parent directory
'(lambda ()
(interactive)
(let ((current-dir (dired-current-directory)))
(joc-dired-single-buffer "..")
(dired-goto-file current-dir))))

按.返回上层目录,光标停留在原先的目录名上。
del.icio.us Tags:

Monday, June 12, 2006

Emacs ido.el

The ido.el is now a default elisp package in Emacs 23. You can get the newest version from CVS.
Use following elisp to enable ido-mode:

(require 'ido)
(ido-mode t)


Typing C-x C-f will run ido-find-file. There are some advantages, the files can be found more quickly. However, the ido-cache will not be refreshed automatically when directories are modified. There are some useful commands.
C-d to enter dired.
C-l to run ido-reread-directory to refresh the current work directory.
C-j to stop automatically completing file names. For example, you have "test.01" and "test.02" in your work directory, but you want to create a new file "test" instead of finding "test.01" or "test.02". Then you should type C-j after inputting "test", to run ido-select-text.
Or C-f to return to normal find-file.
Tab or ? to show completion help.

Don't use ido-mode to find files on ftp server, since that is quite slow and requires to type user name and password. And similarly don't search files in other directories. Add following codes into .emacs :


;; use normal find-file function for ftp files
(setq ido-slow-ftp-host-regexps '(".*"))
;; don't search files in other directories
(setq ido-work-directory-list-ignore-regexps '(".*"))


del.icio.us Tags:

Saturday, May 20, 2006

Vim tip: arrow keys print ABCD?

VIM 方向键在编辑状态下是ABCD?

I have just build vim7 and found weird when i pressed arrow keys in the Insert mode, the cursor didn't move but printed A, B, C and D. And the -- INSERT -- doesn't show up.

As soon as I introduced the ~/.vimrc, although with no contents in this file, the problem disappeared (under ubuntu).

for more information:
Arrow keys/cursor movement prints A B C D letters


del.icio.us Tags:

Saturday, May 13, 2006

How to port uClinux kernel to MicroBlaze

MicroBlaze uClinux Project by John Williams, University of Queensland
Mailing list

Now I have successfully boot uclinux kernel on my Spartan3E-Starter-Kit (XC3S500E-4FG320C) with EDK 8.1 sp2.
A useful tutorial by Jason Wu: uClinux ready Microblaze design. However, the information in the tutorial and on John Williams' Website is not updated for new boards and new tools.

Here is my steps for spartan 3E:

1. Getting uClinux BSP

2. Build an EDK project

... to be continued...

Wednesday, May 10, 2006

Strange gmail address

古怪精灵的Gmail地址

1. Suffix
abc@googlemail.com=abc@gmail.com
这个很早就发现了,最初申请的google帐号是gmail.com后缀,后来申请的后缀是googlemail.com,(据说gmail商标在欧洲被注册了?), 但实际上这两个邮箱地址是通用的。

2. plus
abc@gmail.com=abc+123@gmail.com=abc+abc@gmail.com
在邮箱地址后可以用加号加上仍和英文或者数字。这样可以便于邮件分类。不过有些地方认为+是非法邮件地址,不能被用于注册。

3. dot
abc.xyz@gmail.com=abcxyz@gmail.com
万一少打或者错加了几个点也毫无关系。handy

Any more tips or tricks? Tell me please!


del.icio.us Tags:

Monday, May 08, 2006

Install Firefox 1.5 on Ubuntu

在ubuntu上安装或升级Firefox

Firefox不能用apt-get install来安装(bt, 为什么不行)。所以要从Mozilla.com上下载Firefox. 由于编译的gcc版本不同,导致这个Firefox和中文输入法SCIM有冲突。wiki.ubuntu.com上推荐下载源码并重新编译Firefox。我试过之后发现启动Firefox的时候,提示缺少一个库,有错误产生。

在Ubuntu中文wiki上倒是有很好的解决方法
译注:由于scim可能导致使用libstdc++5的GTK程序出现"段错误",如果出现新装的firefox1.5无法运行,可修改 export GTK_IM_MODULE="scim"为GTK_IM_MODULE="xim" 来绕过,这句一般在/etc/X11/Xsession.d/95xinput中.(catinsnow)

安装完后的配置极其方便,只要把windows里的配置文件(C:\Documents and Settings\user_name\Application Data\Mozilla\Firefox\Profiles\xxxxxxxx.default)直接复制到Linux里就可以了(~/.mozilla/firefox/profiles)。所有的收藏夹、扩展、及其配置全部都有了,甚至包括原先保存的密码。当然复制之前可以先清除cookie减小体积。



del.icio.us Tags:

用MEMS来冷却芯片

用MEMS来冷却芯片

Source: eetimes

基于MEMS的微型冷却器件,推动冷却液,小到可以蚀刻在芯片上。恩,不错的想法。


del.icio.us Tags:

Sunday, May 07, 2006

getting CVS Emacs 23

If you don't have CVS installed, install one:
$ sudo apt-get install cvs

Checkout the latest cvs version, the unicode-2 branch:
$ cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co -r emacs-unicode-2 emacs

Preparing for compile. Install all dependencies:
$ sudo apt-get build-dep emacs21
Compile:
$ cd emacs
$ ./configure --enable-font-backend --with-xft --with-freetype --with-gtk
$ make bootstrap

Try to run src/emacs, if there is no problem,
$ sudo make install
That's all.

I've encounted such error during the ./configure:

checking for gtk+-2.0 >= 2.4 glib-2.0 >= 2.4... no
Package gtk+-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gtk+-2.0' found
configure: error: Library requirements (gtk+-2.0 >= 2.4 glib-2.0 >= 2.4) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.

Solution:

$sudo apt-get install libidl-dev
$sudo apt-get install libgtk2.0-dev
Now there's no conflict to use scim in Emacs under gnome.
However, if emacs is started with --enable-font-backend I still can't use scim.

If you are under Windows and so lazy as me, download the latest Emacs23 for win32 (binary and/or source) from here:
http://ntemacs.sourceforge.net/

last update on 2006-11-01
del.icio.us Tags:

Friday, May 05, 2006

干掉和重建Grub

干掉和重建Grub

装了ubuntu,Grub是装在MBR的。有一次从Windows XP休眠,再次开机后就无法进入Windows,情况是:在Grub list 选择Windows,然后回到Grub list。进入ubuntu没有问题。

当时手头有张Win XP恢复盘(德语),比较土,以前没有用过。从光盘启动后,没有任何停顿,没有任何选项,开始嘎叽嘎叽地安装了。新的Windows是装在D盘的。我不想有两个XP,安装过程中强行关机了。再次开机后只有windows自己的boot list了。选了老的那个,直接把D的windows目录删除,再把C盘下的boot.ini改成只有C盘的Windows。重启后一切正常,只不过开机过程中的语言成了德语。比较郁闷,这个语言是在哪里改的?

用ubuntu安装盘重装Grub。没有Suse的recovery那么简单。
  • 在boot提示行输入rescue
  • 之后就好像要重新安装ubuntu一样,选择语言、地区、键盘等。
  • 然后是配置网络,设置主机名,这些都可以随便设。
  • 然后出来一个分区表,选择原先的ubuntu分区,格式是 dev/discs/disc0/partX. X是1到n,可以一个个试过来,如果不是linux分区,会有错误提示,然后返回。选择linux分区之后进入# 命令行。
  • 输入 # grub-install /dev/sda 重装Grub,有些机器是/dev/hda (?)。
  • 之后有个警告,可以去 /boot/grub/device.map 查看原先是把grub装在哪里的。
  • 最后 # exit,重启,Grub菜单又回来了。
整个过程不到10分钟。

后来又重试了几次,发现windows休眠后的重启仍然正常。又试了一下fdisk /MBR,对于windows启动来说是绝对安全的。比较BT的是,用XP安装盘的恢复模式进入DOS命令行(实际上不是dos?)没有fdisk这个命令。要fdisk /MBR 只能用其他的dos启动盘。
del.icio.us Tags:

Thursday, May 04, 2006

一些Linux应用程序

一些Linux应用程序

来源:王垠的《完全用Linux工作& 处理日常事务的 Linux 程序和它们的配置
  • Shell: bash。它结合了 csh 和 ksh 的优点,并且有 readline 功能,你可以随意绑定自己的键盘。
  • 编辑器: VIM, Emacs。
  • 程序开发: GCC, make, ld, Scheme48, j2sdk, Perl, Python, Tcl/Tk ...
  • 论文,幻灯工具:LaTeX, ConTeXt
  • 绘图工具:MetaPost。这个语言太强了,以至于我只用它了。你不熟悉的话可以用xfig, dia 来画一些流程图之类的图片。
  • 图像处理:ImageMagick。其中的 import 程序可以屏幕抓图,convert 程序可以转换图像格式,display 可以显示图片和简单编辑(缩放,换质量,转格式,简单绘图,简单虑镜)。通常我就这么点需要。如果你要更强大的图像工具可以用 Gimp, 它几乎和Photoshop差不多。
  • 自动管理工具:make。我可以用make来自动编译程序,自动编译文档,自动更新插图…… 全自动,而且不会重复劳动。
  • 数值计算程序:SciLab。这个程序基本上可以代替 Matlab。
  • 代数计算程序:MAXIMA。这个程序基于世界上最老的计算机代数系统之一: 由美国能源部(DOE)发行的 MIT Macsyma 系统。它是用 Common Lisp 实现的。很多现在的符号计算程序比如 Maple 都从 MAXIMA 身上学到很多东西。它现在经过 DOE 批准以GPL发行,永远是一个自由软件。
  • 加密程序:GnuPG。我的 PGP 密钥就是它搞出来的。
  • 打包,压缩程序。什么都有: tar, gzip, bzip2, zip, rar, ...
  • 虚拟光驱程序。Linux 不需要虚拟光驱程序,直接 mount 就行了。
  • ftp 服务器:proftpd, vsftpd。proftpd 功能很强,但是我只用了最简单的一种设置。
  • WWW 服务器:apache。(我一般没有开)
  • ftp 客户程序:lftp,ncftp。它们都是文本方式操作的,但是比起图形界面的方便的多。比如 lftp 几乎具有 bash 的所有方便功能,Tab 补全,bookmark, queue, 后台下载,镜像…… Linux 也有图形界面的 ftp 客户程序,但是大多不稳定,有很多问题。这就是很多人抱怨 Linux 不如 Windows 的一个小原因。还有很多人用 Wine 模拟 Windows 的leapftp,其实 lftp 比 leapftp 好很多,你需要的只是适应一下。
  • 自动下载工具:wget。它非常稳定,有一次我下载一个程序,用 IE 和 Mozilla 下载回来的文件都是坏的,最后还是 wget 可靠的传输了数据。用它甚至可以镜像整个网站,比起WebZip 这样的 Windows 程序强多了,而且不会因为你不付钱就在下载回来的网页里强制插入广告。
  • 虚拟终端:rxvt, xterm, gnome-terminal, mlterm, ...
  • X server: XFree86
  • 窗口管理器:FVWM。编译加入了 libstroke。
  • 中文输入:XSIM。被我修改过以适应 FVWM 的需要。另外推荐你还可以用 SCIM。
  • email 处理:Mutt + Postfix + fetchmail
  • 看 PDF, PS, DJVU 文件:Acrobat Reader, xpdf, GhostScript, gv, djvu工具包和netscape 插件。
  • 看CAJ文档。我从来不看CAJ之类的文档,如果找不到PDF或PS,直接去图书馆借最好。
  • 看网页:Mozilla, Phoenix, lynx。Mozilla-Xft 的显示效果比IE 好很多。
  • 英汉字典:IBM智能词典,星际译王。
  • 编辑网页:我用VIM 直接写 HTML。你如果想要图形方式的可以用其它的比如screem, BlueFish。
  • 登录其它 UNIX, Linux 机器:openSSH, telnet。 我喜欢用 openSSH 把其它机器的X 程序通过 ssh 加密的隧道传到我机器上显示。
  • 登录 Windows2000 server 的 display service: rdesktop,...我有一天试了一下,不错。后来就没有用过了。
  • 同步程序:rsync。我用 rsync 通过 ssh 来跟某些机器同步数据,或者做自己机器上不同目录间的同步。
  • 上BBS:rxvt(或任何一种终端) + telnet + chatbot(helloooo 机器人的程序)
  • QQ, ICQ: 我没有 QQ 或 ICQ。不过你可以用 Gaim, 它同时支持 QQ, ICQ 和很多其它的即时通信方式。ICQ 用户也可以用 Licq。
  • 放录像:MPlayer, RealPlayer。MPlayer 太好了,直接就可以放 VCD, DVD, divx, wma, wmv ... 用 Windows 的同学都很羡慕我,说 Windows 要放这个需要大堆插件。rm 最好还是用 realplayer 放,它也是免费的。
  • 放音乐: xmms(mp3,ogg都可以), mpg321(放mp3), ogg123(放ogg)。mpg321 不如xmms管理音乐文件那么方便,但是有时我还是用 mpg321 放 mp3 作为背景音乐,因为懒得开一个xmms窗口:-)
  • 游戏:我觉得 KDE 的那个 ksokoban(推箱子),很好玩 :-)
  • 看 Word 文档。请 Word 用户把文档全部转为 PDF 或 PS 再给我,文档里没有特殊的格式干脆就用文本吧,何必那么麻烦。以前很奇怪的是,通知里本来没有什么特殊的格式居然还要发doc附件的email。现在好 了,我们系发通知都用文本,PDF,甚至图片了。
  • 其它程序:还有很多我需要用而你不一定用得着的。比如,Doctor Scheme,
  • Scheme48, Scsh, kawa...这些程序只有 Doctor Scheme 有Windows版本。还有很多幕后工作但是你一般不察觉的:xinetd, telnetd, sshd, crond, atd, lpd, ... 他们都比 Windows 的对应者强的多,或者根本没有对应者。
后续
del.icio.us Tags:

Tuesday, May 02, 2006

Proxy setting for ubuntu 5.10 GUI Update Manager

Proxy setting for ubuntu 5.10 Update Manager:

Set proxies in Gnome "Network Proxy Setting", or in /etc/bash.bashrc, or /etc/wget.rc won't apply to Update Manager.
You had to put a line like this in /etc/apt/apt.conf

Acquire::http::Proxy "http://proxy.mydomain.com:8080"


In "Breezy Badger" you must edit apt.conf as follows:

Acquire
{
http::proxy "http://proxy.mydomain.com:8080"
}
del.icio.us Tags:

Saturday, April 29, 2006

关于ThinkPad飞线

关于联想ThinkPad飞线


相关报道:
ThinkPad T60现重大缺陷!主板居然飞线 (替代链接)
联想承认ThinkPad飞线 否认质量问题 (替代链接)

这个是联想ThinkPad T60(P)主板背面的飞线,X60上也有类似的飞线。ThinkPad竟然也有飞线,粗看着实吓了一跳。不过仔细分析的话,其实也不是什么大问题,对本本质量没有影响。

首先,这条线还是焊得比较精细的,而且用蜡封固定,走线方向也没有大问题,所以这条线本身不会出什么大问题。

其次更为重要的是,这条线到底是干什么的。

先看看这块芯片,Maxim 1540E,根据1540A/1541的Datasheet,此芯片是专用于笔记本电脑,提供0.7~5.5V电源电压,双PWM控制器。可输出两个电压,可用于DDR或其他低电压IC的供电。相当重要的哦。

根据Datasheet,这条飞线是第13个引脚,也就是PGOOD2,Open-Drain Power-Good Output。Function: PGOOD2 is low when the output voltage is more than 10% (typ) above or below the normal regulation point, during soft-start, and in shutdown. After the soft-start circuit has terminated, PGOOD2 becomes high impedance if the output is in regulation. 就是说当输出电压异常的时候这个引脚会变成低电平。否则是高阻态。有可能原先是悬空的,估计这条飞线让他接上一个上拉电阻,既没有大电流,也不是高频率,正常的时候变成高电平而不再是高阻。所以这个脚只是一个报错信号,平常是用不到的。即使出错了,也仍然会报错,即使没有这条线也没关系。

分析了一大通,就算剪掉这条线也没有关系。好像对面的PGOOD1也没有接上拉电阻,不过预留了电阻的空位。

顺便转一个forum.thinkpads.com的评论:
After a 30 year career with IBM, engineering changes to circuit boards were a way of life. When engineers design a circuit board, it is nearly impossible to foresee every condition that will ever be presented to that design. Therefore when that change is needed, the “yellow wire” is applied to the existing boards to allow their use in the production cycle. Hence engineering change numbers are applied to circuit boards, as they are manufactured, to show their level in the ongoing design process. In software or application development, this process is called “bug fixes” or “patches”, you could look at these changes as the “yellow wire” wire applied to programs. Frequently these corrections to code are added to enhancements, and called upgrades.



Tuesday, April 25, 2006

How to create an ISE project including an embedded submodule

Embedded Submodule Design Overview

Adding an Embedded Submodule to ISE

Top-down

Bottom-up

Creating an XPS Design as an ISE Submodule
Only the XMP file must be added as the source file. The BMM file should not be added to the ISE project.
Including an Embedded Submodule in Your Top-Level Design

And next...
del.icio.us Tags:

Emacs for windows 注册表配置

Emacs for windows 注册表配置

参考heriberaht@smth转发的Windows下Emacs启动时最大化设置步骤

Environment:Windows xp + emacs-version "22.0.50.1" (CVS20060320)

注:Sams 一书有这样一句
Any variable that the UNIX user can set with the Xdefaults file is one
that the NT Emacs user can set in the Registry.

Windows 下 Emacs 启动时最大化设置步骤
=====================================

1. 去掉 MenuBar/ToolBar/ScrollBar 查 Emacs 最大化时的 Geometry 参数
在 *scratch* 中输入 (frame-parameters (selected-frame)) C-j
其中有四个参数:(top + -4) (left + -4) (width . 111) (height . 39)
这里的宽和高每台机器的配置或许不同,字体改变后,这个两个值也会变化。我的Laptop上甚至得不到height的值。

2. 根据查到的参数设置注册表和 .emacs 文件
( width 和 height长宽可能要加 1,可以自行调试。如果把windows外观主题设为windows classic, 效果比较好)
(1) 注册表设置

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs]
"Emacs.Background"="Black"
"Emacs.Foreground"="Wheat"
"Emacs.ScrollBars"="OFF"
"Emacs.MenuBar"="OFF"
"Emacs.ToolBar"="OFF"
"Emacs.Geometry"="124x45+-4+-4"
"Emacs.Font"="-*-Courier New-normal-r-*-*-13-*-*-*-c-*-*-*"


设置 Emacs.Font 避免启动时窗口有一个由小到大的变化过程,字体串取自 .emacs
中 (create-fontset-from-fontset-spec ...) 相应设置,如下第一行。
这段没有测试过
(create-fontset-from-fontset-spec
"-*-Bitstream Vera Sans Mono-normal-r-*-*-15-*-*-*-c-*-fontset-most,
chinese-gbk:-*-宋体-normal-r-*-*-18-*-*-*-*-*-gbk*-*,
chinese-gb2312:-*-宋体-normal-r-*-*-18-*-*-*-*-*-gb2312*-*,
chinese-cns11643-5:-*-宋体-medium-r-*-*-18-*-*-*-*-*-gbk*-*,
chinese-cns11643-6:-*-宋体-medium-r-*-*-18-*-*-*-*-*-gbk*-*,
chinese-cns11643-7:-*-宋体-medium-r-*-*-18-*-*-*-*-*-gbk*-*,
korean-ksc5601:-*-Batang-normal-r-*-*-18-*-*-*-c-*-ksc5601.1987*-*,
chinese-big5-1:-*-宋体-normal-r-*-*-18-*-*-*-*-*-big5*-*,
chinese-big5-2:-*-宋体-normal-r-*-*-18-*-*-*-*-*-big5*-*,
japanese-jisx0208:-*-MS UI
Gothic-medium-r-*-*-18-*-*-*-*-*-jisx0208*-*" t)



(2) 设置 .emacs 文件(可以不设,设了可使 C-x 5 2 开 Frame 也最大化)
(setq default-frame-alist
(append '((top + -4)(left + -4)(width . 124) (height . 45))
default-frame-alist))
del.icio.us Tags:

Xilinx EDK Error and solution (1)

最近在用xilinx EDK 8.1i (embedded design kit),又叫 XPS(xilinx platform studio)。期间遇到一些错误及解决方法,顺手记录下来。

ERROR:
In function ‘write’: undefined reference to 'outbyte' or in function ‘read’: undefined reference to ‘inbyte’

Solution:
Define peripheral as standard-out and standard-in by using the Software Platform Settings dialog box.

FATAL_ERROR:Xst:Portability/export/Port_Main.h:127:1.16 - This application has discovered an exceptional condition from which it cannot recover.

Solution:
Delete an unused GPIO instance.

ERROR:Place:207 - Due to SelectIO banking constraints, the IOBs in your design cannot be automatically placed.

Solution 1:

Modify the IOstandard in FPGA Editor and run BitGen without the DRC check (bitgen -d).

Solution 2:

Some pins are not defined. Define all used ports in Project_Dir\data\system.ucf. The complete ports definition is in the EDK directroy: D:\EDK\board\Xilinx\boards\... It is an xbd file. Here I am using a xilinx eva-board, for other boards or customized boards the definition file may be different.






del.icio.us Tags:

Monday, April 24, 2006

Emacs 一些常用包

Emacs 一些常用包

参考newsmth.net的emacs版,bethoven@smth的windows下使用Emacs

1. mule-gbk
用于中文编码,直接复制里面的.el文件就可以用了。
参见这里
emacs 23 就不需要这个包了。不过据说现在23版本还有很多Bug, 而且没有正式的预编译版本,所以暂时先搁着了。

2. wdired
用于在dired模式下直接修改文件或目录名(默认配置按r)
下载wdired.el到%HOME%/site-lisp/
在.emacs添加:
(require 'wdired)
(autoload 'wdired-change-to-wdired-mode "wdired")
(define-key dired-mode-map "r"
'wdired-change-to-wdired-mode)


3. color-theme
很多漂亮的配色主体。我现在用gnome2感觉挺舒服的。下载
(require 'color-theme)
(color-theme-gnome2) ;; change the theme here


4. cygwin-mount
windows下Emacs最好配合cygwin使用,这样就能用ediff(文件比较)这样的功能了。
参见这里

5. ido
加强c-x c-f(find file)和c-x b(切换buffer)功能。由于备选文件和备选Buffer存在Cache里,所以切换Buffer和寻找文件非常迅速。有点像i-search那样,只要输入文件名的一部分就能找到文件了。按方向键或者C-s, C-r可以在ido-find-file切换匹配的Buffer或文件名。
(require 'ido)
(ido-mode t)

用了ido后有一些“副作用”,比如回去访问过的ftp上找匹配的文件名,这样会很慢,解决方法看这里

6. ibuffer
加强c-x c-b (buffer list)的功能,用起来和目录差不多, 按 g 刷新
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(autoload 'ibuffer "ibuffer" "List buffers." t)

7. dired-single
只产生一个dired buffer.
(require 'dired-single)
(define-key dired-mode-map (kbd "RET") 'joc-dired-single-buffer)
(define-key dired-mode-map (kbd ".")
'(lambda ()
(interactive)

(joc-dired-single-buffer "..")))

副作用是回上层目录不能选..了,只能另找个按键代替,这里用了"."
刚改进了一下dired-single返回上层目录的功能,返回上层目录后光标停在原先的目录名上。

8. midnight
自动整理Buffer. 到午夜会自动关闭一些很久不用的buffer。

9. rect-mark
矩形操作或者说列操作。使用方法在rect-mark.el里有。基本上就是C-x r + 常规区域操作。

10. gnuserv/gnuclient
可以让emacs代替notepad了。
参见这里
如果使用TC的话可以用ChoiceEditor把文本文件绑定到gnuclientw.exe上。就可以非常方便地用F4启用Emacs了。
更新 2007/3/20:
最新的NT Emacs 22 和 23 已经带了 emacsclient.exe 和 emacsclientw.exe,所以gnuserv就不用装了。使用方法是,在~/.emacs里加上这些:
(server-start)
;;退出的时候删掉server文件
(add-hook 'kill-emacs-hook
(lambda()
(if (file-exists-p "~/.emacs.d/server/server")
(delete-file "~/.emacs.d/server/server"))))
用emacsclientw.exe打开文件的方法是:
d:\Emacs\bin\emacsclientw.exe -f "d:\Emacs\home\.emacs.d\server\server" -n -a "d:\Emacs\bin\runemacs.exe" path\to\file
11. w32-browser
在windows里相当好用。
加上下面几句:
(require 'w32-browser)
(eval-after-load "dired"
'(define-key dired-mode-map [f4] (lambda ()
(interactive)
(w32-browser
(dired-replace-in-string
"/" "\\"
(dired-get-filename))))))


在dired浏览文件时只要按F4就能用对应的windows程序打开文件了。
del.icio.us Tags:

Emacs 常用快捷键

Emacs 常用快捷键

Emacs的快捷键都是绑定于ctrl和alt(或称meta)上的,例如c-x就是ctrl+x,m-x就是alt+x.
当然所有的按键都可以自定义。

常用的帮助按键:
c-h a : 查询一个命令
c-h c : 查询一个按键
c-h t : Tutorial
m-x customized-group RET ... 自定义模式
m-x describe-... RET 各种各样的帮助信息


光标操作:
m-< : 光标到buffer头 m-> : 光标到buffer尾
m-a : 光标到前一
m-e : 光标到后一
c-up : 光标到前一
c-down : 光标到后一
c-left 或 m-left : 光标到前一个词
c-right 或 m-right : 光标到后一个词

常用按键:
c-g : 取消当前命令或者按键

文件操作:
c-x c-f : 打开文件或目录
c-x c-s : 保存当前文件
c-x c-w : 当前文件另存为
c-x u : undo

剪切操作:
c-spc : 选定区域,建议自行绑定此键,因为和windows的ctrl+space冲突。
c-x h : 全选
m-w : 复制
c-w : 剪切
c-y : 粘贴 (handy for german keyboard :)
m-y : 粘贴剪贴板前一项内容
c-k : 剪切一行

查找和替换:
c-s : 向后寻找 (i-search)
c-r : 向前寻找(i-search)
m-% : 查找并替换

窗口操作:
c-x l : 显示文件(buffer)总行数
c-x 1 : 当前窗口最大化
c-x 2 : 上下两窗口模式
c-x 3 : 左右两窗口模式
c-x 0 : 关闭当前窗口(Buffer仍然存在)
c-x o : 切换窗口

Buffer操作:
c-x b : 切换buffer
c-x c-b : buffer 列表
c-x k : 关闭buffer
g : 刷新目录(dired)或者buffer列表

编码操作:
c-x RET r : 改变当前buffer的编码
c-x RET f : 改变保存当前文件所使用的编码

几个好用的自定义按键:
(global-set-key [(meta g)] 'goto-line) ;; m-g 跳到某一行
(global-set-key [(ctrl tab)] 'kill-this-buffer) ;; c-tab 关闭当前buffer
(global-set-key [(ctrl c) (ctrl c)] 'comment-or-uncomment-region) ;;c-c c-c区域注释或取消注释
(global-set-key [(meta r)] 'eval-buffer) ;; m-r 执行buffer中的lisp代码
(global-set-key [(ctrl <)] 'set-mark-command) ;; c-< 选定区域

dired操作尚在研究中,据说可以有替代TC的可能。

ps:
Emacs是什么? Emacs是世界上最强大的编辑器,但他不仅仅是编辑器,Emacs是一种生活方式。
世界上有三种人,一种使用 Emacs,一种使用 vi,另一种包括其他所有人。wakaka



del.icio.us Tags:

Startup with Blogger

之所以用Blogger是想换换环境,之前一直用msn space的。
注册了之后发现国内原来是上不了blogspot.com的,郁闷。后来google了很久,原来可以找个免费空间当载体,把Blogger当作一个发布器。
具体方法可以见这里:玩转Blogger 或者 妖精の翼
免费ftp空间我找的是 3000mb.com, 大概有3G吧,短期内肯定足够用了。使用ftp发布的坏处就是发文非常慢。

之后的一个问题是tag. 用过Gmaildelicious之后越来越喜欢这个功能了。而这个大名鼎鼎的Blogger竟然默认是没有标签的,虽然space也没有标签,但至少也有目录功能嘛。不过既然是用户最多的blog,那网上的大牛们肯定早有解决方法了吧。
我现在采用的方法是: Firefox + GreaseMonkey + delicious. 步骤如下:
1. 使用Firefox并安装插件GreaseMonkey,重起Firefox.
2. Install user script 2182,重起Firefox.
3. 申请一个del.icio.us帐号.
4. 登陆Blogger,settings->formatting->show link field,yes.
5. 现在可以发文了,或者编辑原来的Blog,在标题下方会多出一栏Tags,单击Tags可以设定标签栏的名称,默认的标签名,和将要加入del.icio.us的帐户名。
6. 发表文章,上传完毕后会多一个links at del.icio.us,单击这里跳出del.icio.us的提示窗口,文章链接、标题、发表时间、标签等都已经设好,直接save即可。


Sunday, April 23, 2006

Getting started from here

这个Blog将作为我的学习笔记。
有一些上手比较难的工具,比如Emacs,曾经有段时间用得比较熟,隔了两三个月基本没用后,就几乎全忘了。这时候感觉到有个学习笔记还是很有用的。
恩,这里就这样开始吧。



del.icio.us Tags: