emacs配置

?

; 指針顏色設置為白色
(set-cursor-color "white")
;; 鼠標顏色設置為白色
(set-mouse-color "white")


;; 從color-theme中獲取
;; 網上下載color-theme.el,放到加載路徑(/usr/share/emacs/site-lisp )下
;; M-x color-theme-select,鼠標左鍵選中,回車查看效果
;; d查看信息,將出現如下信息:
;; color-theme-matrix is an interactive Lisp function in `color-theme.el'.
;; (color-theme-matrix)
;; Color theme by walterh@rocketmail.com, created 2003-10-16.
;; 選擇(color-theme-blue-mood)即可
;;(require 'color-theme)
;;(setq color-theme-is-global t)
;;(color-theme-wheat)

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

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

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

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

;; 顯示時間,格式如下
(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)

(transient-mark-mode t)

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

;; 在標題欄提示你目前在什么位置
(setq frame-title-format "zhj@%b")

;; 默認顯示 80列就換行
(setq default-fill-column 80)

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

;;去掉菜單欄
(menu-bar-mode nil)

;; 去掉滾動欄
(scroll-bar-mode nil)

;; 設置字體
;; 方法為: emacs->options->Set Default Font->"M-x describe-font"查看當前使用的字體名稱、字體大小
(set-default-font " -bitstream-Courier 10 Pitch-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1")

;; 顯示列號
(setq column-number-mode t)
(setq line-number-mode t)

;; 設置默認tab寬度為2
(setq tab-width 2
indent-tabs-mode t
c-basic-offset 2)

;; 回車縮進
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key (kbd "C-<return>") 'newline)

?

?

?

;; 啟動窗口大小
(setq default-frame-alist
'((height . 35) (width . 125) (menu-bar-lines . 20) (tool-bar-lines . 0)))
;; author: chinazhangjie
;; e-mail: chinajiezhang@gmail.com

;; 指針顏色設置為白色
(set-cursor-color "white")
;; 鼠標顏色設置為白色
(set-mouse-color "white")
;;------------語言環境字符集設置(utf-8)-------------
(defun qiang-font-existsp (font)
(if (null (x-list-fonts font))
nil t))
(defvar font-list '("宋體" "新宋體" "Microsoft Yahei" "文泉驛等寬微米黑" "黑體" ))
(require 'cl) ;; find-if is in common list package
(find-if #'qiang-font-existsp font-list)
(defun qiang-make-font-string (font-name font-size)
(if (and (stringp font-size)
(equal ":" (string (elt font-size 0))))
(format "%s%s" font-name font-size)
(format "%s %s" font-name font-size)))
(defun qiang-set-font (english-fonts
english-font-size
chinese-fonts
&optional chinese-font-size)
"english-font-size could be set to \":pixelsize=18\" or a integer.
If set/leave chinese-font-size to nil, it will follow english-font-size"
(require 'cl) ; for find if
(let ((en-font (qiang-make-font-string
(find-if #'qiang-font-existsp english-fonts)
english-font-size))
(zh-font (font-spec :family (find-if #'qiang-font-existsp chinese-fonts)
:size chinese-font-size)))

;; Set the default English font
;;
;; The following 2 method cannot make the font settig work in new frames.
;; (set-default-font "Consolas:pixelsize=18")
;; (add-to-list 'default-frame-alist '(font . "Consolas:pixelsize=18"))
;; We have to use set-face-attribute
(message "Set English Font to %s" en-font)
(set-face-attribute
'default nil :font en-font)

;; Set Chinese font
;; Do not use 'unicode charset, it will cause the english font setting invalid
(message "Set Chinese Font to %s" zh-font)
(dolist (charset '(kana han symbol cjk-misc bopomofo))
(set-fontset-font (frame-parameter nil 'font)
charset
zh-font))))
(qiang-set-font
'("Consolas" "Monaco" "DejaVu Sans Mono" "Monospace" "Courier New") ":pixelsize=15"
'("宋體" "新宋體" "Microsoft Yahei" "文泉驛等寬微米黑" "黑體" ))
;;Setting English Font
;;(set-face-attribute 'default nil :font "Consolas 12")

;; Chinese Font
;;(dolist (charset '(kana han symbol cjk-misc bopomofo)) (set-fontset-font (frame-parameter nil 'font) charset (font-spec :family "Microsoft Yahei" :size 12)))
;;處理shell-mode亂碼,好像沒作用

;;------語言環境字符集設置結束------------



;;--------------窗口界面設置------------------

(set-foreground-color "grey")
(set-background-color "black")
(set-cursor-color "gold1")
(set-mouse-color "gold1")

(set-scroll-bar-mode nil)
;;取消滾動欄

;;(customize-set-variable 'scroll-bar-mode 'right))
;;設置滾動欄在窗口右側,而默認是在左側

(tool-bar-mode nil)
;;取消工具欄

;;啟動設置
;;(setq default-frame-alist '((vertical-scroll-bars) (top . 25) (left . 45) (width . 180) (height . 55)
;;(background-color . "black") (foreground-color . "grey")(cursor-color . "gold1") (mouse-color . "gold1") (tool-bar-lines . 0) (menu-bar-lines . 1) (right-fringe) (left-fringe)))

;;啟動自動最大化(數據自己調整,注意格式,如(top . 0),圓點前后都要留有空格)
(setq initial-frame-alist '((top . 0) (left . 0) (width . 120) (height . 36)))


;; 設置另外一些顏色:語法高亮顯示的背景和主題,區域選擇的背景和主題,二次選擇的背景和選擇
(set-face-foreground 'highlight "white")
(set-face-background 'highlight "blue")
(set-face-foreground 'region "cyan")
(set-face-background 'region "blue")
(set-face-foreground 'secondary-selection "skyblue")
(set-face-background 'secondary-selection "darkblue")

;;------------窗口界面設置結束-----------------

;;------------顯示時間設置------------------------------

(display-time-mode 1);;啟用時間顯示設置,在minibuffer上面的那個杠上
(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 default-directory "~/")
;;(setenv "HOME" "D:/My Documents/Visual Studio 2008/Projects")
;;(setenv "PATH" "D:/My Documents/Visual Studio 2008/Projects")
;;set the default file path
(setq default-directory "~/")

;;------------------------------------------

;;ido的配置,這個可以使你在用C-x C-f打開文件的時候在后面有提示;
;;這里是直接打開了ido的支持,在emacs23中這個是自帶的.
(ido-mode t)

(setq ido-save-directory-list-file nil)
;;ido模式中不保存目錄列表,解決退出Emacs時ido要詢問編碼的問題。

;;(setq visible-bell t)
;;關閉煩人的出錯時的提示聲

(setq inhibit-startup-message t)
;;關閉emacs啟動時的畫面

(setq gnus-inhibit-startup-message t)
;;關閉gnus啟動時的畫面

(fset 'yes-or-no-p 'y-or-n-p)
;; 改變 Emacs 固執的要你回答 yes 的行為。按 y 或空格鍵表示 yes,n 表示 no。

(setq font-lock-maximum-decoration t)
(setq font-lock-global-modes '(not shell-mode text-mode))
(setq font-lock-verbose t)
(setq font-lock-maximum-size '((t . 1048576) (vm-mode . 5250000)))
;; 語法高亮。除 shell-mode 和 text-mode 之外的模式中使用語法高亮。

(setq column-number-mode t)
(setq line-number-mode t)
;;顯示行列號
(global-linum-mode t)
(setq mouse-yank-at-point t)
;;不要在鼠標點擊的那個地方插入剪貼板內容。我不喜歡那樣,經常把我的文檔搞的一團糟。我覺得先用光標定位,然后鼠標中鍵點擊要好的多。不管你的光標在文檔的那個位置,或是在 minibuffer,鼠標中鍵一點擊,X selection 的內容就被插入到那個位置。

(setq kill-ring-max 200)
;;設置粘貼緩沖條目數量.用一個很大的kill ring(最多的記錄個數). 這樣防止我不小心刪掉重要的東西

(setq-default auto-fill-function 'do-auto-fill)
; Autofill in all modes;;
(setq default-fill-column 120)
;;把 fill-column 設為 60. 這樣的文字更好讀

(setq-default indent-tabs-mode nil)
(setq default-tab-width 8);;tab鍵為8個字符寬度
(setq tab-stop-list ())
;;不用 TAB 字符來indent, 這會引起很多奇怪的錯誤。編輯 Makefile 的時候也不用擔心,因為 makefile-mode 會把 TAB 鍵設置成真正的 TAB 字符,并且加亮顯示的。

(setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)
;;設置 sentence-end 可以識別中文標點。不用在 fill 時在句號后插入兩個空格。

(setq enable-recursive-minibuffers t)
;;可以遞歸的使用 minibuffer

(setq scroll-margin 3 scroll-conservatively 10000)
;;防止頁面滾動時跳動, scroll-margin 3 可以在靠近屏幕邊沿3行時就開始滾動,可以很好的看到上下文。

(setq default-major-mode 'text-mode)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;;設置缺省主模式是text,,并進入auto-fill次模式.而不是基本模式fundamental-mode

(show-paren-mode t)
;;打開括號匹配顯示模式

(setq show-paren-style 'parenthesis)
;;括號匹配時可以高亮顯示另外一邊的括號,但光標不會煩人的跳到另一個括號處。

(mouse-avoidance-mode 'animate)
;;光標靠近鼠標指針時,讓鼠標指針自動讓開,別擋住視線。

(setq frame-title-format "emacs@%b")
;;在標題欄顯示buffer的名字,而不是 emacs@wangyin.com 這樣沒用的提示。

(setq uniquify-buffer-name-style 'forward);;好像沒起作用
;; 當有兩個文件名相同的緩沖時,使用前綴的目錄名做 buffer 名字,不用原來的foobar<?> 形式。

(setq auto-image-file-mode t)
;;讓 Emacs 可以直接打開和顯示圖片。

;(auto-compression-mode 1)
;打開壓縮文件時自動解壓縮。

(setq global-font-lock-mode t)
;;進行語法加亮。

(setq-default kill-whole-line t)
;; 在行首 C-k 時,同時刪除該行。

(add-hook 'comint-output-filter-functions
'comint-watch-for-password-prompt)
;;當你在shell、telnet、w3m等模式下時,必然碰到過要輸入密碼的情況,此時加密顯出你的密碼

;;(setq version-control t);;啟用版本控制,即可以備份多次
;; (setq kept-old-versions 2);;備份最原始的版本兩次,及第一次編輯前的文檔,和第二次編輯前的文檔
;; (setq kept-new-versions 1);;備份最新的版本1次,理解同上
;; (setq delete-old-versions t);;刪掉不屬于以上3中版本的版本
;; (setq backup-directory-alist '(("." . "~/backups")));;設置備份文件的路徑
;; (setq backup-by-copying t);;備份設置方法,直接拷貝
;; Emacs 中,改變文件時,默認都會產生備份文件(以 ~ 結尾的文件)。可以完全去掉; (并不可取),也可以制定備份的方式。這里采用的是,把所有的文件備份都放在一個固定的地方("~/backups")。對于每個備份文件,保留最原始的兩個版本和最新的1個版本。并且備份的時候,備份文件是復本,而不是原件。

(setq make-backup-files nil)
;; 設定不產生備份文件

;;(setq auto-save-mode nil)
;;自動保存模式

(setq-default make-backup-files nil)
;; 不生成臨時文件

(put 'scroll-left 'disabled nil) ;允許屏幕左移
(put 'scroll-right 'disabled nil) ;允許屏幕右移
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'LaTeX-hide-environment 'disabled nil)
;;把這些缺省禁用的功能打開。

;;允許emacs和外部其他程序的粘貼
(setq x-select-enable-clipboard t)

;;(setq mouse-yank-at-point t)
;;使用鼠標中鍵可以粘貼

(setq user-full-name "Bluesky")
(setq user-mail-address "whuchenxi2010@gmail.com")
;;設置有用的個人信息,這在很多地方有用。

(setq require-final-newline t)
;; 自動的在文件末增加一新行

(setq-default transient-mark-mode t)
;;Non-nil if Transient-Mark mode is enabled.

(setq track-eol t)
;; 當光標在行尾上下移動的時候,始終保持在行尾。

(setq Man-notify-method 'pushy)
;; 當瀏覽 man page 時,直接跳轉到 man buffer。

;;(setq next-line-add-newlines nil)
;;Emacs 21 中已經是缺省設置。按 C-n 或向下鍵時不添加新行。

(global-set-key [home] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)
;;設置home鍵指向buffer開頭,end鍵指向buffer結尾


(global-set-key (kbd "C-,") 'scroll-left)
;; "C-,"設為屏幕左移命令
(global-set-key (kbd "C-.") 'scroll-right)
;; "C-."設為屏幕右移命令

(global-set-key [f1] 'manual-entry)
(global-set-key [C-f1] 'info )

;;(global-set-key [f2] 'emacs-wiki-find-file)
;;打開wiki

;;(global-set-key [f3] 'repeat-complex-command)

;;(global-set-key [f4] 'other-window)
;; 跳轉到 Emacs 的另一個buffer窗口

(defun du-onekey-compile ()
"Save buffers and start compile"
(interactive)
(save-some-buffers t)
(switch-to-buffer-other-window "*compilation*")
(compile compile-command))
(global-set-key [C-f5] 'compile)
(global-set-key [f5] 'du-onekey-compile)
;; C-f5, 設置編譯命令; f5, 保存所有文件然后編譯當前窗口文件

(global-set-key [f6] 'gdb)
;;F6設置為在Emacs中調用gdb

(global-set-key [C-f7] 'previous-error)
(global-set-key [f7] 'next-error)

(defun open-eshell-other-buffer ()
"Open eshell in other buffer"
(interactive)
(split-window-vertically)
(eshell))
(global-set-key [(f8)] 'open-eshell-other-buffer)
(global-set-key [C-f8] 'eshell)
;;目的是開一個shell的小buffer,用于更方便地測試程序(也就是運行程序了),我經常會用到。
;;f8就是另開一個buffer然后打開shell,C-f8則是在當前的buffer打開shell

(setq speedbar-show-unknown-files t);;可以顯示所有目錄以及文件
(setq dframe-update-speed nil);;不自動刷新,手動 g 刷新
(setq speedbar-update-flag nil)
(setq speedbar-use-images nil);;不使用 image 的方式
(setq speedbar-verbosity-level 0)

(global-set-key [f9] 'speedbar)
;;設置f9調用speedbar命令
;;使用 n 和 p 可以上下移動,
;; + 展開目錄或文件進行瀏覽,- 收縮,RET 訪問目錄或文件,g 更新 speedbar。

(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)
;;讓 dired 可以遞歸的拷貝和刪除目錄。
(global-set-key [C-f9] 'dired)
;;設置[C-f9]為調用dired命令

(global-set-key [f10] 'undo)
;;設置F10為撤銷

(global-set-key [f11] 'calendar)
;;設置F11快捷鍵指定Emacs 的日歷系統

(global-set-key [f12] 'list-bookmarks)
;;設置F12 快速察看日程安排

(setq time-stamp-active t)
(setq time-stamp-warn-inactive t)
(setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M:%02S chunyu")
;; 設置時間戳,標識出最后一次保存文件的時間。

(global-set-key (kbd "M-g") 'goto-line)
;;設置M-g為goto-line

(global-set-key (kbd "C-SPC") 'nil)
;;取消control+space鍵設為mark

(global-set-key (kbd "s-SPC") 'set-mark-command)
;;用win+space鍵來set-mark,這樣,C-SPC就可以用來調用外部輸入法了。
(setq-default cursor-type 'bar)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cedet設置結束;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ecb設置;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(setq ecb-tip-of-the-day nil)
(add-to-list 'load-path "/usr/share/emacs/site-lisp/ecb")
(load-file "/usr/share/emacs/site-lisp/ecb/ecb.el")
(require 'ecb)
(setq ecb-auto-activate t
ecb-tip-of-the-day nil
ecb-tree-indent 4
ecb-windows-height 0.5
ecb-windows-width 0.15
ecb-auto-compatibility-check nil
ecb-version-check nil
inhibit-startup-message t
)
;; Ecb的操作:
;; C-c . g d 目錄列表窗口
;; C-c . g s 源碼窗口
;; C-c . g m 方法和變量窗口
;; C-c . g h 歷史窗口
;; C-c . g l 最后選擇過的編輯窗口
;; C-c . g 1 編輯窗口1
;; C-c . g n 編輯窗口n
;; C-c . l c 選擇版面
;; C-c . l r 重畫版面
;; C-c . l t 拴牢版面(鎖定版面)
;; C-c . l w 拴牢可見的ecb窗口
;; C-c . / 拴牢編繹窗口
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ecb設置結束;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;自動補全設置(工作不理想);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;C/C++語言啟動時自動加載semantic對/usr/include的索引數據庫
;(setq semanticdb-search-system-databases t)
; (add-hook 'c-mode-common-hook
; (lambda ()
; (setq semanticdb-project-system-databases
; (list (semanticdb-create-database
; semanticdb-new-database-class
; "/usr/include")))))

;; project root path
;(setq semanticdb-project-roots
; (list
; (expand-file-name "/")))
;; 避免semantic占用CPU過多
;(setq-default semantic-idle-scheduler-idle-time 432000);
;(defun my-indent-or-complete ()
; (interactive)
; (if (looking-at "\\>")
; (hippie-expand nil)
; (indent-for-tab-command)))
;(autoload 'senator-try-expand-semantic "senator")

;(setq hippie-expand-try-functions-list
; '(
; senator-try-expand-semantic
; try-expand-dabbrev
; try-expand-dabbrev-visible
; try-expand-dabbrev-all-buffers
; try-expand-dabbrev-from-kill
; try-expand-list
; try-expand-list-all-buffers
; try-expand-line
; try-expand-line-all-buffers
; try-complete-file-name-partially
; try-complete-file-name
; try-expand-whole-kill
; )
;)

;(global-set-key [M-/] 'hippie-expand)
;右Ctrl+\ 自動補全menu

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;自動補全設置結束;;;;;;;;;;;;;;;;;;;;;;;;;;



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;補全擴弧配置(沒什么用);;;;;;;;;;;;;;;;;;;;;;;;;;
;(defun my-c-mode-auto-pair ()
; (interactive)
; (make-local-variable 'skeleton-pair-alist)
; (setq skeleton-pair-alist '(
; (?` ?` _ "''")
; (?\( ? _ " )")
; (?\[ ? _ " ]")
; (?{ \n > _ \n ?} >)))
; (setq skeleton-pair t)
; (local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
; (local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
; (local-set-key (kbd "`") 'skeleton-pair-insert-maybe)
; (local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
;(add-hook 'c-mode-hook 'my-c-mode-auto-pair)
;(add-hook 'c++-mode-hook 'my-c-mode-auto-pair)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;補全擴弧配置結束;;;;;;;;;;;;;;;;;;;;;;;;;;
;(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.
; '(scroll-bar-mode (quote right))
; '(tool-bar-mode nil))
;(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.
; '(default ((t (:inherit nil :stipple nil :background "black" :foreground "grey" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight bold :height 120 :width normal :foundry "unknown" :family "Tlwg Typo")))))
(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.
'(ecb-options-version "2.40"))
;; 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.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;'(ecb-options-version "2.40"))
;;(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.
; )


;===================== 文件頭header設置 ===========================
;;當我們保存文件的時候,有很多信息可以自動更新.如何自動更新信息, 更新那些信息,
;也是可以完全自己配置. 包括文件名稱,最后一次修改時間,文件保存次數,最后一次修改的作者等等.
;;可以用 M-x make-header 自動生成文件頭信息.
;(add-to-list 'load-path "~/lisp/header")
;(require 'header)
;(setq make-header-hooks '(header-mode-line

; header-blank
; header-file-name
; header-blank
; header-copyright
; header-blank
; header-author
; header-creation-date
; header-modification-author
; header-modification-date
; header-update-count
; header-blank
; header-history
; header-blank
; ))
;(setq header-copyright-notice " 源成工作室 作品" )
;(make-local-variable 'user-full-name)
;(make-local-variable 'user-mail-address)

;===================== 文件頭header設置結束 ==========================


;(load-library "hideshow")
;(add-hook 'c-mode-hook 'hs-minor-mode)
;(add-hook 'c++-mode-hook 'hs-minor-mode)
;(add-hook 'java-mode-hook 'hs-minor-mode)
;(add-hook 'perl-mode-hook 'hs-minor-mode)
;(add-hook 'php-mode-hook 'hs-minor-mode)
;(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
;;能把一個代碼塊縮起來,需要的時候再展開
;; M-x hs-minor-mode
;; C-c @ ESC C-s show all
;; C-c @ ESC C-h hide all
;; C-c @ C-s show block
;; C-c @ C-h hide block
;; C-c @ C-c toggle hide/show


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;定制操作習慣;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;設置打開文件的缺省路徑
(setq default-directory "/")

;;ido的配置,這個可以使你在用C-x C-f打開文件的時候在后面有提示;
;;這里是直接打開了ido的支持,在emacs23中這個是自帶的.
(ido-mode t)

(setq visible-bell t)
;;關閉煩人的出錯時的提示聲
(setq inhibit-startup-message t)
;;關閉emacs啟動時的畫面

(setq gnus-inhibit-startup-message t)
;;關閉gnus啟動時的畫面

(fset 'yes-or-no-p 'y-or-n-p)
;; 改變 Emacs 固執的要你回答 yes 的行為。按 y 或空格鍵表示 yes,n 表示 no。

;(setq font-lock-maximum-decoration t)
;(setq font-lock-global-modes '(not shell-mode text-mode))
;(setq font-lock-verbose t)
;(setq font-lock-maximum-size '((t . 1048576) (vm-mode . 5250000)))
;; 語法高亮。除 shell-mode 和 text-mode 之外的模式中使用語法高亮。

(setq column-number-mode t)
(setq line-number-mode t)
;;顯示行列號

(setq mouse-yank-at-point t)
;;不要在鼠標點擊的那個地方插入剪貼板內容。我不喜歡那樣,經常把我的文檔搞的一團糟。我覺得先用光標定位,然后鼠標中鍵點擊要好的多。不管你的光標在文檔的那個位置,或是在 minibuffer,鼠標中鍵一點擊,X selection 的內容就被插入到那個位置。

(setq kill-ring-max 200)
;;設置粘貼緩沖條目數量.用一個很大的kill ring(最多的記錄個數). 這樣防止我不小心刪掉重要的東西

(setq-default auto-fill-function 'do-auto-fill)
; Autofill in all modes;;
(setq default-fill-column 80)
;;把 fill-column 設為 60. 這樣的文字更好讀

;(setq-default indent-tabs-mode nil)
;(setq default-tab-width 8)
;(setq tab-stop-list ())
;;不用 TAB 字符來indent, 這會引起很多奇怪的錯誤。編輯 Makefile 的時候也不用擔心,因為 makefile-mode 會把 TAB 鍵設置成真正的 TAB 字符,并且加亮顯示的。

;(setq sentence-end "//([。!?]//|……//|[.?!][]/"')}]*//($//|[ /t]//)//)[ /t/n]*")
;(setq sentence-end-double-space nil)
;;設置 sentence-end 可以識別中文標點。不用在 fill 時在句號后插入兩個空格。

(setq enable-recursive-minibuffers t)
;;可以遞歸的使用 minibuffer

(setq scroll-margin 3 scroll-conservatively 10000)
;;防止頁面滾動時跳動, scroll-margin 3 可以在靠近屏幕邊沿3行時就開始滾動,可以很好的看到上下文。

;(setq default-major-mode 'text-mode)
;(add-hook 'text-mode-hook 'turn-on-auto-fill)
;;設置缺省主模式是text,,并進入auto-fill次模式.而不是基本模式fundamental-mode

(setq show-paren-mode t) ;;打開括號匹配顯示模式
(setq show-paren-style 'parenthesis)
;;括號匹配時可以高亮顯示另外一邊的括號,但光標不會煩人的跳到另一個括號處。

(setq mouse-avoidance-mode 'animate)
;;光標靠近鼠標指針時,讓鼠標指針自動讓開,別擋住視線。

(setq frame-title-format "emacs@%b")
;;在標題欄顯示buffer的名字,而不是 emacs@wangyin.com 這樣沒用的提示。

;(setq uniquify-buffer-name-style 'forward);;好像沒起作用
;; 當有兩個文件名相同的緩沖時,使用前綴的目錄名做 buffer 名字,不用原來的foobar<?> 形式。

(setq auto-image-file-mode t)
;;讓 Emacs 可以直接打開和顯示圖片。

;(auto-compression-mode 1)
;打開壓縮文件時自動解壓縮。

(setq global-font-lock-mode t)
;;進行語法加亮。

(setq-default kill-whole-line t)
;; 在行首 C-k 時,同時刪除該行。

;(add-hook 'comint-output-filter-functions
; 'comint-watch-for-password-prompt)
;;當你在shell、telnet、w3m等模式下時,必然碰到過要輸入密碼的情況,此時加密顯出你的密碼

; (setq version-control t);;啟用版本控制,即可以備份多次
; (setq kept-old-versions 2);;備份最原始的版本兩次,及第一次編輯前的文檔,和第二次編輯前的文檔
; (setq kept-new-versions 1);;備份最新的版本1次,理解同上
;; (setq delete-old-versions t);;刪掉不屬于以上3中版本的版本
;; (setq backup-directory-alist '(("." . "~/backups")));;設置備份文件的路徑
;; (setq backup-by-copying t);;備份設置方法,直接拷貝
;; Emacs 中,改變文件時,默認都會產生備份文件(以 ~ 結尾的文件)。可以完全去掉
;; (并不可取),也可以制定備份的方式。這里采用的是,把所有的文件備份都放在一
;; 個固定的地方("~/backups")。對于每個備份文件,保留最原始的兩個版本和最新的
;; 1個版本。并且備份的時候,備份文件是復本,而不是原件。

;(setq make-backup-files nil)
;; 設定不產生備份文件

;(setq auto-save-mode nil)
;;自動保存模式

;(setq-default make-backup-files nil)
;; 不生成臨時文件

(put 'scroll-left 'disabled nil) ;允許屏幕左移
(put 'scroll-right 'disabled nil) ;允許屏幕右移
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'LaTeX-hide-environment 'disabled nil)
;;把這些缺省禁用的功能打開。

;;允許emacs和外部其他程序的粘貼
(setq x-select-enable-clipboard t)

(setq mouse-yank-at-point t)
;;使用鼠標中鍵可以粘貼

(setq user-full-name "highspeed")
(setq user-mail-address "woshihighspeed@163.com")
;;設置有用的個人信息,這在很多地方有用。

(setq require-final-newline t)
;; 自動的在文件末增加一新行

;(setq-default transient-mark-mode t)
;;Non-nil if Transient-Mark mode is enabled.

(setq track-eol t)
;; 當光標在行尾上下移動的時候,始終保持在行尾。

(setq Man-notify-method 'pushy)
;; 當瀏覽 man page 時,直接跳轉到 man buffer。

;(setq next-line-add-newlines nil)
;;Emacs 21 中已經是缺省設置。按 C-n 或向下鍵時不添加新行。

(global-set-key [home] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)
;;設置home鍵指向buffer開頭,end鍵指向buffer結尾


(global-set-key (kbd "C-,") 'scroll-left)
;; "C-,"設為屏幕左移命令
(global-set-key (kbd "C-.") 'scroll-right)
;; "C-."設為屏幕右移命令

;(global-set-key [f1] 'manual-entry)
;(global-set-key [C-f1] 'info )

;(global-set-key [f3] 'repeat-complex-command)

;(global-set-key [f4] 'other-window)
;; 跳轉到 Emacs 的另一個buffer窗口


(defun du-onekey-compile ()
"Save buffers and start compile"
(interactive)
(save-some-buffers t)
(switch-to-buffer-other-window "*compilation*")
(compile compile-command))
(global-set-key [C-f5] 'compile)
(global-set-key [f5] 'du-onekey-compile)
;; C-f5, 設置編譯命令; f5, 保存所有文件然后編譯當前窗口文件

(global-set-key [f6] 'gdb)
;;F6設置為在Emacs中調用gdb

;(global-set-key [C-f7] 'previous-error)
;(global-set-key [f7] 'next-error)

(defun open-eshell-other-buffer ()
"Open eshell in other buffer"
(interactive)
(split-window-vertically)
(eshell))
(global-set-key [(f8)] 'open-eshell-other-buffer)
(global-set-key [C-f8] 'eshell)
;;目的是開一個shell的小buffer,用于更方便地測試程序(也就是運行程序了),我經常會用到。
;;f8就是另開一個buffer然后打開shell,C-f8則是在當前的buffer打開shell

(setq speedbar-show-unknown-files t);;可以顯示所有目錄以及文件
(setq dframe-update-speed nil);;不自動刷新,手動 g 刷新
(setq speedbar-update-flag nil)
(setq speedbar-use-images nil);;不使用 image 的方式
(setq speedbar-verbosity-level 0)

;(global-set-key [f9] 'speedbar)
;;設置f9調用speedbar命令
;;使用 n 和 p 可以上下移動,
;; + 展開目錄或文件進行瀏覽,- 收縮,RET 訪問目錄或文件,g 更新 speedbar。

(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)
;;讓 dired 可以遞歸的拷貝和刪除目錄。
(global-set-key [C-f9] 'dired)
;;設置[C-f9]為調用dired命令

(global-set-key [f10] 'undo)
;;設置F10為撤銷

;(global-set-key [f11] 'calendar)
;;設置F11快捷鍵指定Emacs 的日歷系統

(global-set-key [f12] 'list-bookmarks)
;;設置F12 快速察看日程安排

(setq time-stamp-active t)
(setq time-stamp-warn-inactive t)
(setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M:%02S chunyu")
;; 設置時間戳,標識出最后一次保存文件的時間。

;(global-set-key (kbd "M-g") 'goto-line)
;;設置M-g為goto-line

;(global-set-key (kbd "C-SPC") 'nil)
;;取消control+space鍵設為mark

(global-set-key (kbd "M-<SPC>") 'set-mark-command)
;;這樣 我就不用按 C-@ 來 setmark 了, C-@ 很不好按。

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;定制操作習慣結束;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;格式化整個文件函數
(defun indent-whole ()
(interactive)
(indent-region (point-min) (point-max))
(message "format successfully"))
;;綁定到F7鍵
(global-set-key [f7] 'indent-whole)
(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.
)




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;=========================================================================
(setq semantic-load-turn-everything-on t)
;(add-hook 'semantic-init-hooks 'semantic-idle-completions-mode)

(setq semanticdb-project-roots
(list
(expand-file-name "/")))
;;配置Semantic的檢索范圍

(setq semanticdb-default-save-directory "~/")
;;設置semantic.cache路徑

(global-set-key [(meta ?/)] 'hippie-expand)
;;M-/ 綁定到 hippie-expand

(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-functions-list
'(senator-try-expand-semantic ;優先調用了senator的分析結果
try-expand-dabbrev ;當前的buffer補全
try-expand-dabbrev-visible ;別的可見的窗口里尋找補全
try-expand-dabbrev-all-buffers ;所有打開的buffer
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))
;設置 hippie-expand 的補全方式。它是一個優先列表, hippie-expand 會優先使用表最前面的函數來補全。

;=========================================================================


;=====================GDB調試多窗口====================
;(setq gdb-many-windows t)

;(load-library "multi-gud.el")
;(load-library "multi-gdb-ui.el")
;====================================================

;========================================================================

;(load-library "hideshow")
;(add-hook 'c-mode-hook 'hs-minor-mode)
;(add-hook 'c++-mode-hook 'hs-minor-mode)
;(add-hook 'java-mode-hook 'hs-minor-mode)
;(add-hook 'perl-mode-hook 'hs-minor-mode)
;(add-hook 'php-mode-hook 'hs-minor-mode)
;(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
;;能把一個代碼塊縮起來,需要的時候再展開
;; M-x hs-minor-mode
;; C-c @ ESC C-s show all
;; C-c @ ESC C-h hide all
;; C-c @ C-s show block
;; C-c @ C-h hide block
;; C-c @ C-c toggle hide/show

;========================================================================

轉載于:https://www.cnblogs.com/wuyuans/p/4214088.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/273455.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/273455.shtml
英文地址,請注明出處:http://en.pswp.cn/news/273455.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

自然連接(NATURAL JOIN)

自然連接&#xff08;NATURAL JOIN&#xff09;是一種特殊的等價連接&#xff0c;它將表中具有相同名稱的列自動進行記錄匹配。自然連接不必指定任何同等連接條件。圖9.9給出了典型的自然連接示意圖。 圖9.9 自然連接 自然連接自動判斷相同名稱的列&#xff0c;而后形成匹配。…

iis express8 自動關閉

引用&#xff1a;http://www.cnblogs.com/chunCui/p/3522619.html 問題&#xff1a;最近使用vs2013開發個web &#xff0c; 每次調試結束時iis express 8 也會自動關閉 解決方法&#xff1a;web項目-屬性-web-調試器-只選中ASP.Net就可以了 轉載于:https://www.cnblogs.com/qqq…

自連接

9.3 表的連接類型 9.3.1 自連接 自連接是指表與其自身進行連接&#xff0c;這就需要用到前面介紹的表別名。下面通過一個具體實例來講解自連接的應用。 實例5 自連接的使用方法 查詢成績中存在不及格課程的學生的姓名、所在系、所有的課程及成績信息。如果采用前面介紹的…

從此記錄

從此記錄工作、學習、生活的那些事兒&#xff01;轉載于:https://www.cnblogs.com/alwaysjava/p/4221362.html

LIKE運算符

6.5 使用LIKE進行模糊查詢 當只知道部分字符串時&#xff0c;可使用LIKE運算符來查詢數據庫&#xff0c;找出與其相關的整個字符串。因此&#xff0c;當把關鍵字LIKE用在WHERE子句中時&#xff0c;可以比較兩個字符串的部分匹配。當對字符串內容有些印象&#xff0c;但并不知…

AND運算符

6.2 組合查詢條件 在前一章提到的WHERE子句進行查詢時&#xff0c;WHERE子句后面的搜索條件只是單一的。實際上&#xff0c;可以通過布爾運算符AND和OR&#xff0c;將多個單獨的搜索條件結合在一個WHERE子句中&#xff0c;形成一個復合的搜索條件。當對復合搜索條件求值時&a…

Cron表達式【一】

Cron表達式【一】 Cron表達式被用來配置CronTrigger實例。 Cron表達式是一個由 7個子表達式組成的字符串。每個子表達式都描述了一個單獨的日程細節。這些子表達式用空格分隔&#xff0c;分別表示&#xff1a; 1. Seconds 秒 2. Minutes 分鐘 3. Hours 小時 4. Day-of-Month 月…

OR運算符

6.2.2 OR運算符 OR運算符表示“或”的關系。當可能有多個條件為True&#xff0c;但只要有一個為True就滿足搜索要求時&#xff0c;可以使用OR運算符來組合搜索條件。OR在結合兩個布爾表達式時&#xff0c;只要其中一個條件為True時&#xff0c;便傳回True。OR運算符的真值表…

Java基礎---網絡編程

第一講 概述 1、網絡模型&#xff1a;OSI參考模型和TCP/IP參考模型 圖示&#xff1a; 一般來說開發處于傳輸層和網際層&#xff0c;應用層為&#xff1a;FTP和HTTP協議等&#xff0c;傳輸層為&#xff1a;UDP和TCP等&#xff0c;網際層為&#xff1a;IP。 通常用戶操作的是…

AND、OR運算符的組合使用

6.2.3 AND、OR運算符的組合使用 在WHERE子句中&#xff0c;通過AND、OR運算符可以同時連接多個條件&#xff0c;當然AND、OR運算符也可以同時使用。但是當AND、OR運算符同時存在時&#xff0c;其優先級如何確定呢&#xff1f;與大多數語言一樣&#xff0c;SQL語言認為AND運算…

Nginx配置指定媒體類型文件強制下載

由于業務需要&#xff0c;在點擊顯示鏈接&#xff08;如www.xxx.com/2015-01-15/xxx.png&#xff09;顯示媒體資源&#xff08;如圖片、視頻、音頻、文檔&#xff09;&#xff0c;而在點擊下載鏈接&#xff08;如www.xxx.com/2015-01-15/xxx.png?downloadtrue&#xff09;請求…

IN運算符的使用

6.3 IN運算符 在查詢中&#xff0c;有時只要滿足多個條件中的一個條件即可&#xff0c;如查詢地址在北京、上海或者重慶的學生信息&#xff0c;這時候可以使用IN運算符。 6.3.1 IN運算符的使用 IN運算符允許根據一行記錄中&#xff0c;是否有一列包括在一系列值之中&#…

app后端設計(php)

來源&#xff1a;http://blog.csdn.net/column/details/mobilebackend.html?page1 做了3年app相關的系統架構&#xff0c;api設計&#xff0c;先后在3個創業公司中工作&#xff0c;經歷過手機網頁端&#xff0c;android客戶端&#xff0c;iphone客戶端&#xff0c;現在從事日p…

NOT運算符與運算符

6.4.2 NOT運算符與<>運算符 對于簡單的條件查詢&#xff0c;NOT運算符與<>運算符的功能幾乎沒有什么區別&#xff0c;那么NOT運算符的優勢體現在哪里呢&#xff1f;答案是它可以與其他運算符組合使用&#xff0c;這一點是<>運算符所不能實現的。在6.4.1節已…

bootstrap-wysiwyg 結合 base64 解碼 .net bbs 圖片操作類 (三) 圖片裁剪

官方的例子 是 長方形的。 我這里 用于 正方形的頭像 所以 做如下 修改 #preview-pane .preview-container {width: 73px;height: 73px;overflow: hidden;} 可惜很莫名奇妙的是 有的時候 他自動把圖片 變小了&#xff0c;而且針對的都是 小圖&#xff0c;大圖 都顯示正常 發現…

“%”通配符

6.5.2 “%”通配符 在SQL語言中最常用的通配符可能就是“%”了&#xff0c;它表示任意字符的匹配&#xff0c;且不計字符的多少。下面通過幾個典型實例來說明“%”通配符的使用。 1&#xff0e;開頭&#xff0f;結尾匹配 從COURSE表中查詢所有以“計算機”開頭的所有課程的…

Wireshark基本介紹和學習TCP三次握手

Wireshark基本介紹和學習TCP三次握手 原文&#xff1a;http://www.cnblogs.com/TankXiao/archive/2012/10/10/2711777.html wireshark介紹 wireshark的官方下載網站&#xff1a; http://www.wireshark.org/ wireshark是非常流行的網絡封包分析軟件&#xff0c;功能十分強大。可…

“_”通配符

6.5.3 “_”通配符 “_”通配符的功能與“%”通配符基本相同&#xff0c;只是它只表示任意一個字符的匹配。當然&#xff0c;要表示兩個字符的匹配&#xff0c;就需要使用兩個“_”通配符&#xff0c;即寫成“__”。 只有在用戶確定所要查詢的字符串的個數&#xff0c;只是不…

“[]”通配符

6.5.4 “[]”通配符 “[]”通配符用于指定一系列的字符&#xff0c;只要滿足這些字符其中之一&#xff0c;且位置出現在“[]”通配符的位置的字符串就滿足查詢條件。 當然&#xff0c;各種通配符也可以組合使用。組合使用各種通配符時&#xff0c;一定要弄清其表示的匹配條…

QT分頁控件,開源,供大家使用

下載地址&#xff1a;http://files.cnblogs.com/dragonsuc/qt5.rar 轉載于:https://www.cnblogs.com/dragonsuc/p/4242342.html