我的 emacs配置

;;设置插件的加载路径,放到~/emacs_dir/packages/下
(setq my-dot-path "~/emacs_dir/")  ;;设置 my-dot-path 的路径
(setq my-site-el-path (concat my-dot-path "packages/")) ;;  设置路径, concat 为连接意思
(add-to-list 'load-path my-site-el-path)


;;**********************        常用编程配置        *********************

;;f1为woman快捷键
(global-set-key [(f1)] (lambda()        
			 (interactive)
			 (let ((woman-topic-at-point t)) 
			   (woman))))

;; WoMan不打开新的 frame, 你可能会想要这个配置
(setq woman-use-own-frame nil)

;;热键设置
(global-set-key [f5] 'compile)
(setq-default compile-command "make -k")
(global-set-key [f6] 'speedbar)
(global-set-key [f7] 'gdb)
(global-set-key [f8] 'previous-error)
(global-set-key [f9] 'next-error)
;;启动窗口gdb    
(global-set-key [f10] 'gdb-many-windows)

;; f11,实现全屏效果
(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))
  )

;; 最大化
(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时窗口最大化
(my-maximized)
;; 启动窗口大小
(setq default-frame-alist
      '((height . 35) (width . 125) (menu-bar-lines . 20) (tool-bar-lines . 0))) 
(put 'upcase-region 'disabled nil)

;; 回车缩进
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key (kbd "C-<return>") 'newline)


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

;; 默认显示 80列就换行 
;;(setq default-fill-column 80) 

;; 去掉工具栏
;;(tool-bar-mode nil)

;;去掉菜单栏
;;(menu-bar-mode nil)

;; 去掉滚动栏
;;(scroll-bar-mode nil)


;; 使用tabbar.el
;;(require 'tabbar)
;;(tabbar-mode t)
;; 使用C-<TAB>在tab间切换
;;(global-set-key [(control tab)]       'tabbar-forward)

;; 使用tabbar.el
(require 'tabbar)  

(tabbar-mode)  

(global-set-key (kbd "<M-up>")    'tabbar-backward-group)  
(global-set-key (kbd "<M-down>")  'tabbar-forward-group)  
(global-set-key (kbd "<M-left>")  'tabbar-backward-tab)  
(global-set-key (kbd "<M-right>") 'tabbar-forward-tab)  

(setq  
 tabbar-scroll-left-help-function nil   ;don't show help information  
 tabbar-scroll-right-help-function nil  
 tabbar-help-on-tab-function nil  
 tabbar-home-help-function nil  
 tabbar-buffer-home-button (quote (("") "")) ;don't show tabbar button  
 tabbar-scroll-left-button (quote (("") ""))  
 tabbar-scroll-right-button (quote (("") "")))  


(defun my-tabbar-buffer-groups ()  
  "Return the list of group names the current buffer belongs to.  
    Return a list of one element based on major mode."  
  (list  
   (cond  
    ((or (get-buffer-process (current-buffer))  
	 ;; Check if the major mode derives from `comint-mode' or  
	 ;; `compilation-mode'.  
	 (tabbar-buffer-mode-derived-p  
	  major-mode '(comint-mode compilation-mode)))  
     "Process"  
     )  
    ((string-equal "*" (substring (buffer-name) 0 1))  
     "Emacs Buffer"  
     )  
    ((eq major-mode 'dired-mode)  
     "Dired"  
     )  
    (t  
     "User Buffer"  
     ))))  

(setq tabbar-buffer-groups-function 'my-tabbar-buffer-groups)  



;; 语法高亮
(global-font-lock-mode t)

;; 在标题栏提示你目前在什么位置
(setq frame-title-format "xwp@%b")

;; 以 y/n代表 yes/no
(fset 'yes-or-no-p 'y-or-n-p) 

;; 显示列号
(setq column-number-mode t)
(setq line-number-mode t)

;;(require 'linum+)
(global-linum-mode 1);;启用全局显示行号模式
(global-set-key (kbd "C-x N") 'linum-mode)

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

;;(put 'scroll-left 'disabled nil)
;;(put 'upcase-region 'disabled nil)
;;(setq make-backup-file nil)
;;'(mouse-1-click-in-non-selected-windows t)
;;'(mouse-drag-copy-region t)
;;'(mouse-yank-at-point t)


;; GBK settings:
;;(set-language-environment 'Chinese-gbk)
;;(set-terminal-coding-system 'chinese-gbk)
;;(set-selection-coding-system 'chinese-gbk)
;;(set-keyboard-coding-system 'chinese-gbk)
;;(set-clipboard-coding-system 'chinese-
;;(set-buffer-file-coding-system 'chinese-gbk)
;;(modify-coding-system-alist 'process "*" 'chinese-gbk)


;; UTF-8 settings
;;(set-language-environment 'utf-8)
;;(set-terminal-coding-system 'utf-8)
;;(set-keyboard-coding-system 'utf-8)
;;(set-clipboard-coding-system 'utf-8)
;;(set-buffer-file-coding-system 'utf-8)
;;(set-selection-coding-system 'utf-8)
;;(modify-coding-system-alist 'process "*" 'utf-8)

;;time set
(display-time-mode 1)                   ;;启用时间显示设置
(setq display-time-24hr-format t)       ;;时间使用24小时制
(setq display-time-day-and-date t)      ;;时间显示包括日期和具体时间
;;(setq display-time-use-mail-icon t)     ;;时间栏旁边启用邮件设置
(setq display-time-interval 10)         ;;时间的变化频率
(setq display-time-format " %Y-%m-%d %A %H:%M ") ;;设定日期时间的格式



;;开启星际译王
(require 'sdcv-mode)
(global-set-key (kbd "C-c d") 'sdcv-search)


;; 编程  
;;默认Linux内核编程风格,取自Linux内核说明文档                       

(setq auto-mode-alist (cons '("/usr/src/linux.*/.*\\.[ch]$" . linux-c-mode)
                            auto-mode-alist))                                                 
(defun linux-c-mode ()
  "C mode with adjusted defaults for use with the Linux kernel."  
  (interactive)                                                           
  (c-mode)                                                               
   (c-set-style "K&R")                                                    
   (setq tab-width 4) ;;默认风格是8个缩进                                 
   (setq indent-tabs-mode t)                                            
   (setq c-basic-offset 4))  ;;默认风格是8个缩进            


;;c-mode或cc-mode下缩进只有4格
(add-hook 'c-mode-hook
          '(lambda ()
             (c-set-style "Stroustrup")))


;;_____________C______________
;;C预处理设置                                                               
(setq c-macro-shrink-window-flag t)
(setq c-macro-preprocessor "c")
(setq c-macro-cppflags " ")
(setq c-macro-prompt-flag t)
(setq abbrev-mode t)
;;(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)




;;___________CPP______________
;;CPP预处理设置
(setq c-macro-shrink-window-flag t)
(setq c-macro-preprocessor "cpp")
(setq c-macro-cppflags " ")
(setq c-macro-prompt-flag t)
(setq abbrev-mode t)
;;(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)


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

;;写文件的编码方式
;;(set-buffer-file-coding-system 'gb2312)
(set-buffer-file-coding-system 'utf-8)

;;新建文件的编码方式
;;(setq default-buffer-file-coding-system 'gb2312)
(setq default-buffer-file-coding-system 'utf-8)

;;终端方式的编码方式
(set-terminal-coding-system 'utf-8)

;;键盘输入的编码方式
;;(set-keyboard-coding-system 'gb2312) 
(set-keyboard-coding-system 'utf-8) 
    
;;读取或写入文件名的编码方式
(setq file-name-coding-system 'utf-8)

;; 取消自动保存
 (auto-save-mode 0)

;;打开图片显示功能
;;(auto-image-file-mode t)

;;关闭烦人的出错时的提示声。
(setq visible-bell t)

;;去掉菜单栏,将F10绑定为显示菜单栏,需要菜单栏了可以摁F10调出,再摁F10就去掉菜单
(menu-bar-mode nil)

;;禁止终端响铃
(setq visiable-bell t)

;;光标显示为一竖线
;;(setq-default cursor-type 'bar)

;;指针不要闪,我得眼睛花了
(blink-cursor-mode -1)

;;记住离开时的变量等
;;(load-file "/home/.emacs.d/session.el") 
(require 'session)
(add-hook 'after-init-hook 'session-initialize)

;; M-x desktop-save。以后 Emacs 启动时就会打开你上次离开时的所有 buffer.
(load "desktop") 
(require 'desktop)
(setq desktop-save t)
(setq desktop-load-locked-desktop t)
(setq *desktop-dir* (list (expand-file-name "~/.emacs.d/desktop")))
(setq desktop-path '("~/.emacs.d/"))
(setq desktop-dirname "~/.emacs.d/")
(setq desktop-base-file-name ".emacs-desktop")
(desktop-save-mode 1)
(desktop-read)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值