(defun wc ()
"a simple mimic of the linux command `wc`"
(interactive)
(message "Word count: %s"
(how-many "\\w+"
(or (and (region-active-p) (region-beginning)) (point-min))
(or (and (region-active-p) (region-end)) (point-max)))))
2008-12-16
a native simple wc in Emacs Lisp
I googled "count words emacs" and read several articles, "Counting words in Emacs" and "Emacs Tip: Word counting with a regular expression". The first uses a loop and a regular expression to count only words in a region, and the latter uses the emacs built-in function "how-many" to count words in the whole current buffer. So I combined them to the following `wc` function which count in the whold buffer when no region is active and in the region otherwise.
2008-11-07
A great alternative for OpenOffice, MS Office, the "永中Office"
永中Office, which is produced by this company called "Evermore Software"(www.evermoresw.com.cn) located in Wuxi, China, has announced its personal edition as free (as in free lunch), both for the Linux and the Windows platform, which you can download from here. Java is used to produce this software.
永中Office has a similar look as MS office and is almost 100% compitable with most of M$'s office document formats(In fact, Word, Excel and PPT). But it *CAN NOT* parse OpenOffice's ODF, which is sad news for the FOSS community.
This free(as in free lunch, again) personal edition offers functions to create word processing, electric table and slides documents.
The reason I switched from OpenOffice just now to 永中Office is that the later have a much more faster loading and processing speed than the former, although 永中Office is written using the same language as OpenOffice. Speed means time, which dominates.
PS: this software can't show its window and dialogs normally when compiz is running. But it can be fixed by editing the startup script which is usually "/usr/bin/eio" by changing it to:
Note the line
which is newly added to choose the correct AWT TOOLKIT when compiz is running, thanks to the post at here.
永中Office has a similar look as MS office and is almost 100% compitable with most of M$'s office document formats(In fact, Word, Excel and PPT). But it *CAN NOT* parse OpenOffice's ODF, which is sad news for the FOSS community.
This free(as in free lunch, again) personal edition offers functions to create word processing, electric table and slides documents.
The reason I switched from OpenOffice just now to 永中Office is that the later have a much more faster loading and processing speed than the former, although 永中Office is written using the same language as OpenOffice. Speed means time, which dominates.
PS: this software can't show its window and dialogs normally when compiz is running. But it can be fixed by editing the startup script which is usually "/usr/bin/eio" by changing it to:
#!/bin/bash
if test -n "$(grep "Ubuntu" /proc/version)"; then
export AWT_TOOLKIT=MToolkit
else
export AWT_TOOLKIT=XToolkit
fi
pidof compiz >/dev/null&& export AWT_TOOLKIT=MToolkit
exec 4<&0 0<&4 $line1/EIOffice.bin ${@:+"$@"} 2>/dev/null
Note the line
"pidof compiz >/dev/null&& export AWT_TOOLKIT=MToolkit"
which is newly added to choose the correct AWT TOOLKIT when compiz is running, thanks to the post at here.
2008-01-15
Switching from ubuntu to Arch linux
Because compared to ubuntu, arch linux is :
- lightweight.
- optimized for i686
- more faster to connect to its mirrors.
- lightweight.
- optimized for i686
- more faster to connect to its mirrors.
2007-10-13
emacs cvs unicode branch now supports multi-tty!
On 3rd, Oct, I saw on the emacs developing mailing list that RMS was calling for a merging of multi-tty in to emacs's unicode branch. Since then I have always been longing for that merging.
And now, it has come true! This morning I updated the source code and found a lot of patches and updates. I took a look at the src/Changelog.unicode, found there is a item saying:
I guess the multi-tty has been already merged successfully!
So I took a hurry to compile the newest src codes. And you can guess that, it succeeds! Now I'm running it.
PS: Does anyone knows about how to customize a single frame's color-theme?
And now, it has come true! This morning I updated the source code and found a lot of patches and updates. I took a look at the src/Changelog.unicode, found there is a item saying:
2007-10-12 Stefan Monnier
Fix up multy-tty merge.
I guess the multi-tty has been already merged successfully!
So I took a hurry to compile the newest src codes. And you can guess that, it succeeds! Now I'm running it.
PS: Does anyone knows about how to customize a single frame's color-theme?
2007-09-27
Trackerd in ubuntu gutsy causes emacs to repond slowly when saving files
The slow repondence of emacs saving files is really conspicuious when trackerd(tracker's daemon) is running in the background. After I kill the trackerd with the command "killall -9 trackerd", emacs just acts so briskly.
I think the possible reason is that trackerd is watching the files I'm editing in emacs. Thus, when I try to save the files I've updated, tracerd tries to update its index, and thus takes the computing resources, lackness of which makes emacs to stop respond(In compiz fusion, emacs would just turn into gray and can't be operated).
I have not taken the time to view how this part of trackerd's code is written. and I've not tested trackerd and emacs on other versions of ubuntu or other distroes yet.
I think the possible reason is that trackerd is watching the files I'm editing in emacs. Thus, when I try to save the files I've updated, tracerd tries to update its index, and thus takes the computing resources, lackness of which makes emacs to stop respond(In compiz fusion, emacs would just turn into gray and can't be operated).
I have not taken the time to view how this part of trackerd's code is written. and I've not tested trackerd and emacs on other versions of ubuntu or other distroes yet.
2007-09-24
字符集(charset)和字符编码(character encoding)的区别
from this post: http://www.thescripts.com/forum/thread214891.html
It's important to distinquish between characters (or charsets) and
character encodings. They are two different things. A charset is a map
that defines which numeric value represents a particular glyph. A
character encoding defines how numeric values are serialized into a
stream of bytes. For example Unicode can be encoded as UTF-8 which which
is space effecient and provides compatibility with the ASCII and ISO-8859-1
charsets. Or it could be encoded as UCS4-LE which is not space effient
but it can be easier to do heavy text processing with it.
Here's a nice link about programming with extended charsets although it
is a little UTF-8/*nix centric:
http://www.cl.cam.ac.uk/~mgk25/unicode.html
It's important to distinquish between characters (or charsets) and
character encodings. They are two different things. A charset is a map
that defines which numeric value represents a particular glyph. A
character encoding defines how numeric values are serialized into a
stream of bytes. For example Unicode can be encoded as UTF-8 which which
is space effecient and provides compatibility with the ASCII and ISO-8859-1
charsets. Or it could be encoded as UCS4-LE which is not space effient
but it can be easier to do heavy text processing with it.
Here's a nice link about programming with extended charsets although it
is a little UTF-8/*nix centric:
http://www.cl.cam.ac.uk/~mgk25/unicode.html
2007-09-23
[howto] gnome's file association
According to this post at http://forums.fedoraforum.org/showthread.php?t=26875 , sereral files affect the file associations.
Though that post targets gnome 2.8, I find that it's still the same for the newest gnome, that is gnome 2.20, after checking these files.
-> /usr/share/applications/defaults.list
This file contains the applications which cause a double-click success. All Mime types will point to a desktop file.
-> /usr/share/applications/[application_name].desktop
This is the file where "defaults.list" will point to. One of the most important things inside this file is the entry "MimeType=".
-> /usr/share/applications/mimeinfo.cache
Contains information in similar form shown for file "defaults.list" in same directory. This file contains ALL associations given to a mime type. There is no need for a specified order of desktop files (see XMMS example lateron)
-> /usr/share/mime (Directory)
This directory contains several information. The sub-directories - excluding packages - contain information about given mime types. You'll see that many mime types already exist.
The packages directory contains the DATABASE calles freedesktop.org.xml!
-> /usr/share/mime/globs
This file contains the file extensions, associated to the mime-types.
Though that post targets gnome 2.8, I find that it's still the same for the newest gnome, that is gnome 2.20, after checking these files.
-> /usr/share/applications/defaults.list
This file contains the applications which cause a double-click success. All Mime types will point to a desktop file.
-> /usr/share/applications/[application_name].desktop
This is the file where "defaults.list" will point to. One of the most important things inside this file is the entry "MimeType=".
-> /usr/share/applications/mimeinfo.cache
Contains information in similar form shown for file "defaults.list" in same directory. This file contains ALL associations given to a mime type. There is no need for a specified order of desktop files (see XMMS example lateron)
-> /usr/share/mime (Directory)
This directory contains several information. The sub-directories - excluding packages - contain information about given mime types. You'll see that many mime types already exist.
The packages directory contains the DATABASE calles freedesktop.org.xml!
-> /usr/share/mime/globs
This file contains the file extensions, associated to the mime-types.
2007-09-05
终于知道为什么install-keymap不行了
关键字:/etc/console/boottime.kmap.gz
我重新映射更改console(/dev/tty*)的ctrl和caps,于是按照install-keymap来弄,但是不行。
在配置文件里digg半天以后,发现ubuntu默认用的是console-setup,于是上面的boottime.kmap.gz是不会起作用的(即使用install-keymap)来更新。然后去看/etc/default/console-setup这个文件,发现我成功remap了ctrl和caps的机器上的配置是:
XKBMODEL="pc104"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="ctrl:swapcaps"
而没有成功的机器上的是
XKBMODEL="pc104"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""
这就是问题了。。
我重新映射更改console(/dev/tty*)的ctrl和caps,于是按照install-keymap来弄,但是不行。
在配置文件里digg半天以后,发现ubuntu默认用的是console-setup,于是上面的boottime.kmap.gz是不会起作用的(即使用install-keymap)来更新。然后去看/etc/default/console-setup这个文件,发现我成功remap了ctrl和caps的机器上的配置是:
XKBMODEL="pc104"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="ctrl:swapcaps"
而没有成功的机器上的是
XKBMODEL="pc104"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""
这就是问题了。。
2007-08-31
2007-06-28
debian下mysql server的一个问题的解决
如果出现
那么这时候可以去/etc/mysql/debian.cnf,找到里面的password
然后登录到mysql shell:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '' WITH GRANT OPTION;
mysql> flush priviledges;
七中的就是上面找到的password
然后
$sudo /etc/init.d/mysql restart
看看:)
$sudo /etc/init.d/mysql start
Starting MySQL database server: mysqld . . ..
Checking for corrupt, not cleanly closed and upgrade needing tables..
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'
那么这时候可以去/etc/mysql/debian.cnf,找到里面的password
然后登录到mysql shell:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '
mysql> flush priviledges;
七中的
然后
$sudo /etc/init.d/mysql restart
看看:)
2007-06-21
It's really amazing
The fantastic Compiz and Beryl have been merged and a new project named "Compiz fusion" has been set up at http://www.opencompositing.org.
I've just installed Compiz fusion on my ubuntu feisty box according to this guide. The first impression it gives hits me! It's unbelievably fast than beryl!
Here is a screenshot of its expo plugin:
I've just installed Compiz fusion on my ubuntu feisty box according to this guide. The first impression it gives hits me! It's unbelievably fast than beryl!
Here is a screenshot of its expo plugin:
2007-01-18
linux下ogg/mp3 id3tag
很多ogg或者mp3的id3tag是用gbk或者gb2312编码的。
而rhythmbox里gstreamer调用libid3tag去解析音频文件的tag。但是libid3tag只会做iso-8859->unicode的转换,于是,无论本来的id3tag是用什么编码的,libid3tag都以为使用iso-8859编码的,于是在非英语地区,就不爽了。
于是今天用mutagen里面的mid3iconv把id3tag乱码的音频文件都给转换到了utf-8。在rhythmbox里搜索、浏览、播放都舒服多了。
另外,有些音频文件根本就没有id3tag。这个时候也许可以试试看easytag。easytag支持多种格式的音频文件,包括MP3, MP2, MP4/AAC, FLAC, Ogg Vorbis, MusePack and Monkey's Audio files。而且支持从文件名匹配信息到id3tag,比如01_title.ogg,就可以用%n_%t来匹配,这样这个文件id3tag里的track就是01,而title就是title了。
而rhythmbox里gstreamer调用libid3tag去解析音频文件的tag。但是libid3tag只会做iso-8859->unicode的转换,于是,无论本来的id3tag是用什么编码的,libid3tag都以为使用iso-8859编码的,于是在非英语地区,就不爽了。
于是今天用mutagen里面的mid3iconv把id3tag乱码的音频文件都给转换到了utf-8。在rhythmbox里搜索、浏览、播放都舒服多了。
另外,有些音频文件根本就没有id3tag。这个时候也许可以试试看easytag。easytag支持多种格式的音频文件,包括MP3, MP2, MP4/AAC, FLAC, Ogg Vorbis, MusePack and Monkey's Audio files。而且支持从文件名匹配信息到id3tag,比如01_title.ogg,就可以用%n_%t来匹配,这样这个文件id3tag里的track就是01,而title就是title了。
2006-10-01
如何修改linux的console的分辨率
修改/boot/grub/menu.1st
找到kernel /boot/vmlinuz root=/dev/hda1 ro这行
在ro后面加上vga=xxx
这个xxx请参考下面的表
depth-----640x480----800x600----1024x768-----1280x1024
8bit----------769----------771-----------773------------775
15bit--------784----------787-----------790------------793
16bit--------785----------788-----------791------------794
24bit--------786----------789-----------792------------795
转载自http://linux.hiweed.com/node/1787
找到kernel /boot/vmlinuz root=/dev/hda1 ro这行
在ro后面加上vga=xxx
这个xxx请参考下面的表
depth-----640x480----800x600----1024x768-----1280x1024
8bit----------769----------771-----------773------------775
15bit--------784----------787-----------790------------793
16bit--------785----------788-----------791------------794
24bit--------786----------789-----------792------------795
转载自http://linux.hiweed.com/node/1787
2006-09-25
beta|alpha|unstable life
比如现在用的是ubuntu edgy;emacs是23;gaim是beta;compiz当然也就是unstable;nvidia driver是9625。
于是问题就来了。compiz其实还好,不过就是在alt+tab切换窗口的时候,scim容易出问题:候选词表不出来,这个时候或者就真的只能盲打,或者改变scim的配置,让它reload一下,一般都会好。
edgy现在alt+ctrl+F1不能切换到console,ft。不过在另外一台机器上,同样的系统,同样升级,就可以。不过这个也就忍了,好歹还可以ssh过来。
emacs嘛,中文的xft渲染还是很差。6月份有段时间co出来的代码倒是对中文字体的支持很好。不过后来一直到现在都不行。然后偶尔还会因为把;错输入为:,然后C-h(我重新绑定了这个键组合),就会没有响应,然后试图C-g,那么,恭喜我自己,马上X crash。
gaim对google talk的字体设置支持不错,可是msn account的字体就不行,没法放大,看着很难受,费眼睛。来消息了的声音提示有时候有,有时没有。不过,据说gaim2.0会支持qq,所以co一个,正在编译。
所以估计系统的不稳定是上面诸多原因的综合
于是问题就来了。compiz其实还好,不过就是在alt+tab切换窗口的时候,scim容易出问题:候选词表不出来,这个时候或者就真的只能盲打,或者改变scim的配置,让它reload一下,一般都会好。
edgy现在alt+ctrl+F1不能切换到console,ft。不过在另外一台机器上,同样的系统,同样升级,就可以。不过这个也就忍了,好歹还可以ssh过来。
emacs嘛,中文的xft渲染还是很差。6月份有段时间co出来的代码倒是对中文字体的支持很好。不过后来一直到现在都不行。然后偶尔还会因为把;错输入为:,然后C-h(我重新绑定了这个键组合),就会没有响应,然后试图C-g,那么,恭喜我自己,马上X crash。
gaim对google talk的字体设置支持不错,可是msn account的字体就不行,没法放大,看着很难受,费眼睛。来消息了的声音提示有时候有,有时没有。不过,据说gaim2.0会支持qq,所以co一个,正在编译。
所以估计系统的不稳定是上面诸多原因的综合
订阅:
博文 (Atom)