http://www.freebsdchina.org/forum/viewtopic.php?p=202881
1. 先安装tiff, ungif, xpm, jpeg, png, gtk, ncurses的开发包。
2. 下载emacs23的代码
代码: |
cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co -r emacs-unicode-2 emacs |
3.
代码: |
$./configure --enable-font-backend --with-xft --with-freetype --with-gtk --with-xpm --with-gif --with-tiff --with-png --with-jpeg $make bootstrap $make $su #make install #exit |
4. 安装wqy字体,在emacs下面wqy中文字体的效果比较好,当然你也可以用微软雅黑,我是桌面用微软雅黑,emacs用wqy。字体设置记得要添加到/etc/X11/xorg.conf中。
英文用dejavu sans mono字体,不要用雅黑的英文字体,雅黑的英文是非等宽字体,在其他软件中打开这些写好的代码会变形(字体的间距变了)。
5. ~/.Xresources中添加
代码: |
Emacs.FontBackend: xft Xft.antialias: 1 Xft.hinting: 1 Xft.hintstyle: hintfull Xft.rgba: rgb |
然后
代码: |
$xrdb -load ~/.Xresources |
6. 到www.xref-tech.com下载xref的1.x版,1.x版是免费的,2.x则要收费。
xref按f8有补全功能
7. 到sf.net下载ecb, cedet, 解压代码, make all,
然后复制整个目录到/usr/local/share/emacs/site-lisp里面,并将目录改名为ecb, cedet。
8. 安装cscope,网上下载xcscope.el,放到/usr/local/share/emacs/site-lisp
9. 网上下载redo.el, 放到/usr/local/share/emacs/site-lisp
10. 网上下载emacs-goodies-el,将里面的emacs-goodies-el目录放到/usr/local/share/emacs/site-lisp
=========================================================================================================
我的.emacs文件
代码: |
;; 字体设置 ;; -------------------------------------------------------------------------- ;; 定义字体集 (create-fontset-from-fontset-spec "-*-dejavu sans mono-medium-r-normal--13-*-*-*-*-*-fontset-fixend") ;; 设置默认字体 (set-default-font "fontset-fixend") ;; 新建frame时也应用字体设置 (setq default-frame-alist (append '((font . "fontset-fixend")) default-frame-alist)) ;; 设置中文字体 (set-fontset-font "fontset-default" nil "-*-wenquanyi bitmap song-medium-*-normal--12-*-*-*-*-*-iso10646-1" nil 'prepend) (set-fontset-font "fontset-fixend" 'kana "-*-wenquanyi bitmap song-medium-*-normal--12-*-*-*-*-*-iso10646-1" nil 'prepend) (set-fontset-font "fontset-fixend" 'han "-*-wenquanyi bitmap song-medium-*-normal--12-*-*-*-*-*-iso10646-1" nil 'prepend) (set-fontset-font "fontset-fixend" 'cjk-misc "-*-wenquanyi bitmap song-medium-*-normal--12-*-*-*-*-*-iso10646-1" nil 'prepend) ;; 屏幕设置 ;; -------------------------------------------------------------------------- ;; 全屏 (defun my-fullscreen () (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_FULLSCREEN" 0))) ;; 水平最大化 (defun my-maximized-horz () (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))) ;; 垂直最大化 (defun my-maximized-vert () (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0))) ;; 最大化 (defun my-maximized () (my-maximized-vert) (my-maximized-horz)) ;; 启动时最大化 (cond ((eq window-system 'x) (my-maximized) ) ) ;; 插件设置 ;; -------------------------------------------------------------------------- ;; el文件装载路径 (add-to-list 'load-path "/usr/share/emacs/site-lisp/") (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/") (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/ecb/") (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/emacs-goodies-el/") ;; 如果在x-windows中, 另一个条件为(not window-system) (cond ((eq window-system 'x) ;; 设置界面风格 (require 'color-theme) (color-theme-classic))) ;; 启用cedet (load-file "/usr/local/share/emacs/site-lisp/cedet/common/cedet.el") (semantic-load-enable-code-helpers) ;; (semantic-load-enable-guady-code-helpers) ;; 启用tabbar标签插件 (require 'tabbar) (tabbar-mode t) ;; 设置ecb (cond ((eq window-system 'x) (require 'ecb) (setq ecb-auto-activate t ecb-auto-compatibility-check nil ecb-version-check nil ecb-tip-of-the-day nil) (setq ecb-source-path (quote ("/home/fixend/c" "/home/fixend/cpp" "/home/fixend/cc" "/home/fixend"))) ; ecb代码路径 ) ) ;; 设置xref ;; Xrefactory configuration part ;; (defvar xref-current-project nil) ;; can be also "my_project_name" (defvar xref-key-binding 'global) ;; can be also 'local or 'none (setq load-path (cons "/usr/local/share/xref/emacs" load-path)) (setq exec-path (cons "/usr/local/share/xref" exec-path)) (load "xrefactory") ;; end of Xrefactory configuration part ;; (message "xrefactory loaded") ;; 启用xcscope (require 'xcscope) ;; 加入会话功能 (require 'session) (add-hook 'after-init-hook 'session-initialize) (load "desktop") (desktop-save-mode) ;; 启用ibuffer (require 'ibuffer) ;; 启用redo (require 'redo) (global-set-key ( kbd "C-.") 'redo) ;; 启用dired-x (require 'dired-x) ;; 补全,提示 ;; -------------------------------------------------------------------------- ;; 补全优先级 (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)) ;; gdb和shell设置 ;; -------------------------------------------------------------------------- ;; 非交互式编译 (defun do-compile () "Save buffers and start compile" (interactive) (save-some-buffers t) (setq compilation-read-command nil) (compile compile-command) (setq compilation-read-command t)) ;; shell,gdb退出后,自动关闭该buffer (defun kill-buffer-on-exit (process state) (message "%s" state) (if (or (string-match "exited abnormally with code.*" state) (string-match "finished" state)) (kill-buffer (current-buffer)))) (defun sg-mode-hook-func () (set-process-sentinel (get-buffer-process (current-buffer)) 'kill-buffer-on-exit)) (add-hook 'shell-mode-hook 'sg-mode-hook-func) (add-hook 'gdb-mode-hook 'sg-mode-hook-func) ;; 跳转设置 ;; -------------------------------------------------------------------------- ;; 跳转函数,类似vi的f键 (defun wy-go-to-char (n char) "Move forward to Nth occurence of CHAR. Typing `wy-go-to-char-key' again will move forwad to the next Nth occurence of CHAR." (interactive "p\ncGo to char: ") (search-forward (string char) nil nil n) (while (char-equal (read-char) char) (search-forward (string char) nil nil n)) (setq unread-command-events (list last-input-event))) (define-key global-map (kbd "C-c a") 'wy-go-to-char) ;; 普通设置 ;; -------------------------------------------------------------------------- (cua-mode '(t nil (cua-base))) ; 启动cua复制粘贴模式 (tool-bar-mode nil) ; 去丢工具栏 (column-number-mode t) ; 显示列号 (global-font-lock-mode t) ; 语法高亮 (show-paren-mode t) ; 显示括号匹配 (transient-mark-mode t) ; 高亮被选择的区域 (mouse-avoidance-mode 'animate) ; 鼠标指针自动避开光标 (setq inhibit-splash-screen t) ; 禁止开机画面 (setq make-backup-files nil) ; 不产生备份文件 (setq visible-bell t) ; 关闭喇叭 (setq kill-whole-line t) ; 在行首C-k时,同时删除该行 (setq x-select-enable-clipboard t) ; 支持emacs和外部程序的复制粘贴 (setq default-major-mode 'text-mode) ; 一打开就启用text模式 (setq default-tab-width 4) ; 设置tab长度 (setq default-fill-column 80) ; 设置默认列数 (setq-default indent-tabs-mode nil) ; 用空格代替tab (setq kill-ring-max 200) ; 设置删除纪录 (setq require-final-newline t) ; 文件必须以空行结束 (setq show-paren-style 'parentheses) ; 设置括号匹配的方式 (setq dired-recursive-deletes t) ; 可以递归地删除目录 (setq dired-recursive-copies t) ; 可以递归地进行目录拷贝 (setq bookmark-default-file "~/.emacs.d/.emacs.bmk") ; 书签文件的路径及文件名 (setq bookmark-save-flag t) ; 自动保存/读取书签 ;; 改变 Emacs 固执的要你回答 yes 的行为。按 y 或空格键表示 yes,n 表示 no (fset 'yes-or-no-p 'y-or-n-p) ;; 解决emacs shell显示问题 (setq ansi-color-for-comint-mode t) (customize-group 'ansi-colors) (kill-this-buffer) ; 关闭设置所产生的定制窗口 ;; c-mode设置 ;; -------------------------------------------------------------------------- ;; c-mode公共设置 (defun my-c-mode-common-hook () (setq default-tab-width 4) (setq tab-width 4) (setq c-basic-offset 4) (hs-minor-mode t)) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) ;; C语言设置 (defun my-c-mode-hook () (c-set-style "cc-mode")) (add-hook 'c-mode-hook 'my-c-mode-hook) ;; C++设置 (defun my-c++-mode-hook () (c-set-style "stroustrup")) (add-hook 'c++-mode-hook 'my-c++-mode-hook) ;; 快捷键设置 ;; -------------------------------------------------------------------------- (global-set-key [f1] 'shell) ; 进入shell (global-set-key [C-f9] 'gdb) ; 调试 (setq compile-command "make -f Makefile") ; 编译 (global-set-key [f9] 'do-compile) (global-set-key [f10] 'speedbar) ; 启动/关闭speedbar (global-set-key (kbd "M-\[") 'hs-hide-block) ; 隐藏块 (global-set-key (kbd "M-\]") 'hs-show-block) ; 显示块 (global-set-key [C-f12] 'comment-or-uncomment-region) ; 注释 / 取消注释 (global-set-key [f12] 'c-indent-line-or-region) ; 格式化代码 (global-set-key (kbd "C-`") 'ecb-goto-window-sources) ; 切换到ecb sources窗口 (global-set-key [C-tab] 'other-window) ; 切换窗口 (global-set-key [M-return] 'delete-other-windows) ; 关闭其他窗口 (global-set-key "\C-xk" 'kill-this-buffer) ; 关闭当前buffer (global-set-key (kbd "s-SPC") 'set-mark-command) ; 改变set mark键 ;; 补全命令 (global-set-key [M-/] 'hippie-expand) (global-set-key "\C-\\" 'semantic-ia-complete-symbol-menu) ;; 显示buffer列表 (global-set-key (kbd "C-x C-b") 'ibuffer) ;; 跳转到当前目录的Dired (global-set-key "\C-x\C-j" 'dired-jump) ;; 跳转到寄存器指定的位置 (global-set-key "\C-xj" 'jump-to-register) ;; 跳转到全局定义 (global-set-key "\C-xg" 'cscope-find-global-definition-no-prompting) ;; emacs自动生成的设置 ;; -------------------------------------------------------------------------- (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. ) (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. ) |