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

;; 澶栬璁劇疆================================

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


;;紱佺敤宸ュ叿鏍?br>

(tool-bar-mode nil)


;;紱佺敤鑿滃崟鏍忥紝F10 寮鍚叧闂彍鍗?br>

(menu-bar-mode nil)


;;紱佺敤婊氬姩鏍忥紝鐢ㄩ紶鏍囨粴杞唬鏇?br>

;;(scroll-bar-mode nil)


;;紱佺敤鍚姩鐢婚潰

(setq inhibit-startup-message t)


;;灝哄

(setq initial-frame-alist '( (width . 90) (height . 35)))


;;~~~~~~~~~~~~~~~~~~~~

;; 棰滆壊璁劇疆

;;~~~~~~~~~~~~~~~~~~~~


;; 鎸囬拡棰滆壊

(set-cursor-color "white")

;; 榧犳爣棰滆壊

(set-mouse-color "blue")

;; 鑳屾櫙鍜屽瓧浣撻鑹?br>

(set-foreground-color "lightblue")

(set-background-color "black")

(set-border-color "lightgreen")


;; 璇硶楂樹寒鏄劇ず錛屽尯鍩熼夋嫨錛屼簩嬈¢夋嫨

;;鍓嶆櫙鍜岃儗鏅壊

(set-face-foreground 'highlight "red")

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


;; 瀛椾綋璁劇疆
浣犵殑緋葷粺涓緢鍙兘娌℃湁YaHeiConsolas,閭d箞浣犲氨閫夋嫨涓涓綘鍠滄鐨勫瓧浣?浠f浛瀹冨啓鍦ㄤ笅闈?

(set-default-font "YaHeiConsolas")








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

;; 緙撳啿鍖?=================================

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

;;璁懼畾琛岃窛

(setq default-line-spacing 0)


;;欏靛

(setq default-fill-column 90)


;;緙虹渷妯″紡 text-mode

(setq default-major-mode 'text-mode)


;;璁劇疆鍒犻櫎綰綍

(setq kill-ring-max 200)


;;浠ョ┖琛岀粨鏉?br>

(setq require-final-newline t)



;;璇硶鍔犱寒

(global-font-lock-mode t)


;;楂樹寒鏄劇ず鍖哄煙閫夋嫨

(transient-mark-mode t)


;;欏甸潰騫蟲粦婊氬姩錛?nbsp;scroll-margin 5 闈犺繎灞忓箷杈規部3琛屾椂寮濮嬫粴鍔紝鍙互寰堝ソ鐨勭湅鍒頒笂涓嬫枃銆?br>

(setq scroll-margin 5

scroll-conservatively 10000)


;楂樹寒鏄劇ず鎴愬鎷彿錛屼絾涓嶆潵鍥炲脊璺?br>

(show-paren-mode t)

(setq show-paren-style 'parentheses)



;;榧犳爣鎸囬拡瑙勯伩鍏夋爣

;(mouse-avoidance-mode 'animate)


;;綺樿創浜庡厜鏍囧錛岃屼笉鏄紶鏍囨寚閽堝

(setq mouse-yank-at-point t)


;;鑷姩琛ラ綈璁劇疆
鎸変笅 M - / 閿?涓鑸岃█灝辨槸Alt + /),emacs浼氬府浣犺ˉ鍏ㄤ綘姝e湪鎵撶殑鍏抽敭瀛?br>
(global-set-key [(meta ?/)] 'hippie-expand)

(setq hippie-expand-try-functions-list

'(try-expand-dabbrev

try-expand-dabbrev-visible

try-expand-dabbrev-all-buffers

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




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

;;鎻掍歡鎷撳睍============================

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

;;
榪欎釜閮ㄥ垎鏄壒鍒煎緱娉ㄦ剰鐨?鍥犱負濡傛灉浣犳病鏈変笅杞戒笅闈㈢殑鎻掍歡,emacs浼氬嚭鐜板姞杞藉紓甯?
;;
涓轟簡閬垮厤榪欑鎯呭喌,姝ゆ枃鐨勪笅闈㈡垜鎻愪緵浜嗘彃浠剁殑鍘嬬緝鍖?br>
;;鏄劇ず琛屽彿

(require 'linum)

(setq linum-format "%3d ")

(add-hook 'find-file-hooks (lambda () (linum-mode 1))) ;;瀵規墍鏈夋枃浠剁敓鏁?br>


;;榪欎釜鎻掍歡濂藉儚鎷挎潵琛ュ叏鐢ㄧ殑,涓嶈繃涓嶆槸寰堝己澶?br>

;;yasnippet-bundle

(require 'yasnippet-bundle)








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

;;鑷畾涔変竴浜涘揩鎹烽敭====================

;;===================================
;;
涓嬮潰鏄煩琛岀殑蹇嵎閿?鎸変笅Ctrl + j ,鐒跺悗杈撳叆瀵瑰簲鐨勮,鍐嶆寜鍥炶濺鍗沖彲

(global-set-key (kbd "C-j")'goto-line)


;;
浣犱篃鍙互鍦ㄨ繖閲屽畾涔夊叾瀹冪殑蹇嵎閿?/span>




;;===================================
;;璁劇疆緙栬瘧鍣?=========================
;;===================================
;;(setq compile-command (concat "D:/Dev-Cpp/bin/g++ -g " "\"" buffer-file-name "\""))
(global-set-key (kbd "<f9>") 'smart-compile)
(defun smart-compile()

;; "姣旇緝鏅鴻兘鐨凜/C++緙栬瘧鍛戒護
;;濡傛灉褰撳墠鐩綍鏈塵akefile鍒欑敤make -k緙栬瘧錛屽惁鍒欙紝濡傛灉鏄?br>
;;澶勪簬c-mode錛屽氨鐢╣cc -Wall緙栬瘧錛屽鏋滄槸c++-mode灝辯敤 g++ -Wall緙栬瘧"
(interactive)
;; 鏌ユ壘 Makefile
(let ((candidate-make-file-name '("makefile" "Makefile" "GNUmakefile"))
(command nil))
(if (not (null
(find t candidate-make-file-name :key
'(lambda (f) (file-readable-p f)))))
(setq command "make -k ")
;; 娌℃湁鎵懼埌 Makefile 錛屾煡鐪嬪綋鍓?nbsp;mode 鏄惁鏄凡鐭ョ殑鍙紪璇戠殑妯″紡
(if (null (buffer-file-name (current-buffer)))
(message "Buffer not attached to a file, won't compile!")
(if (eq major-mode 'c-mode)
(setq command
(concat "D:/Dev-Cpp/bin/gcc.exe -Wall -o " ;;浣犺鏄庣‘鐭ラ亾鑷繁鐨勭紪璇戝櫒鍦ㄥ摢閲?
(file-name-sans-extension ;;榪欐牱,鐢ㄤ綘鐨刧cc.exe鐨勫湴鍧浠f浛榪欓噷鐨凞:/Dev-Cpp/bin/gcc.exe
(file-name-nondirectory buffer-file-name)) ;;娉ㄦ剰,榪欓噷鐨勮礬寰勭殑鏂滄潬鍜寁ista鐨勪範鎯浉鍙?浣犺娉ㄦ剰淇敼
" "
(file-name-nondirectory buffer-file-name)
" -g -lm "))
(if (eq major-mode 'c++-mode)
(setq command
(concat "D:/Dev-Cpp/bin/g++.exe -Wall -o " ;;榪樻湁榪欓噷鐨刧++,涔熷悓gcc涓鏍?..
(file-name-sans-extension
(file-name-nondirectory buffer-file-name))
" "
(file-name-nondirectory buffer-file-name)
" -g -lm "))
(message "Unknow mode, won't compile!")))))
(if (not (null command))
(let ((command (read-from-minibuffer "Compile command: " command)))
(compile command)))))

;;=====================================
;;浠g爜椋庢牸==============================
;;=====================================
;; C/C++/Java mode
(defun my-c-mode-hook()
;; 灝嗗洖杞︿唬鏇緾-j鐨勫姛鑳斤紝鎹㈣鐨勫悓鏃跺榻?br>
(define-key c-mode-map [return] 'newline-and-indent)
(interactive)
;; 璁劇疆C紼嬪簭鐨勫榻愰鏍?br>
;; (c-set-style "K&R")
;; 鑷姩妯″紡錛屽湪姝ょ妯″紡涓嬪綋浣犻敭鍏鏃訛紝浼氳嚜鍔ㄦ牴鎹綘璁劇疆鐨勫榻愰鏍煎榻?br>
;; (c-toggle-auto-state)
;; 姝ゆā寮忎笅錛屽綋鎸塀ackspace鏃朵細鍒犻櫎鏈澶氱殑絀烘牸
(c-toggle-hungry-state)
;; TAB閿殑瀹藉害璁劇疆涓?
(setq c-basic-offset 4)
;; 鍦ㄨ彍鍗曚腑鍔犲叆褰撳墠Buffer鐨勫嚱鏁扮儲寮?br>
(imenu-add-menubar-index)
;; 鍦ㄧ姸鎬佹潯涓婃樉紺哄綋鍓嶅厜鏍囧湪鍝釜鍑芥暟浣撳唴閮?br>
(which-function-mode)
)
(defun my-c++-mode-hook()
(define-key c++-mode-map [return] 'newline-and-indent)
(interactive)
(c-set-style "stroustrup")
(c-toggle-auto-state)
(c-toggle-hungry-state)
(setq c-basic-offset 4)
(imenu-add-menubar-index)
(which-function-mode)
)
(defun my-java-mode()
(define-key java-mode-map [return] 'newline-and-indent)
(interactive)
(c-set-style "java")
(c-toggle-auto-state)
(c-toggle-hungry-state)
(setq c-basic-offset 4)
(imenu-add-menubar-index)
(which-function-mode)
)
(add-hook 'c-mode-hook 'my-c-mode-hook)
(add-hook 'c++-mode-hook 'my-c++-mode-hook)
(add-hook 'java-mode-hook 'my-java-mode)