2010年10月31日星期日
PHP MYSQL JQUERY JS 编写二级联动下拉列表
请浏览www.wackguild.tk 我的博客浏览
我的百度空间也有http://hi.baidu.com/dszul
2010年7月21日星期三
PHP之Emacs实现自动提示
这里主要感谢“土豆”兄弟提供的一个日本emacser 的博客网站地址,在哪里看到详细的配置,我也是按照步骤配置的,结果成功了。不过还需要改进,有点别扭,
得知此配置的网站:http://d.hatena.ne.jp/IMAKADO jump
首先将这个文件download下来,放在一个路径里面。我的就放在 ~/.emacs.d/php/下面
wget http://www.emacswiki.org/cgi-bin/wiki/download/install-elisp.el
将此文件加载到配置文件中去。
(add-to-list 'load-path "~/.emacs.d/php/")
(require 'install-elisp)
(setq install-elisp-repository-directory "~/.emacs.d/php/");;设置使用install-elisp-from-emacswiki 后下载下来的文件路径,我把它们放在一个文件夹里面
然后使用M-x将相关的文件get download下来,不用管它会怎么样,因为我们设置了下载路径,自动会下载到那个路径文件夹里面。(* 注意,Pagename输入后 他会自动打开,你需要执行C-c C-c 进行编译。)
M-x:
install-elisp-from-emacswiki
Pagename:
anything.el
M-x:
install-elisp-from-emacswiki
Pagename:
anything-match-plugin.el
M-x:
install-elisp-from-emacswiki
Pagename:
auto-complete.el
;;完成后在.emacs 加入此句代码 :
(locate-library "auto-complete.el")
;;然后重新载入下.emacs 文件。跟前面的操作一样,我们的PHP配置文件给弄下来编译。
M-x:
install-elisp-from-emacswiki
Pagename:
php-completion.el
;;php 自动提示设置
(add-hook 'php-mode-hook
(lambda()
(require 'php-completion)
(php-completion-mode t)
(define-key php-mode-map (kbd "C-c p") 'phpcmp-complete)
(when (require 'auto-complete nol t)
(make-variable-buffer-local 'ac-sources)
(add-to-list 'ac-sources 'ac-source-php-completion)
(auto-complete-mode t))))
2010年6月10日星期四
emacs自定义工具栏
(setq tool-bar-map (make-sparse-keymap))
要自定义工具栏,只需要修改tool-bar-map这个变量就可以了,一般我们可以用tool-bar-add-item这个函数来往tool- bar-map里添加工具项。
tool-bar-add-item的原型是这样的:
(tool-bar-add-item icon def key &rest props)
参数icon设置工具图标,emacs的工具栏可以使用XPM和PBM格式的图标,当emacs 有libxmp支持时会使用XPM格式,没有libxmp库时会寻找PBM格式的图标(Info上还说有XBM格式,我没搞清楚什么情况下使用XBM)。
在etc/images目录下可以看到emacs自带的图标一般都同时有XPM和PBM两种格式,就是为了在没有libxmp库时也能显示工具栏,因为如果我们只有xpm格式的图标而没有libxmp库时,emacs就不在工具栏上显示这个项了。所以我们自己做图标时最好XPM和PBM都准备一份。
icon参数的类型是字符串,只需要传主文件名就可以,扩展名emacs会自己加,比如对图标文件semantic.xpm写成”semantic”。
emacs会在image-load-path下查找图标文件,这个变量的值默认为(“…/etc/images/” data-directory load-path),就是说它除了查找image目录外还会查找所有的load-path,所以如果我们有自己的图标目录,把它加到image- load-path或者load-path都可以。
图标的大小好像没有限制,emacs本身使用的图标是24×24像素的,如果使用了比它大的图标,整个工具栏会自动扩大。
参数def设置这个工具项被按下的执行什么命令,它的格式跟global-set-key里的command格式是一样的。
参数key用来给这个工具项指定一个key,这个key用于唯一标识这个工具项,所以在同一个keymap里key不能重复。
剩下的参数可以设置一些属性项,具体可以设置哪些属性可以看Info > elisp > Keymaps > Menu Keymaps > Defining Menus > Extended Menu Items。常用的几个属性有:
* :enable 这个属性的值是一个表达式,emacs对这个表达式求值,如果值为nil时,这个工具项会被禁用。
* :visible 这个属性控制这个工具项是否显示,它的类型与:enable是一样的。
* :help 这个属性类型是字符串,当鼠标在工具项上停留时会显示这个字符串。
其余的属性我没用过,也没仔细研究它们用来干什么。
举例来说,如果要添加一个工具项用来执行gdb命令,并且只有在c-mode或者c++-mode时才让它有效,可以这样:
(tool-bar-add-item "gud/run" 'gdb 'gdb
:enable '(memq major-mode '(c++-mode c-mode)))
这样会把gdb这个工具项添加到默认工具栏的最后,如果不想要emacs默认的工具栏,可以先执行(setq tool-bar-map (make-sparse-keymap))把默认的工具栏清空。
2010年6月2日星期三
pymacs-settings.el配置python自动补全
将会看见pymacs 的python代码源包,解压就行了....
进入其中 执行 python setup.py install 可以先执行python setup build 然后安装rope ropemacs来很好的配合python让他具有IDE的项目管理功能,首先执行下面的命令下载源代码下来
$hg clone http://bitbucket.org/agr/rope/
$hg clone http://bitbucket.org/agr/ropemacs/
$hg clone http://bitbucket.org/agr/ropemode/
然后分别进入rope ropemacs 里面执行
python setup.py install
把三个文件分别移动到你的path下面如:
mv rope* /home/B.Qnyd/lisp/
如果你还想要它检查你的语法是否正确,你就需要安装pyflakes
我的是fedora 直接安装
yum install pyflakes
其他系统可以用sudo apt-get install 等系统默认的在线安装包...
(注意这个python-setuptools东西必不可少,一样执行
yum install python-setuptools)
然后.
新建一个pymacs-settings.el 把以下代码加入进去:
(setq pymacs-load-path '("~/lisp/rope"
"~/lisp/ropemacs"))
(autoload 'python-mode "python-mode" "Python Mode." t)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("python" . python-mode))
(require 'python-mode)
(add-hook 'python-mode-hook
(lambda ()
(set-variable 'py-indent-offset 4)
;(set-variable 'py-smart-indentation nil)
(set-variable 'indent-tabs-mode nil)
(define-key py-mode-map (kbd "RET") 'newline-and-indent)
;(define-key py-mode-map [tab] 'yas/expand)
;(setq yas/after-exit-snippet-hook 'indent-according-to-mode)
))
;; pymacs
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)
;;(eval-after-load "pymacs"
;; '(add-to-list 'pymacs-load-path YOUR-PYMACS-DIRECTORY"))
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Auto-completion
;;; Integrates:
;;; 1) Rope
;;; 2) Yasnippet
;;; all with AutoComplete.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun prefix-list-elements (list prefix)
(let (value)
(nreverse
(dolist (element list value)
(setq value (cons (format "%s%s" prefix element) value))))))
(defvar ac-source-rope
'((candidates
. (lambda ()
(prefix-list-elements (rope-completions) ac-target))))
"Source for Rope")
(defun ac-python-find ()
"Python `ac-find-function'."
(require 'thingatpt)
(let ((symbol (car-safe (bounds-of-thing-at-point 'symbol))))
(if (null symbol)
(if (string= "." (buffer-substring (- (point) 1) (point)))
(point)
nil)
symbol)))
(defun ac-python-candidate ()
"Python `ac-candidates-function'"
(let (candidates)
(dolist (source ac-sources)
(if (symbolp source)
(setq source (symbol-value source)))
(let* ((ac-limit (or (cdr-safe (assq 'limit source)) ac-limit))
(requires (cdr-safe (assq 'requires source)))
cand)
(if (or (null requires)
(>= (length ac-target) requires))
(setq cand
(delq nil
(mapcar (lambda (candidate)
(propertize candidate 'source source))
(funcall (cdr (assq 'candidates source)))))))
(if (and (> ac-limit 1)
(> (length cand) ac-limit))
(setcdr (nthcdr (1- ac-limit) cand) nil))
(setq candidates (append candidates cand))))
(delete-dups candidates)))
(add-hook 'python-mode-hook
(lambda ()
(auto-complete-mode 1)
(set (make-local-variable 'ac-sources)
(append ac-sources '(ac-source-rope) '(ac-source-yasnippet)))
(set (make-local-variable 'ac-find-function) 'ac-python-find)
(set (make-local-variable 'ac-candidate-function) 'ac-python-candidate)
(set (make-local-variable 'ac-auto-start) nil)))
;;Ryan's python specific tab completion
(defun ryan-python-tab ()
; Try the following:
; 1) Do a yasnippet expansion
; 2) Do a Rope code completion
; 3) Do an indent
(interactive)
(if (eql (ac-start) 0)
(indent-for-tab-command)))
(defadvice ac-start (before advice-turn-on-auto-start activate)
(set (make-local-variable 'ac-auto-start) t))
(defadvice ac-cleanup (after advice-turn-off-auto-start activate)
(set (make-local-variable 'ac-auto-start) nil))
(define-key py-mode-map "\t" 'ryan-python-tab)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; End Auto Completion
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Auto Syntax Error Hightlight
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
(provide 'pymacs-settings)
然后在你的.emacs 里面加入 (load "pymacs-settings")这样你就给你的emacs扩展了自动补全,
建立工程了.不比任何IDE差...... 不过首先你得配置好,不然你就会觉得它很差劲....
2010年5月29日星期六
emacs23的编译和安装
--prefix=/usr \
--with-x-toolkit=gtk \
--with-xft \
--enable-font-backend \
--with-freetype \
--with-gtkmake && make bootstrap && make info && make install
呵呵,23支持中文很好!
特别注意的是在编译的时候会出现--with-gif=no --with-trff=no --with-libXpm=no 等错误,但是首先你需要把这三个缺省包安装上,不然你忽略了,无法启动图形界面的EMACS 所以需要安装上,GIF这个可以直接忽略掉,我就忽略了,因为实在找不到安装包,没办法,不会影响到其他的,能装上最好装上。
Emacs 自动补全 yasnippet
(add-to-list 'load-path
"~/.emacs.d/plugins")
(require 'yasnippet-bundle)
new my .emacs
;;;;;;;;;今天最新添加org-mode Emacs 23自带的功能,非常棒,做笔记最好,今天尝试了下..
;;;;;;;;;配置参考Emacs中文网的各位高手,,主要参考DEA 的作者ahei和
;;;;;;;;;common lisp开发环境配置由重庆的common lisp程序员(曾大哥)给我配置的第一次,
;;;;;;;;;后面自己进行升级和改进
;;;;;;;;;其 它快捷键参考VIM 的基本常用的功能自己通过M-x 进行设置的。
;;;;;;;;;下次更新GNUS 的新闻阅读 和MP3,MPLAYER的功能!
;;;;;;;;;里面注释比较多,主要是很多插件的使用快捷键.
;;;;;;;;;由于 我很懒,不想去记,不知道 可以看看,,hoho
;;;;;;;;;目前根据以前的代码 整理了下,但还有部分漏掉了。。
;;;;;;;;; 只要不影响Emacs正常工作,我就没管了,大家可以看看,最好不要直接COPY,
;;;;;;;;;因为我和你的操作系统环境可能不一 样;
;;;;;;;;;非常感谢DEA 的作者ahei和曾大哥 他俩所提供的配置源代码(
;;;;;;;;;都上了W行,看着眼花缭乱)
;解决emacs shell 乱码
(setq ansi-color-for-comint-mode t)
(customize-group 'ansi-colors)
(kill-this-buffer);关闭customize窗口
(setq default-major-mode 'text-mode);一打开就起用 text 模式
;自定义按键
(global-set-key [f1] 'shell);F1进入Shell
;;目的是开一个shell的小buffer,用于更方便地测试程序(也就是运行程序了),我经常会用到。
;;f1就是另开一个buffer然后打开shell,C-f1则是在当前的buffer打开shell
(global-set-key [C-f5] 'previous-error)
(global-set-key [f5] 'next-error)
(setq backup-inhibited t);;不产生备份
(setq auto-save-default nil);不生成名为#filename# 的临时文件
(defun open-eshell-other-buffer ()
"Open eshell in other buffer"
(interactive)
(split-window-vertically)
(eshell))
(global-set-key [C-f1] 'open-eshell-other-buffer)
;;(global-set-key [C-f1] 'eshell)
;;加载cedet
(add-to-list 'load-path "~/lisp/cedet/speedbar")
(add-to-list 'load-path "~/lisp/cedet/eieio")
(add-to-list 'load-path "~/lisp/cedet/semantic")
(add-to-list 'load-path "~/lisp/cedet/common")
(add-to-list 'load-path "~/.emacs.d/")
(require 'cedet)
;;加载ecb
(add-to-list 'load-path "~/lisp/ecb")
;;(require 'ecb)
(require 'ecb-autoloads)
;;(ecb-activate)
(when (require 'ecb nil 'noerror)
(setq ecb-tip-of-the-day nil)
(setq ecb-auto-compatibility-check nil)
(setq ecb-primary-secondary-mouse-buttons 'mouse-1--C-mouse-1))
;; 用M-x执行某个命令的时候,在输入的同时给出可选的命令名提示
(icomplete-mode 1)
(define-key minibuffer-local-completion-map (kbd "SPC") 'minibuffer-complete-word)
(setq column-number-mode t)
(setq line-number-mode t)
(global-linum-mode 'linum-mode);;在左边显示行号
;;(global-set-key (kbd "C-a") 'view-file-other-window)
(global-font-lock-mode t);语法高亮
(setq font-lock-maximum-decoration t)
(setq font-lock-global-modes '(not shell-mode text-mode))
(setq font-lock-verbose t)
(setq font-lock-maximum-size '((t . 1048576) (vm-mode . 5250000)))
(setq-default kill-whole-line t);;C-k 删除该行
(fset 'yes-or-no-p 'y-or-n-p);以 y/n代表 yes/no
(column-number-mode t);显示列号
(show-paren-mode t);显示括号匹配
(setq show-paren-mode t) ;;打开括号匹配显示模式
(setq show-paren-style 'parenthesis)
(display-time-mode 1);显示时间,格式如下
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(setq display-time-use-mail-icon t);;时间栏旁边启用邮件设置
(setq display-time-interval 10);;时间的变化频率,单位多少来着?
(tool-bar-mode nil);去掉那个大大的工具栏
(scroll-bar-mode nil);去掉滚动条
(auto-save-mode nil);;禁止自动保存
(put 'scroll-left 'disabled nil);;允许屏幕左移
(put 'scroll-right 'disabled nil);;允许屏幕右移
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'LaTeX-hide-environment 'disabled nil)
(mouse-avoidance-mode 'animate);光标靠近鼠标指针时,让鼠标指针自动让开
(setq mouse-yank-at-point t);支持中键粘贴
(transient-mark-mode t);允许临时设置标记
;; 高亮显示C/C++中的可能的错误(CWarn mode)
(global-cwarn-mode 1)
(global-set-key (kbd "
(global-set-key (kbd "
(global-set-key (kbd "
(global-set-key [C-f2] 'slime-compile-file);slime编译文件
(global-set-key [C-f3] 'python-shell);F3进入Python-Shell
(global-set-key [C-f6] 'gdb);F5调试程序
(setq compile-command "make -f Makefile")
;;(global-set-key [f7] 'compile);F7编译文件
;; C-f7, 设置编译命令; f7, 保存所有文件然后编译当前窗口文件
(defun du-onekey-compile ()
"Save buffers and start compile"
(interactive)
(save-some-buffers t)
(switch-to-buffer-other-window "*compilation*")
(compile compile-command))
(global-set-key [C-f7] 'compile)
(global-set-key [f7] 'du-onekey-compile)
(setq speedbar-show-unknown-files t);;可以显示所有目录以及文件
;;让 dired 可以递归的拷贝和删除目录。
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)
(global-set-key (kbd "C-e") 'ecb-activate);;启动Ecb
(global-set-key [C-f9] 'dired);;设置[C-f9]为调用dired命令
(global-set-key [C-f10] 'undo);;设置C-F10为撤销
(global-set-key [C-f11] 'calendar) ;;设置C-F11快捷键指定Emacs 的日历系统
(global-set-key [C-f12] 'list-bookmarks);;设置C-F12 快速察看日程安排
(global-set-key (kbd "C-|") 'other-window);窗口间跳转
(global-set-key [f2] 'kill-this-buffer);F2关闭当前buffer
(global-set-key [M-return] 'kill-this-buffer);M-return关闭当前buffer
(global-set-key [C-return] 'kill-this-buffer);C-return关闭当前buffer
(global-set-key [f10] 'split-window-vertically);F10分割窗口
(global-set-key [f11] 'delete-other-windows);F11 关闭其它窗口
(global-set-key [f12] 'my-fullscreen);F12 全屏
(global-set-key (kbd "C-,") 'backward-page);文件首
(global-set-key (kbd "C-.") 'forward-page);文件尾
(global-set-key (kbd "C-'") 'next-buffer);转到下一个buffer
(global-set-key (kbd "C-;") 'previous-buffer);转到上一个buffer
(global-set-key (kbd "C-/") 'next-multiframe-window);;转到下一个窗口
(global-set-key (kbd "C-?") 'previous-multiframe-window);;转到上一个窗口
(global-set-key (kbd "C-<") 'beginning-of-line);;跳转到行首
(global-set-key (kbd "C->") 'end-of-line);;跳转到行尾
(global-set-key (kbd "C-c C-g") 'goto-char) ;;跳转到行任意位子
(setq mouse-drag-copy-region nil);;取消鼠标选择即复制
;普通设置
(setq inhibit-startup-message t);关闭起动时闪屏
(setq visible-bell t);关闭出错时的提示声
(menu-bar-mode nil);;关闭菜单
;;shell,gdb退出后,自动关闭该buffer
(defun kill-buffer-when-shell-command-exit ()
"Close current buffer when `shell-command' exit."
(let ((process (ignore-errors (get-buffer-process (current-buffer)))))
(when process
(set-process-sentinel process
(lambda (proc change)
(when (string-match "\\(finished\\|exited\\)" change)
(kill-buffer (process-buffer proc))))))))
;; 退出gdb的时候关闭gdb对应的buffer
(add-hook 'gdb-mode-hook 'kill-buffer-when-shell-command-exit)
;; 退出term的时候关闭term对应的buffer
(add-hook 'term-mode-hook 'kill-buffer-when-shell-command-exit)
;;编译成功后自动关闭*compilation* 函数
(defun kill-buffer-when-compile-success (process)
"Close current buffer when `shell-command' exit."
(set-process-sentinel process
(lambda (proc change)
(when (string-match "finished" change)
(delete-windows-on (process-buffer proc))))))
;; 编译成功后自动关闭*compilation* buffer
(add-hook 'compilation-start-hook 'kill-buffer-when-compile-success)
;;退出时寻问
(setq kill-emacs-query-functions
(lambda ()
(y-or-n-p "Do you really want to quit? ")))
;; 设置时间戳,标识出最后一次保存文件的时间。
(setq time-stamp-active t)
(setq time-stamp-warn-inactive t)
(setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M:%02S chunyu")
(global-set-key (kbd "M-g") 'goto-line);;设置M-g为goto-line
;; 尽快显示按键序列
(setq echo-keystrokes 0.1)
(setq system-time-locale "C")
;;加载template
(defconst my-emacs-path "~/.emacs.d/" "我的emacs相关配置文件的路径")
(load "template-settings")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 设置日历 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;设置日历的一些颜色
(setq calendar-load-hook
'(lambda ()
(set-face-foreground 'diary-face "skyblue")
(set-face-background 'holiday-face "slate blue")
(set-face-foreground 'holiday-face "white")))
;;设置我所在地方的经纬度,calendar里有个功能是日月食的预测,和你的经纬度相联系的。
;; 让emacs能计算日出日落的时间,在 calendar 上用 S 即可看到
(setq calendar-latitude +39.54)
(setq calendar-longitude +116.28)
(setq calendar-location-name "北京")
;; 设置阴历显示,在 calendar 上用 pC 显示阴历
(setq chinese-calendar-celestial-stem
["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"])
(setq chinese-calendar-terrestrial-branch
["子" "丑" "寅" "卯" "辰" "巳" "戊" "未" "申" "酉" "戌" "亥"])
;; 设置 calendar 的显示
(setq calendar-remove-frame-by-deleting t)
(setq calendar-week-start-day 1);; 设置星期一为每周的第一天
(setq mark-diary-entries-in-calendar t);; 标记calendar上有diary的日期
(setq mark-holidays-in-calendar nil); ; 为了突出有diary的日期,calendar上不标记节日
(setq view-calendar-holidays-initially nil) ; 打开calendar的时候不显示一堆节日
;; 去掉不关心的节日,设定自己在意的节日,在 calendar 上用 h 显示节日
(setq christian-holidays nil)
(setq hebrew-holidays nil)
(setq islamic-holidays nil)
(setq solar-holidays nil)
(setq general-holidays '((holiday-fixed 1 1 "元旦")
(holiday-fixed 2 14 "情人节")
(holiday-fixed 3 14 "白色情人节")
(holiday-fixed 4 1 "愚人节")
(holiday-fixed 5 1 "劳动节")
(holiday-float 5 0 2 "母亲节")
(holiday-fixed 6 1 "儿童节")
(holiday-float 6 0 3 "父亲节")
(holiday-fixed 7 1 "建党节")
(holiday-fixed 8 1 "建军节")
(holiday-fixed 9 10 "教师节")
(holiday-fixed 10 1 "国庆节")
(holiday-fixed 12 25 "圣诞节")))
;;Calendar模式支持各种方式来更改当前日期
;;(这里的“前”是指还没有到来的那一天,“后”是指已经过去的日子)
;; q 退出calendar模式
;; C-f 让当前日期向前一天
;; C-b 让当前日期向后一天
;; C-n 让当前日期向前一周
;; C-p 让当前日期向后一周
;; M-} 让当前日期向前一个月
;; M-{ 让当前日期向后一个月
;; C-x ] 让当前日期向前一年
;; C-x [ 让当前日期向后一年
;; C-a 移动到当前周的第一天
;; C-e 移动到当前周的最后一天
;; M-a 移动到当前月的第一天
;; M-e 多动到当前月的最后一天
;; M-< 移动到当前年的第一天
;; M-> 移动到当前年的最后一天
;;Calendar模式支持移动多种移动到特珠日期的方式
;; g d 移动到一个特别的日期
;; o 使某个特殊的月分作为中间的月分
;; . 移动到当天的日期
;; p d 显示某一天在一年中的位置,也显示本年度还有多少天。
;; C-c C-l 刷新Calendar窗口
;; Calendar支持生成LATEX代码。
;; t m 按月生成日历
;; t M 按月生成一个美化的日历
;; t d 按当天日期生成一个当天日历
;; t w 1 在一页上生成这个周的日历
;; t w 2 在两页上生成这个周的日历
;; t w 3 生成一个ISO-SYTLE风格的当前周日历
;; t w 4 生成一个从周一开始的当前周日历
;; t y 生成当前年的日历
;;EMACS Calendar支持配置节日:
;; h 显示当前的节日
;; x 定义当天为某个节日
;; u 取消当天已被定义的节日
;; e 显示所有这前后共三个月的节日。
;; M-x holiday 在另外的窗口的显示这前后三个月的节日。
;; 另外,还有一些特殊的,有意思的命令:
;; S 显示当天的日出日落时间(是大写的S)
;; p C 显示农历可以使用
;; g C 使用农历移动日期可以使用
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 设置日记 ;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;
(setq diary-file "~/文档");; 默认的日记文件
(setq diary-mail-addr "BB.Qnyd@gmail.com")
(add-hook 'diary-hook 'appt-make-list)
;;当你创建了一个'~/diary'文件,你就可以使用calendar去查看里面的内容。你可以查看当天的事件,相关命令如下 :
;; d 显示被选中的日期的所有事件
;; s 显示所有事件,包括过期的,未到期的等等
;; 创建一个事件的样例:
;; 02/11/1989
;; Bill B. visits Princeton today
;; 2pm Cognitive Studies Committee meeting
;; 2:30-5:30 Liz at Lawrenceville
;; 4:00pm Dentist appt
;; 7:30pm Dinner at George's
;; 8:00-10:00pm concert
;; 创建事件的命令:
;; i d 为当天日期添加一个事件
;; i w 为当天周创建一个周事件
;; i m 为当前月创建一个月事件
;; i y 为当前年创建一个年事件
;; i a 为当前日期创建一个周年纪念日
;; i c 创建一个循环的事件
(setq compile-command "make")
;;emacs的默认compile命令是调用make -k,我把它改成了make。你也可以把它改成其他的,比如gcc之类的.
;;把c语言风格设置为k&r风格
(add-hook 'c-mode-hook
'(lambda ()
(c-set-style "k&r")))
;;把C++语言风格设置为stroustrup风格
(add-hook 'c++-mode-hook
'(lambda()
(c-set-style "stroustrup")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C/C++设定;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;缩进策略
(defun my-indent-or-complete ()
(interactive)
(if (looking-at "\\>")
(hippie-expand nil)
(indent-for-tab-command)))
;;按键定义
(define-key c-mode-base-map [(return)] 'newline-and-indent)
(define-key c-mode-base-map [(meta \`)] 'c-indent-command)
;;能把一个代码块缩起来,需要的时候再展开
;; M-x hs-minor-mode
;; C-c @ ESC C-s show all
;; C-c @ ESC C-h hide all
;; C-c @ C-s show block
;; C-c @ C-h hide block
;; C-c @ C-c toggle hide/show
(load-library "hideshow")
(add-hook 'c-mode-hook 'hs-minor-mode)
(add-hook 'c++-mode-hook 'hs-minor-mode)
(add-hook 'java-mode-hook 'hs-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
(add-hook 'lisp-mode-hook 'hs-minor-mode)
(add-hook 'scheme-mode-hook 'hs-minor-mode)
(add-hook 'css-mode-hook 'hs-minor-mode)
(add-hook 'html-mode-hook 'hs-minor-mode)
(global-set-key (kbd "C-c C-:") 'hs-show-all);;显示
(global-set-key (kbd "C-c C-\"") 'hs-hide-all);;隐藏
;;输入左边的括号,就会自动补全右边的部分.包括(), "", [] , {} , 等等。
(defun my-common-mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(? ? _ "''")
(? ? _ """")
(? ? _ "()")
(? ? _ "[]")
(?{ \n > _ \n ?} >)))
(setq skeleton-pair t)
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "\'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'c-mode-hook 'my-common-mode-auto-pair)
(add-hook 'c++-mode-hook 'my-common-mode-auto-pair)
(add-hook 'java-mode-hook 'my-common-mode-auto-pair)
(add-hook 'lisp-mode-hook 'my-common-mode-auto-pair)
(add-hook 'php-mode-hook 'my-common-mode-auto-pair)
(add-hook 'python-mode-hook 'my-common-mode-auto-pair)
(add-hook 'html-mode-hook 'my-common-mode-auto-pair)
(add-hook 'scheme-mode-hook 'my-common-mode-auto-pair)
(add-hook 'css-mode-hook 'my-common-mode-auto-pair)
(add-hook 'sql-mode-hook 'my-common-mode-auto-pair)
(add-hook 'emacs-lisp-mode-hook 'my-common-mode-auto-pair)
(add-hook 'text-mode-hook 'my-common-mode-auto-pair)
(setq x-select-enable-clipboard t);支持emacs和外部程序的粘贴
(setq frame-title-format '("Emacs@ " buffer-file-name " " ));在标题栏显示buffer名称
;;ido的配置,这个可以使你在用C-x C-f打开文件的时候在后面有提示;
;;这里是直接打开了ido的支持,在emacs23中这个是自带的.
(ido-mode t)
(setq visible-bell t)
;;设置 sentence-end 可以识别中文标点。不用在 fill 时在句号后插入两个空格。
(setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)
;;可以递归的使用 minibuffer
(setq enable-recursive-minibuffers t)
;;设置个人信息
(setq user-full-name "B.Qnyd")
(setq user-mail-address "BB.Qnyd@gmail.com")
(setq track-eol t);; 当光标在行尾上下移动的时候,始终保持在行尾。
(setq Man-notify-method 'pushy);; 当浏览 man page 时,直接跳转到 man buffer。
;;设置home键指向buffer开头,end键指向buffer结尾
(global-set-key [home] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)
(setq default-fill-column 80);;把 fill-column 设为 80. 这样的文字更好读
;; 实现程序变量得自动对齐
(require 'align)
(global-set-key "\C-x\C-j" 'align)
;鼠标滚轮,默认的滚动太快,这里改为3行
(defun up-slightly () (interactive) (scroll-up 1))
(defun down-slightly () (interactive) (scroll-down 1))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)
(add-to-list 'load-path "/usr/share/emacs/site-lisp/xcscope.el")
;;(add-to-list 'load-path "~/lisp/cscope/contrib/xcscope/xcscope.el")
(require 'xcscope)
;;自动补全 yasnippet
(add-to-list 'load-path
"~/.emacs.d/plugins")
(require 'yasnippet-bundle)
(add-to-list 'load-path "~/.emacs.d/plugins/wcy-swbuff.el");;加载wcy-swbuff
(require 'wcy-swbuff)
;; then you can use
(global-set-key (kbd "
(global-set-key (kbd "
(setq wcy-switch-buffer-active-buffer-face 'highlight)
(setq wcy-switch-buffer-inactive-buffer-face 'secondary-selection )
;;=================================
(require 'psvn)
(require 'auto-complete+)
(require 'auto-complete-config)
(load-library "multi-gud.el")
(load-library "multi-gdb-ui.el")
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)
(setq gdb-many-windows t)
(require 'recentf)
;;(recentf-mode 1)
(defun recentf-open-files-compl ()
(interactive)
(let* ((all-files recentf-list)
(tocpl (mapcar (function
(lambda (x) (cons (file-name-nondirectory x) x))) all-files))
(prompt (append '("File name: ") tocpl))
(fname (completing-read (car prompt) (cdr prompt) nil nil)))
(find-file (cdr (assoc-ignore-representation fname tocpl)))))
(global-set-key [(control x)(control r)] 'recentf-open-files-compl)
;;(require 'thumbs)
(autoload 'table-insert "table" "WYGIWYS table editor")
;; session,可以保存很多东西,例如输入历史(像搜索、打开文件等的输入)、
;; register的内容、buffer的local variables以及kill-ring和最近修改的文件列表等。非常有用。
(require 'my-session)
(add-hook 'after-init-hook 'session-initialize)
;;全屏
(defun my-fullscreen ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0)))
;最大化
(defun my-maximized ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
;; 启动emacs时窗口最大化
(when window-system
(my-maximized))
;; 启动窗口大小
(when window-system
(setq default-frame-alist
'((height . 34) (width . 158) (menu-bar-lines . 20) (tool-bar-lines . 0))))
;;;;;;;;;;;;我的 Common Lisp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-to-list 'load-path "~/lisp/src/slime/")
(add-to-list 'load-path "~/lisp/src/slime/contrib")
(require 'slime)
(slime-setup '(slime-fancy slime-asdf slime-tramp))
(setq inferior-lisp-program "/usr/bin/sbcl --noinform"
lisp-indent-function 'common-lisp-indent-function ;lisp-indent-function
slime-complete-symbol-function 'slime-fuzzy-complete-symbol
slime-net-coding-system 'utf-8-unix
slime-startup-animation t
slime-default-lisp 'sbcl
slime-enable-evaluate-in-emacs nil
slime-log-events t
slime-outline-mode-in-events-buffer nil
;;slime-repl-return-behaviour :send-only-if-after-complete
slime-autodoc-use-multiline-p t
slime-use-autodoc-mode t
slime-highlight-compiler-notes t
slime-fuzzy-completion-in-place nil)
(global-set-key [f4] 'slime);F4进入Slime
(defun lisp-indent-or-complete (&optional arg)
(interactive "p")
(if (or (looking-back "^\\s-*") (bolp))
(call-interactively 'lisp-indent-line)
(call-interactively 'slime-indent-and-complete-symbol)))
(eval-after-load "lisp-mode"
'(progn
(define-key lisp-mode-map (kbd "TAB") 'lisp-indent-or-complete)))
;;;;;;;;;;;;;;;;;;;;;;代码跳转;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(global-set-key [f8] 'semantic-ia-fast-jump)
(global-set-key [S-f8]
(lambda ()
(interactive)
(if (ring-empty-p (oref semantic-mru-bookmark-ring ring))
(error "Semantic Bookmark ring is currently empty"))
(let* ((ring (oref semantic-mru-bookmark-ring ring))
(alist (semantic-mrub-ring-to-assoc-list ring))
(first (cdr (car alist))))
(if (semantic-equivalent-tag-p (oref first tag)
(semantic-current-tag))
(setq first (cdr (car (cdr alist)))))
(semantic-mrub-switch-tags first))))
(define-key c-mode-base-map [M-f1] 'semantic-analyze-proto-impl-toggle)
;;;;;;;;;;;;;;;;;;可视化书签;;;;;;;;;;;;;;;;;;;;;;;;;;
(enable-visual-studio-bookmarks)
;;;;;h/cpp切换;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'eassist nil 'noerror)
(define-key c-mode-base-map [M-f12] 'eassist-switch-h-cpp)
(setq eassist-header-switches
'(("h" . ("cpp" "cxx" "c++" "CC" "cc" "C" "c" "mm" "m"))
("hh" . ("cc" "CC" "cpp" "cxx" "c++" "C"))
("hpp" . ("cpp" "cxx" "c++" "cc" "CC" "C"))
("hxx" . ("cxx" "cpp" "c++" "cc" "CC" "C"))
("h++" . ("c++" "cpp" "cxx" "cc" "CC" "C"))
("H" . ("C" "CC" "cc" "cpp" "cxx" "c++" "mm" "m"))
("HH" . ("CC" "cc" "C" "cpp" "cxx" "c++"))
("cpp" . ("hpp" "hxx" "h++" "HH" "hh" "H" "h"))
("cxx" . ("hxx" "hpp" "h++" "HH" "hh" "H" "h"))
("c++" . ("h++" "hpp" "hxx" "HH" "hh" "H" "h"))
("CC" . ("HH" "hh" "hpp" "hxx" "h++" "H" "h"))
("cc" . ("hh" "HH" "hpp" "hxx" "h++" "H" "h"))
("C" . ("hpp" "hxx" "h++" "HH" "hh" "H" "h"))
("c" . ("h"))
("m" . ("h"))
("mm" . ("h"))))
;;;F12 u 更新当前版本
(global-set-key (kbd "C-u") 'vc-next-action)
;; 为各种只读mode加入vi的按键
(require 'man)
(require 'apropos)
(require 'log-view)
(require 'diff-mode)
(let ((list (list view-mode-map Man-mode-map apropos-mode-map completion-list-mode-map
log-view-mode-map compilation-mode-map diff-mode-map)))
(require 'grep)
(setq list (append list (list grep-mode-map))))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
'(cua-mode t nil (cua-base))
'(display-time-mode t)
'(show-paren-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 113 :width normal :foundry "microsoft" :family "Comic Sans MS")))))
;;用下面的办法对于编写 python, bash, per, awk, sed, 脚本的时候十分有用。在保存文件的时候,会自动给脚本增加可执行权限
(setq my-shebang-patterns
(list "^#!/usr/.*/perl\\(\\( \\)\\|\\( .+ \\)\\)-w *.*"
"^#!/usr/.*/sh"
"^#!/usr/.*/bash"
"^#!/bin/sh"
"^#!/.*/perl"
"^#!/.*/awk"
"^#!/.*/sed"
"^#!/bin/bash"))
(add-hook
'after-save-hook
(lambda ()
(if (not (= (shell-command (concat "test -x " (buffer-file-name))) 0))
(progn
;; This puts message in *Message* twice, but minibuffer
;; output looks better.
(message (concat "Wrote " (buffer-file-name)))
(save-excursion
(goto-char (point-min))
;; Always checks every pattern even after
;; match. Inefficient but easy.
(dolist (my-shebang-pat my-shebang-patterns)
(if (looking-at my-shebang-pat)
(if (= (shell-command
(concat "chmod u+x " (buffer-file-name)))
0)
(message (concat
"Wrote and made executable "
(buffer-file-name))))))))
;; This puts message in *Message* twice, but minibuffer output
;; looks better.
(message (concat "Wrote " (buffer-file-name))))))
(setq default-directory "~/");;默认目录
;; author: pluskid
;; 调用 stardict 的命令行程序 sdcv 来查辞典
;; 如果选中了 region 就查询 region 的内容,否则查询当前光标所在的单词
;; 查询结果在一个叫做 *sdcv* 的 buffer 里面显示出来,在这个 buffer 里面
;; 按 q 可以把这个 buffer 放到 buffer 列表末尾,按 d 可以查询单词
(global-set-key (kbd "C-c d") 'kid-sdcv-to-buffer)
(defun kid-sdcv-to-buffer ()
(interactive)
(let ((word (if mark-active
(buffer-substring-no-properties (region-beginning) (region-end))
(current-word nil t))))
(setq word (read-string (format "Search the dictionary for (default %s): " word)
nil nil word))
(set-buffer (get-buffer-create "*sdcv*"))
(buffer-disable-undo)
(erase-buffer)
(let ((process (start-process-shell-command "sdcv" "*sdcv*" "sdcv" "-n" word)))
(set-process-sentinel
process
(lambda (process signal)
(when (memq (process-status process) '(exit signal))
(unless (string= (buffer-name) "*sdcv*")
(setq kid-sdcv-window-configuration (current-window-configuration))
(switch-to-buffer-other-window "*sdcv*")
(local-set-key (kbd "d") 'kid-sdcv-to-buffer)
(local-set-key (kbd "q") (lambda ()
(interactive)
(bury-buffer)
(unless (null (cdr (window-list))) ; only one window
(delete-window)))))
(goto-char (point-min))))))))
;;启动mew
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)
(if (boundp 'read-mail-command)
(setq read-mail-command 'mew))
(autoload 'mew-user-agent-compose "mew" nil t)
(if (boundp 'mail-user-agent)
(setq mail-user-agent 'mew-user-agent))
(if (fboundp 'define-mail-user-agent)
(define-mail-user-agent
'mew-user-agent
'mew-user-agent-compose
'mew-draft-send-message
'mew-draft-kill
'mew-send-hook))
(setq mew-use-cached-password t)
(require 'color-theme)
(color-theme-calm-forest)
(setq user-full-name "B.Qnyd")
(setq user-mail-address "bb.qnyd@gmail.com")
;;w 写信
;;M-TAB 补齐收信人信息
;;Q 退出mew
;;i 收信
;;g 跳转邮箱
;;o 对邮件进行分类
;;d 把邮件标记为删除
;;* 作星号标记
;;u 清除标记
;;x 对所有标记进行处理
;;a 不带引用的回复,不建议使用
;;A 带引用的回复,推荐
;;f 转发邮件
;;y 保存邮件,会提示是保存整个邮件和是仅保存正文
;;SPACE 阅读邮件
;;ENTER 让阅读的邮件向上滚动一行
;;- 向下滚动一行
;;n 下一封邮件
;;p 前一封邮件
;;j 跳到某一封邮件
;;N 下一封带星号的邮件
;;P 上一封带星号的邮件
;;S 按某个指定项目对邮件排序
;;/ 按指定条件搜索邮件,并进入虚拟模式
;;tt 进入虚拟模式,根据线索查看,普通模式下是不可以的
;;C 如果设置了多个邮箱,用此切换
;;C-cC-m 编辑新邮件,放入草稿中
;;C-cC-c 发送邮件
;;C-cC-q 取消草稿
;;C-cC-a 插入附件
;;C-cTAB 插入签名
;;C-cC-l 转换当前邮件的编码格式
;;C-cC-y 复制部分邮件,带引用前缀
;;C-cC-t 复制部分邮件,不带引用前缀
;;C-cC-a 把当前的发信人加入地址薄
;;C-uC-cC-a 比C-cC-a多加入昵称和名字,推荐
(global-set-key [f6] 'mew)
(auto-image-file-mode);打开图片显示功能
(if window-system
(autoload 'keisen-mode "keisen-mouse" "MULE table" t)
(autoload 'keisen-mode "keisen-mule" "MULE table" t))
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(add-hook 'laTeX-mode-hook 'turn-on-reftex)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq org-todo-keywords
'((sequence "TODO(t)" "DOING(i!)" "HANGUP(h!)" "|" "DONE(d!)" "CANCEL(c!)")))
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
;;;;~/.mew.el 这个文件没有需要新建... 还有个密码保存没有,没搞定...
;;;; 谁知道enail发给我看看..email:bb.qnyd@gmail.com
;; Mew limits the size of receiveing messages to 54KB in default.
;; Messages larger than 54KB will marked 'T' by Mew. You can receive
;; the entire messages later.
;; This setting makes Mew remove the limitation. See Mew FAQ 3.2
(setq mew-pop-size 0)
;;(setq mew-imap-prefix-list '("#mh/" "#mhinbox"))
;;(setq mew-auto-get t)
(setq toolbar-mail-reader 'Mew)
;; input passwd once and won't ask anymore untill quit Mew.
(setq mew-use-cached-passwd t)
(setq mew-passwd-timer-unit 999)
(setq mew-passwd-lifetime 999)
(set-default 'mew-decode-quoted 't)
(setq mew-prog-pgp "gpg")
;; leave messages in mail server
(setq mew-pop-ssl-port t)
(setq mew-pop-delete t)
;; mark the unread mail with a 'U'
(setq mew-use-unread-mark t)
;; Send the mails in +queue when enter `i'.
;;(setq mew-auto-flush-queue t)
(setq mew-ssl-verify-level 0)
(setq mew-prog-ssl "/usr/bin/stunnel")
(setq mew-config-alist
;;Gmail
;; misc
'(
("default"
("name" . "B.Qnyd")
("user" . "bb.qnyd")
("mail-domain" . "gmail.com")
("proto" . "+")
("pop-ssl" . t)
("prog-ssl" . "/usr/bin/stunnel")
("pop-auth" . pass)
("pop-server" . "pop.gmail.com")
("pop-ssl-port" . "995")
("pop-user" . "bb.qnyd@gmail.com")
("smtp-ssl" . t)
("smtp-ssl-port". "465")
("smtp-auth-list" . ("PLAIN" "LOGIN" "CRAM-MD5"))
("smtp-user" . "bb.qnyd@gmail.com")
("smtp-server" . "smtp.gmail.com"))))
;;Thread
;;(setq mew-prog-imls-arg-list '("--thread=yes" "--indent=2"))
;;(setq mew-use-fancy-thread t)
;;(setq mew-fancy-thread-indent-strings [" +" " +" " |" " "] )
;;(setq mew-use-thread-separator nil)
;;(setq mew-thread-separator "--")
;; Open a html mail in external browser
;; You must open the browser manually first.
;; Look -> http://www.mew.org/pipermail/mew-int/2005-March/001530.html
;; only Mozilla or Firefox is valid.No support Opera.
;; Look -> http://www.mew.org/pipermail/mew-int/2007-June/001814.html
;;(setq mew-prog-text/html-ext
;;'("firefox" ("-a" "firefox" "-remote" "openFile(%s)") t))
;; Signature
(setq mew-signature-file "~/Mail/signature")
(setq mew-signature-insert-last t)
;; Biff - check new mail
(setq mew-use-biff t) ;; nil
(setq mew-use-biff-bell t) ;; nil
(setq mew-pop-biff-interval 5) ;; 5 (minutes)
;; cite
(setq mew-cite-fields '("From:" "Subject:" "Date:" "Message-ID:"))
(setq mew-cite-format "From: %s\nSubject: %s\nDate: %s\nMessage-ID: %s\n\n")
(setq mew-refile-guess-alist
'((nil . "%[Gmail]/All Mail")))
(auto-image-file-mode);打开图片显示功能
Linux Emacs 中编写GTK应用程序
//主窗口中按钮的回调函数
void on_button_clicked(GtkWidget* button, gpointer userdata)
{
GtkWidget *dialog;创建带确认按钮的对话框,父控件为空
dialog = gtk_message_dialog_new(NULL,
GTK_DIALOG_MODAL |GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
(gchar*)userdata);
gtk_dialog_run(GTK_DIALOG(dialog));//显示并运行对话框
gtk_widget_destroy(dialog);//销毁对话框
}
//主函数
int main(int argc, char* argv[])
{
GtkWidget *window, *button;
//初始化GTK+程序
gtk_init(&argc, &argv);
//创建窗口,并为窗口的关闭信号加回调函数以便退出
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window),"delete_event",
G_CALLBACK(gtk_main_quit),NULL);
gtk_window_set_title(GTK_WINDOW(window),"Hello World!");
gtk_container_set_border_width(GTK_CONTAINER(window),10);
//创建按钮控件,为单击信号加回调函数,将其放入窗口中
button=gtk_button_new_with_label("Hello World!");
g_signal_connect(G_OBJECT(button),"clicked",
G_CALLBACK(on_button_clicked),(gpointer)"你好!\n 自由的世
界。");
gtk_container_add(GTK_CONTAINER(window),button);
//下面函数显示窗口控件同时显示其中的所有其它控件
gtk_widget_show_all(window);
gtk_main();
return FALSE;
}
我的windows-emacs配置
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
'(display-time-mode t)
'(show-paren-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;(setq visible-bell t);关闭出错提示声
(setq inhibit-startup-message t);关闭开启画面
(setq column-number-mode t);
;------------------------------- 设置界面-------------------------------
(set-cursor-color "Wheat")
(set-mouse-color "Wheat")
(set-foreground-color "Wheat")
(set-background-color "DarkSlateGray")
(if window-system
(setq default-frame-alist
(append
'( (top . 100)
(left . 100)
(width . 150)
(height . 50))
default-frame-alist))
)
;-----------------------------end of 设置界面--------------------------
;------------------------------- 设置显示时间---------------------------
(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
;--------------------------------endof 设置显示时间---------------------
;-------------------------------快捷键---------------------------------
; (define-key [(f7)] 'compile)
;;;;以下是我的快捷键设置
(global-set-key [(meta g)] 'goto-line)
;;(global-set-key [(meta ?/)] 'hippie-expand)
;; F12 t 从当前缓冲区建立任务
(global-set-key (kbd "
;; F12 g 切换到当日的任务
;;(global-set-key (kbd "
(global-set-key (kbd "
(global-set-key (kbd "
;; F12 r 添加当前备忘录
(global-set-key (kbd "
;; F12 c 切换到日历
(global-set-key (kbd "
;;;F2:进入wiki-mode模式
;;(global-set-key [(f2)] 'emacs-wiki-find-file)
;;;F3:切换到dired模式
;;(global-set-key [(f3)] 'dired)
;;;F4:切换到shell模式
;;(global-set-key [(f4)] 'ansi-term)
;;;F5:打开speedbar
(global-set-key [(f5)] 'speedbar)
;;;;F7:调用compile
;;(global-set-key (kbd "
;;;Alt+s : 让speedbar获得焦点
(global-set-key (kbd "M-s") 'speedbar-get-focus)
;;;F9:列举我的书签
(global-set-key (kbd "
;;;F10:添加当前页到书签中
(global-set-key [(f10)] 'bookmark-set)
;;;F12 u 更新当前版本
(global-set-key (kbd "
;;------------------------End of 快捷键 ---------------------
;(setq kill-ring-max 200);; 设置粘贴缓冲条目数量
(setq enable-recursive-minibuffers t);; 设置递归使用minibuffer
;;(setq scroll-margin 3
;; scroll-conservatively 10000) ;;防止页面滚动时跳动
(setq default-major-mode 'text-mode);;设置默认模式是text mode
(show-paren-mode t)
(setq show-paren-style 'parentheses) ;; 设置显示括号匹配,但不跳转
(mouse-avoidance-mode 'animate) ;;让鼠标不要挡住光标
;------------------------------程序语言--------------------------------
;;;; CC-mode配置 http://cc-mode.sourceforge.net/
(require 'cc-mode)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
;;;;根据后缀判断所用的mode
;;;;注意:我在这里把.h关联到了c++-mode
(setq auto-mode-alist
(append '(("\\.h$" . c++-mode)) auto-mode-alist))
;;;;我的C/C++语言编辑策略
(defun my-c-mode-common-hook()
(setq tab-width 4 indent-tabs-mode nil)
;;; hungry-delete and auto-newline
(c-toggle-auto-hungry-state 1)
;;按键定义
(define-key c-mode-base-map [(control \`)] 'hs-toggle-hiding)
(define-key c-mode-base-map [(return)] 'newline-and-indent)
(define-key c-mode-base-map [(f7)] 'compile)
(define-key c-mode-base-map [(f8)] 'ff-get-other-file)
(define-key c-mode-base-map [(meta \`)] 'c-indent-command)
;; (define-key c-mode-base-map [(tab)] 'hippie-expand)
(define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
;;预处理设置
(setq c-macro-shrink-window-flag t)
(setq c-macro-preprocessor "cpp")
(setq c-macro-cppflags " ")
(setq c-macro-prompt-flag t)
(setq hs-minor-mode t)
(setq abbrev-mode t)
(setq tab-width 4 indent-tabs-mode nil)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;;;;我的C++语言编辑策略
(defun my-c++-mode-hook()
(setq tab-width 4 indent-tabs-mode nil)
(c-set-style "stroustrup")
(define-key c++-mode-map [f3] 'replace-regexp)
)
(add-hook 'c++-mode-hook 'my-c++-mode-hook)
;;;;C/C++语言启动时自动加载semantic对/usr/include的索引数据库
(setq semanticdb-search-system-databases t)
(add-hook 'c-mode-common-hook
(lambda ()
(setq semanticdb-project-system-databases
(list (semanticdb-create-database
semanticdb-new-database-class
"/usr/include")))))
;;;;我的Java语言编辑策略
(defun my-java-mode-hook()
(setq tab-width 4 indent-tabs-mode nil)
)
(add-hook 'java-mode-hook 'my-java-mode-hook)
(setq ansi-color-for-comint-mode t)
(customize-group 'ansi-colors)
(kill-this-buffer);关闭customize窗口
;自定义按键
(global-set-key [f8] 'other-window);F8窗口间跳转
(global-set-key [C-return] 'kill-this-buffer);C-return关闭当前buffer
(global-set-key [f10] 'split-window-vertically);F10分割窗口
(global-set-key [f11] 'delete-other-windows);F11 关闭其它窗口
(global-set-key [f1] 'my-fullscreen);F1 全屏
(global-set-key (kbd "C-.") 'backward-page);文件首
(global-set-key (kbd "C-/") 'forward-page);文件尾
;普通设置
(setq make-backup-files nil);不产生备份文件
(global-font-lock-mode t);语法高亮
(auto-image-file-mode t);打开图片显示功能
(fset 'yes-or-no-p 'y-or-n-p);以 y/n代表 yes/no
(column-number-mode t);显示列号
(show-paren-mode t);显示括号匹配
(tool-bar-mode nil);去掉那个大大的工具栏
(scroll-bar-mode nil);去掉滚动条
;(mouse-avoidance-mode 'animate);光标靠近鼠标指针时,让鼠标指针自动让开
(setq mouse-yank-at-point t);支持中键粘贴
(transient-mark-mode t);允许临时设置标记
(setq x-select-enable-clipboard t);支持emacs和外部程序的粘贴
(setq frame-title-format '("" buffer-file-name "@emacs" ));在标题栏显示buffer名称
(setq default-fill-column 80);默认显示 80列就换行
;鼠标滚轮,默认的滚动太快,这里改为3行
(defun up-slightly () (interactive) (scroll-up 3))
(defun down-slightly () (interactive) (scroll-down 3))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)
(global-set-key [f11] 'my-fullscreen) ;; 启动全屏的快捷键
;全屏
(defun my-fullscreen ()
(interactive)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C/C++设定;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;缩进策略
(defun my-indent-or-complete ()
(interactive)
(if (looking-at "\\>")
(hippie-expand nil)
(indent-for-tab-command)))
;补全优先级
(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-functions-list
'(
senator-try-expand-sematic
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)
(add-hook 'semantic-init-hooks 'semantic-idle-completions-mode)
;;自动补全括号
(defun my-c-mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(?` ?` _ "''")
(?\( _ ")")
(?\[ _ "]")
(?{ \n > _ \n ?} >)
(?\" _ "\"")))
(setq skeleton-pair t)
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "\"") 'skeleton-pair-insert-maybe))
(add-hook 'c-mode-hook 'my-c-mode-auto-pair)
(add-hook 'c++-mode-hook 'my-c-mode-auto-pair)
;; 输入左边的括号,就会自动补全右边的部分.包括(), '', [] , {} ,""
(setq auto-save-default nil);不生成名为#filename# 的临时文件
(require 'linum)
(global-linum-mode t)
Emacs 自动补全强大的auto-complete
下载地址
(add-to-list 'load-path
"~/.emacs.d/")
(require 'auto-complete+)
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)
注意: auto-complete+ 是ahei改写的扩展可以去Emacs中文网下载。







