`
s103y
  • 浏览: 111600 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

ubuntu(dapper)的emacs( 我刚刚在网上找到的)

阅读更多

以 前在linux下一直都用vim,但是对vim的这样的模态编辑器一直不太适应,总觉得esc键摁起来一点也不方便,不小心摁成F1了就更麻烦了。所以决 定试试emacs,但是ubuntu的emacs对中文支持的很不好,需要自己作大量的配置工作,而我对linux的态度一向是能用就好,尽量不自找麻 烦,所以就这样拖了很长时间。可惜等到现在ubuntu的emacs也没什么改进,只好抽时间按照网上的资料配了一下emacs,基本达到我的要求了。把 配置过程写一下,免得以后忘了。

1. 安装emacs及其插件
sudo apt-get install emacs //ubuntu 缺省的安装的是xemacs21
sudo apt-get install speedbar
sudo apt-get install eieio
sudo apt-get install semantic
sudo apt-get install ecb // 这个据说要在上面三个装完才可以装,我没试过打乱顺序装可以不可以。
sudo apt-get install emacs_wiki
下载color-theme ,解压缩,sudo cp color-theme.el /usr/share/emacs/site-lisp
下载mule-gbk , 解压缩,进入目录,
./configure
make
sudo make install
在.emacs.el中加上(require 'mule-gbk)即可。按照网上文章的说法,似乎还要做指定gbk字库之类的工作,但是我不知道哪个字库是gbk字库,所以什么也没改,只在.emacs.el中加了一句话。

现在大致就装了这么些东西,其中前几个是编程需要用到的,mule-gbk是用来支持中文的,我曾将尝试自己配中文环境,但是总有无法使用X的scim输入法,最后还是找到了这个mule-gbk。


2. 配置emacs
上网找了一个.emacs.el文件,在http://www.emacs.cn/ 有些资源,我随便挑了一个ljs 的配置文件,他的配置文件是用在windows下的,所以需要修改一下。主要修改的地方包括: site-list的path,字库的配置,去掉备份的配置,增加了color-theme,增加了对鼠标滚轮的支持,增加了对mule-gbk的支持。
关于字库的配置,可以在console下用xlsfonts查看,选一个合适的添加到.emacs.el中

3. 缺点
1. 启动太慢
2. 还是不能拷贝中文

;;; Load mule-gbk
(require 'mule-gbk)

(require 'un-define)
(set-language-environment 'utf-8)
(set-language-environment 'Chinese-GB)
(set-keyboard-coding-system 'euc-cn)
(set-clipboard-coding-system 'euc-cn)
(set-terminal-coding-system 'euc-cn)
(set-buffer-file-coding-system 'euc-cn)
(set-selection-coding-system 'euc-cn)
(modify-coding-system-alist 'process "*" 'euc-cn)
(setq default-process-coding-system
'(euc-cn . euc-cn))
(setq-default pathname-coding-system 'euc-cn)



;; Setup GBK environment
;(set-terminal-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")

;; 设置字体

;(create-fontset-from-fontset-spec
; "-misc-fixed-medium-r-*-*-20-*-*-*-c-*-fontset-global,
; chinese-gb2312:-song-*-medium-r-normal-*-20-*-*-*-*-*-gb2312.1980-*")

;(setq default-frame-alist
; (append '((font . "fontset-global")) default-frame-alist))
;(set-default-font "-adobe-courier-medium-r-normal--18-180-75-75-m-110-iso10646-1")

;;;;;;;;;; global setting
;(set-scroll-bar-mode nil) ;; 去掉滚动条
(tool-bar-mode -1) ;; 去掉工具栏
(setq require-final-newline t) ;; 以空行结束
(add-to-list 'load-path (expand-file-name "/usr/share/emacs/site-lisp/")) ;; set load-path
(setq visible-bell t) ;; 关闭出错时的提示声
(setq inhibit-startup-message t) ;;关闭开启画面
(setq column-number-mode t) ;; 显示列号
(setq mouse-yank-at-point t) ;; 用光标定位文本插入位置
(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) ;;让鼠标不要挡住光标
(setq user-full-name "locky")
(setq user-mail-address "lockister@gmail.com")
(setq frame-title-format '("" buffer-file-name "@" user-login-name ":" system-name)) ;;设置缓冲标题
(global-font-lock-mode t) ;; 进行语法加亮
(setq next-line-add-newlines nil
resize-mini-windows t
track-eol t
kill-whole-line t
Man-notify-method 'pushy
woman-cache-level 2
woman-cache-filename nil
uniquify-buffer-name-style 'forward
vc-follow-symlinks t
line-move-ignore-invisible t
ring-bell-function 'ignore
tooltip-gud-tips-p t)

;; 设置备份版本控制 start
;(setq version-control t
; kept-old-versions 2
; kept-new-versions 5
; delete-old-versions t
; backup-directory-alist
; '(("." . "D:/tmp")
; (cons tramp-file-name-regexp nil))
; backup-by-copying t
; backup-by-copying-when-linked t
; backup-by-copying-when-mismatch t)
;(setq dired-kept-versions 1)
;; 设置备份版本控制 end

;(setq dired-recursive-copies 'top) ;;让dired可以递归地拷贝和删除目录
;(setq dired-recursive-deletes 'top) ;;

;; 设置显示时间
(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)

;;;;;;;;; 设置界面 start
(require 'color-theme)
;(color-theme-subtle-hacker)
(color-theme-deep-blue)
(setq my-color-themes (list 'color-theme-billw 'color-theme-jsc-dark
'color-theme-sitaramv-solaris 'color-theme-resolve
'color-theme-classic 'color-theme-jonadabian-slate
'color-theme-kingsajz 'color-theme-shaman
'color-theme-subtle-blue 'color-theme-snowish
'color-theme-sitaramv-nt 'color-theme-wheat))


(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 . 80)
; (left . 100)
; (width . 110)
; (height . 35))
; default-frame-alist))
;)
;;;;;;;;; 设置界面 end


;;;;; Esay Edit for C++/C programming
;; TAB and RET auto align and indent
(add-hook 'c++-mode-hook
(lambda ()
(c-set-style "bsd")
(hs-minor-mode)
(local-set-key "\C-c\t" 'complete-symbol)
(local-set-key "\C-m" 'newline-and-indent)
(setq mslk-c++-key (make-keymap))
(local-set-key "\C-j" mslk-c++-key)
(define-key mslk-c++-key "\C-j" 'complete-symbol)
(define-key mslk-c++-key "\C-o" 'hs-hide-all)
(define-key mslk-c++-key "\C-p" 'hs-show-all)
(define-key mslk-c++-key "\C-h" 'hs-hide-block)
(define-key mslk-c++-key "\C-u" 'hs-show-block)
(define-key mslk-c++-key "\C-l" 'hs-hide-level)
(define-key mslk-c++-key "\C-m" 'hs-toggle-hiding)
))
(add-hook 'c-mode-hook 'c++-mode)
(defun my-indent-or-complete ()
(interactive)
(if (looking-at "\\>")
(hippie-expand nil)
(indent-for-tab-command)))
(add-hook 'c-mode-common-hook
(function (lambda ()
(define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
(define-key c-mode-base-map [(control m)] 'align-newline-and-indent)
(c-toggle-auto-state))))


;;;;;;;;;;;;;;;; 调用Lisp扩展包
;;;;;;;; load ido.el
(require 'ido)
(ido-mode t)

(autoload 'table-insert "table" "WYGIWYS table editor") ;;所见即所得做表格

(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)

;;;;;;;;;;; global key setting
(global-set-key [home] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)
;; wheel mouse
(global-set-key [mouse-4] 'scroll-down)
(global-set-key [mouse-5] 'scroll-up)
(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.
'(blink-cursor-mode nil nil (frame))
'(column-number-mode t)
'(cua-mode nil)
;'(global-font-lock-mode t nil (font-core))
'(show-paren-mode t nil (paren)))
(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.
)

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics