码迷,mamicode.com
首页 > 系统相关 > 详细

个人的Emacs配置文件

时间:2014-12-26 14:46:09      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:

我的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)

效果图:

技术分享

个人的Emacs配置文件

标签:

原文地址:http://blog.csdn.net/u014488381/article/details/42170053

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!