ArchLinux下编译gvim +python

2011年12月01日 21:26

ArchLinux的gvim版本比较新,
但是其python2的library链接有错。
当import gtk就会出现Error import的错误提示。

这个错误我知道已经有好几个月了,
之前在github上就有用ArchLinux的人表示用不了我插件里的取色器。
但是当时我用的还是Ubuntu,所以没去fix。

不过如今我用上了Arch,当然得解决这个问题:D

方法很简单,重新编译gvim:

hg clone https://vim.googlecode.com/hg/ vim

cd vim/src
./configure --enable-multibyte --with-features=huge --enable-gui=gtk2 \
  --enable-python3interp=yes --enable-rubyinterp \
  --enable-pythoninterp=yes \
  --enable-tclinterp  --enable-fontset  \
  --with-python-config-dir=/usr/lib/python2.7/config \
  --with-python3-config-dir=/usr/lib/python3.2/config-3.2mu

make && sudo make install


NOTE:
1.要将python2 link 为 python,否则会提示找不到python2.x
在/usr/bin下
    ln -s python2 python
PS:安装好后可以用 ln -sf python3 python 把它替换回来


2.--with-python3-config-dir为/usr/lib/python3.2/config-3.2mu

3.如果还是找不到python2,可以在 auto/config.cache里找到
vi_cv_var_python_version并将此行改成
vi_cv_var_python_version=${vi_cv_var_python_version=2.7}

 

PS: 看了下gvim的PKGBUILD。里面有这么一句

  # fix python name
  sed -i -e 's|vi_cv_path_python, python|vi_cv_path_python, python2|' \
    vim-build/src/configure.in

那改这句应该也行。

也就是在configure.in里面把

vi_cv_path_python, python 改成 vi_cv_path_python, python2

Tags: vim
评论(4) 阅读(7833)

vim:撤销最后关闭的buffer

2011年12月01日 02:55


在目前的主流浏览器里面,都可以撤销最后关闭的标签页。

于是我以为vim里面也有这样的功能,但是看完:help buffer后发现,这个真没有 :|

于是只好自己动手,写了个mapping

<ctrl-w>z:撤销最后关闭的buffer
 

