个人的Emacs配置文件

我的Emacs版本:GNU Emacs 23.1.1 (x86_64-redhat-linux-gnu, GTK+ Version 2.18.9)

1:下载http://ftp.twaren.net/Unix/NonGNU/color-theme/color-theme-6.6.0.tar.gz  然后自己解压

2:把color-theme-6.6.0.tar.gz解压后的 color-theme.el和 theme文件夹 复制到 ~/.emacs.d文件夹内(如果~/.emacs.d文件夹不存在请先建立)。

3:创建配置文件 .emacs。目录在你的家目录,用户目录下。

配置文件为:

;;将~/.emacs.d/添加到加载路径
(add-to-list 'load-path "~/.emacs.d/")
(require 'color-theme)
(color-theme-initialize) 
;; 这个是你选择的主题,后面的calm forest就是它的名字,注意使用小写。
(color-theme-calm-forest)

;;竖线光标
(setq-default cursor-type 'bar) 


;;自动换行缩进
(global-set-key (kbd "RET") 'newline-and-indent)
;;; ### Indent ###
;;; --- 缩进设置
(setq-default indent-tabs-mode t)       ;默认不用空格替代TAB
(setq default-tab-width 4)              ;设置TAB默认的宽度
(dolist (hook (list                     ;设置用空格替代TAB的模式
               'emacs-lisp-mode-hook
               'lisp-mode-hook
               'lisp-interaction-mode-hook
               'scheme-mode-hook
               'c-mode-hook
               'c++-mode-hook
               'java-mode-hook
               'haskell-mode-hook
               'asm-mode-hook
               'emms-tag-editor-mode-hook
               'sh-mode-hook
               ))
  (add-hook hook '(lambda () (setq indent-tabs-mode nil))))

;;设置程序的对齐风格  
;(c-set-style "K&R") 

;;撤消  
(global-set-key (kbd "C-z") 'undo)  
;;全选  
(global-set-key (kbd "C-a") 'mark-whole-buffer)  
;;保存  
(global-set-key (kbd "C-s") 'save-buffer)  

;;支持emacs和外部程序的粘贴  
(setq x-select-enable-clipboard t)

;显示匹配括号  
(show-paren-mode t)  
(setq show-paren-style 'parentheses)  

;;设置光标闪烁或者不闪
;;(blink-cursor-mode l)  

;;设置tab宽度为4  
(setq-default indent-tabs-mode  nil)  
(setq tab-width 4 c-basic-offset 4)  
(setq tab-width 4 indent-tabs-mode nil)  

;;不要生成临时文件  
(setq-default make-backup-files nil)  

;;hanghao
(global-linum-mode 'linum-mode)

;;高亮c中的宏定义
;;(load-file "/home/.emacs.d/ctypes.el") 
(require 'ctypes)
(ctypes-auto-parse-mode 1)

;;Buffer管理
;; 按下C-x k立即关闭掉当前的buffer
(global-set-key (kbd "C-x k") 'kill-this-buffer)

;; 一打开就起用 text 模式。
(setq default-major-mode 'c-mode)

;;去掉欢迎界面
(setq inhibit-startup-message t)

;;buffer分割模式
(defun toggle-window-split ()
  "Vertical split shows more of each line, horizontal split shows
more lines. This code toggles between them. It only works for
frames with exactly two windows."
  (interactive)
  (if (= (count-windows) 2)
      (let* ((this-win-buffer (window-buffer))
             (next-win-buffer (window-buffer (next-window)))
             (this-win-edges (window-edges (selected-window)))
             (next-win-edges (window-edges (next-window)))
             (this-win-2nd (not (and (<= (car this-win-edges)
                                         (car next-win-edges))
                                     (<= (cadr this-win-edges)
                                         (cadr next-win-edges)))))
             (splitter
              (if (= (car this-win-edges)
                     (car (window-edges (next-window))))
                  'split-window-horizontally
                'split-window-vertically)))
        (delete-other-windows)
        (let ((first-win (selected-window)))
          (funcall splitter)
          (if this-win-2nd (other-window 1))
          (set-window-buffer (selected-window) this-win-buffer)
          (set-window-buffer (next-window) next-win-buffer)
          (select-window first-win)
          (if this-win-2nd (other-window 1))))))

(global-set-key [(control c) (|)] 'toggle-window-split)  
(global-set-key [(f5)] 'speedbar)

;;鼠标滚轮,默认的滚动太快,这里改为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)

;;启动Emacs自动设置为两个窗口(上下各一个)
;;(split-window-vertically)

效果图:

技术分享

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。