"reopen last closed buffers "{{{
"exclude the buffer closed with :bw :qall :)
aug BufList
    au!
    au vimenter * let g:bufList=[]
    au bufwinleave * call AddBufList()
aug END
nmap <silent> <c-w>z :call OpenBufList()<cr>
nmap <silent> <c-w><c-z> <c-w>z
function! AddBufList()
    let b=expand('<abuf>')
    if b > 0
        let g:bufList=add(g:bufList,b)
    endif
endfunction
function! OpenBufList()
    if len(g:bufList) !=0
        exec "sb ".remove(g:bufList,-1)
    endif
endfunction "}}}





可以撤销:q :hid :close :only :bun :bd所关闭的buffer('hidden'选项没影响)

不会撤销 :bw :qall 所关闭的buffer

我猜也不需要撤销了吧,嗯……

 



NOTE:

1.<afile>是当前autocommand执行的对象,<abuf>是其buf number。不一定与“%”相同

还有一个<amatch>,看说明是指 filetype/syntax 的events时所匹配的filetype/syntax的名称

2.buffer events的执行顺序 ,'[]'括号内为'hidden'选项打开的情况。


:new => bufleave

:hid => bufleave -> bufwinleave -> bufhidden
(与:e #相同,'hidden'打开时:q,:close与之相同)

:bun => bufleave -> bufwinleave ->[bufhidden ->]bufunload
('hidden'关闭时:q,:close与之相同)

:bd  => bufleave -> bufwinleave ->[bufhidden ->]bufunload -> bufdelete

:bw  => bufleave -> bufwinleave ->[bufhidden ->]bufunload -> bufdelete
                 -> bufwipeout
                (!这里的buffer不能被恢复了)

 

 

Tags: vim
评论(6) 阅读(7491)

gnome-shell and unity

2011年11月23日 16:37

I have installed archlinux with gnome-shell and replacing ubuntu11.10 due to gvim's python issues for a couple days.

As I have tried them both. here is my Yet Another Compare between gnome-shell and unity.

Looking:
    Gnome-shell is cleaner at first glance. but you can make unity with that
looking.
    the notification and tray applet of gnome-shell is better than unity.
    gnome-shell is a bit stylized than unity which need a bit config with
compiz

Usablity:
    They both introduce a quick way of opening applications: Activites and
Dash.
    gnome-shell combine window ,desktop and applications in Activites which
looks cleaner.
    unity don't have window in dash. and you could config expo/scales with ccsm
to have similar using as gnome-shell does.
    And both works fine with easystroke. that's enough for me.
    
Configurability:
    gnome-shell have no config tool. only a install tool with gnome-tweak-tool
and gnome-shell-extension
    unity configs in ccsm. but not fully configured.
    
Stability:
    unity is stable enough. and it can automatic recover after crashes most of
the time. you can use unity --replace to recover it manually.
    gnome-shell (3.2.1) crashes more often. and should recover it manually.
    by gnome-shell --replace
    or DISPLAY=:0 gnome-shell --replace & in other tty
    and sometimes you can't react with the windows even with gnome-shell
recovered.
 
Conclusion:
    unity is easy enough to use and need some time to config.
    gnome-shell is elegant but need some time to get used to (it's
crash).

 

Tags: Unity gnome-shell
评论(0) 阅读(2996)

ubuntu 11.10 的theme 和icon

2011年10月14日 11:08

Ubuntu 11.10升级好了,十分顺利,比10.10升11.04的时候好多了。

安装后桌面主题变了,需要自行设置。

Theme:Elegant_Brit
http://grvrulz.deviantart.com/art/Elegant-Brit-gnome3-208925032
下载后解压到~/.themes
不过panel面板居然是black,需要自己修改下
vim ~/.themes/Elegant_Brit/gtk-3.0/gtk.css
    @define-color os_chrome_bg_color black;
修改成自己想要的颜色就行了。

Icon:Faenza
http://tiheum.deviantart.com/art/Faenza-Icons-173323228

Theme和Icon设置
sudo apt-get install gnome-tweak-tool
运行后在theme里修改相应选项就行了
    
 

Tags: ubuntu
评论(0) 阅读(3313)

对banshee当前播放曲目评分的python脚本

2011年9月07日 19:09

直接通过command line 似乎有bug.只能通过dbus

import dbus,sys,subprocess
import commands
bus = dbus.SessionBus()
banshee = bus.get_object ("org.bansheeproject.Banshee", "/org/bansheeproject/Banshee/PlayerEngine")
engine_interface=dbus.Interface (banshee, "org.bansheeproject.Banshee.PlayerEngine")
album=engine_interface.GetCurrentTrack()['album']
artist=engine_interface.GetCurrentTrack()['artist']
title=engine_interface.GetCurrentTrack()['name']

if len(sys.argv) == 2: 
    engine_interface.SetRating (dbus.Byte (int(sys.argv[1])))
    subprocess.call(["notify-send","Rate to: "+str(sys.argv[1]),artist+"\n"+title])
    
else:
    subprocess.call(["notify-send","Rate to: 0",artist+"\n"+title])
    engine_interface.SetRating (dbus.Byte (0))

使用:

>python bansheerating.py [1/2/3/4/5]

我是直接用easystroke的手势来运行的。

 

 

Tags: python ubuntu
评论(0) 阅读(2640)

vim colorscheme: galaxy1.0 发布~

2011年9月05日 00:24

 

 

都是英文,改天再翻译,总之,就是个根据色彩自动生成主题的插件。支持Terminal(8/16/256)

Terminal curosr 部分感谢 依云同学的 改变终端下的光标颜色,包括 screen 和 tmux!

galaxy 在  http://www.vim.org/scripts/script.php?script_id=3729 下载

需要安装 ColorV http://www.vim.org/scripts/script.php?script_id=3597  

 

内置主题预览:

        GUI        


        TERM(256)  

 

 

##INTRO##

    *galaxy* is a colorscheme that generate schemes with colors.

    With this you can:
        Simply get your desired colorscheme.

    With this you get:
        5 built-in schemes.
        Generate scheme with only one color.
        Edit schemes in 5 colors.
        Simply generate 100+ schemes with colorname-list.
        Terminal (256/16/8) support with all schemes.
        StatusLine highlight with insert-enter.
        Clearly diff mode color.
        ...

    Take a glance:
        GUI         http://i55.tinypic.com/u0qh2.png
        TERM(256)   http://i56.tinypic.com/2nr234y.png

    Where to start:     
        :colorscheme galaxy
        :Galaxy

##INSTALL##

1.Using [Vundle.vim](Recommend):~
    https://github.com/gmarik/vundle
    After installed vundle and git. Add this line to your vimrc  
    `Bundle 'Rykka/vim-galaxy'`
    `Bundle 'Rykka/ColorV'`
    Run `:BundleInstall` to install.
    And update them easily by `:BundleInstall!`
 
2.Using [Galaxy on Vim.org]~
    You should download latest 'ColorV' at first.
    http://www.vim.org/scripts/script.php?script_id=3597
    http://www.vim.org/scripts/script.php?script_id=3729
    Download the latest version of tar.gz file,
    Extract to $VIMFILE folder.
    ("~/.vim" for linux. "$HOME/vimfiles" for windows)
    Generate helptags. `:helptags ~/.vim/doc
 

Tags: vim
评论(0) 阅读(6231)

Alternate python "下载" for China...

2011年9月03日 16:27

一直以来,http://www.python.org/ 的download 页面都是被gfwed掉的。

 

今天上去下载,发现页面左边居然多了一个链接。

http://www.python.org/getit/

并且用中文写着“下载”。

 

当时我就感动了.... 多么理解中国国情的python开发者啊。

Tags: python
评论(2) 阅读(3454)

python regxp 笔记

2011年8月31日 15:45

import re
# python REGXP: {{{
# . matches any char                (include end-of-line(EOL) if re.S is on)
#                                               vim:. (always NO EOL)
# ^ $ matches start/end of string   (include EOL start/end if re.M is on)
# *  matches 0+
# +  matches 1+                                 vim: \+
# ?  matches 0 or 1                             vim: \? \=
# {} matches numbers                            vim: \{}
# *? +? ??  {}? matches the minimal             vim: \{-}
# \ escape
# [] character set
# () group
# (?<!...) no preceding                         vim: \@<!
# (?<=...) with preceding                       vim: \@<=
# (?!...)  no following                         vim: \@!
# (?=...)  with following                       vim: \@=
# (?:...)  ignore group number                  vim: \%(\)
# (?P<NAME>...) define the group 'NAME'
# (?P=name)  match the group 'name'
# (?(id/name)yes-pattern|no-pattern)
#       match the yes-pattern if the group id/name exists      
# (?iLmsux) re option:ignore/locale/multiline/dot2all/unicode/verbose
# 
# NOTE 
# MODULE:
# re.compile() Compile a regular expression pattern into a regular expression object
# {{{ e.g.
# prog = re.compile(pattern)
# result = prog.match(string)
# is equivalent to:
# result = re.match(pattern, string)
# }}}
# finditer()  returns iterable
# findall()   returns string list
# match(string,[pos,[endpos]])     match object match with whole ptn
# search(string,[pos,[endpos]])    match object if ptn exists in it
# split(ptn,str)     returns string list    vim:split(str,ptn)
# sub(ptn,rpl,str,flag)                     vim:substiture(str,ptn,rpl,flag)
# escape()    Return string with all non-alphanumerics backslashed
# 
# Regular Object:
# groups        number of groups
# pattern       compiled pattern
# flags         compiled flag
#
# Match Object:
# expand(tmpl)    expand character '\1','\n' in tmpl
# group()       return subgroup string 0:entire match 1,2...:subgroup
# groups()      return subgroup tuple
# groupdict()   return subgroup dict with group which have NAME
# start() end() return idx of the group in whole string.
# span()        return (start,end) tuple
# pos           the pos passed to search()/match() 
# endpos        the endpos passed to search()/match() 
# string        the string passed to search()/match() 
# lastgroup     last matched group
# re            thre regular object produce this match object
# 
# ERRORS:
# XXX look-behind requires fixed-width pattern
# (?<![0-9a-fA-F]|0[xX]) is wrong!! 
# (?<![0-9a-fA-F])|(?<!0[xX]) is wrong
#  (?<!([\w\#]))      final use
# XXX unbalanced parentheses
# use raw text r'''\(......\) '''
# or escape twice '\\(......\\)' 
# }}}
 

vim 下的\s 和python 的\s 不同

python 的\s 是[ \t\n\r\f\v]

vim 的 \s 是[ \t ]

 

Tags: python
评论(0) 阅读(2590)

vim 插件 ColorV 2.5发布~

2011年8月31日 15:14

这是我的一个vim插件,方便在vim中直接处理色彩文本(e.g.,yellow/rgb(255,255,0)/#ff3300)。

功能简述:
        选择颜色
        获取色彩信息
        改变色彩文本
        生成色彩列表
        预览色彩文本
 

最新版可以从 https://github.com/rykka/ColorV 下载


2.5版本的新特性

1. 采用了python 对核心程序重写.改变了原先的算法。

使运行速度得到极大提升

(gui <0.06s term<0.10s 对比之前的数据 gui~0.4s term~1.1s )

 

2. 增加了新的max模式 ('<leader>cx')。

显示更多的色彩信息(RGB/HSV/HLS/YIQ)

一个色彩历史条,记录曾经复制过的色彩。

 

3.新的色彩空间

增加了一个HLS空间的显示 。"g:ColorV_win_space" 。

不过感觉用'hls'空间里面选择色彩并不比'hsv'方便。

 

4.终端支持(感谢依云同学)

添加了对彩色终端的支持。包括8/16/256色。

需要注意设置‘&t_Co’选项

 

附图

(左边是terminal 右边是gui。

其主题色彩是根据在colorv中所显示的色彩自动生成的。

生成器是我的另外一个插件vim-galaxy ,不过还没正式发布,哈哈)

 

 

 

 

 

 

 

 

 

 

 

 

 

Tags: vim
评论(0) 阅读(3777)

vim两种算法的终端颜色对比

2011年8月01日 21:15

上面是终端色图

左边delta_e_cie2000,右边是rgb差值

下面为标准色图

可看出,其差别主要是在饱和度和亮度较低(<40)时,rgb算法就丢失了色彩信息

而delta_e_cie2000在(<25)左右丢失

总体上delta_e_cie2000比rgb更鲜艳。

不过就识别度而言,两者都差不多。

用rgb差值还是能够接受的

Tags: vim
评论(0) 阅读(4227)