emacs配置,就是我們CSP考試時用的那個
windows下記得調環境變量!!!要不然還是只能是原版配置
;; 本 emacs 配置在 emacs26 起效
;; via iotang
;; t = True
;; nil = False
(package-initialize)
;; 默認編碼環境。
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
;; 不顯示歡迎頁面。
(setq-default inhibit-startup-screen t)
;; 設置標題。
(setq-default frame-title-format "%b")
;; 剪貼板共享。
(setq-default x-select-enable-clipboard t)
;; 不顯示工具欄。在舊版本中,這個值可能是 nil。
(tool-bar-mode 0)
;; 啟用 cua-mode (C-x C-c C-v 分別代表剪切,復制,粘貼)。
(cua-mode t)
;; 全選大文件的時候不會卡死。當然,如果你使用的是 fcitx,並且打開了剪貼板支持,在復制大文件的時候還是會卡死。你可以使用 emacs-terminal 來解決這個問題。
(setq-default select-active-regions 'only)
;; emacs-terminal 鼠標可用。
(xterm-mouse-mode t)
;; emacs 和系統的剪貼板共用。
(setq-default x-select-enable-clipboard t)
;; 顯示行號。
(global-linum-mode t)
;; 高亮當前行。
(global-hl-line-mode 1)
;; 高亮匹配括號。
(show-paren-mode t)
(setq show-paren-style 'parenthesis)
;; 光標形狀。'box = 框;'bar = 豎線。
(setq-default cursor-type 'bar)
;; Ctrl-z 撤銷。
(global-set-key (kbd "C-z") 'undo)
;; Ctrl-a 全選。
(global-set-key (kbd "C-a") 'mark-whole-buffer)
;; Ctrl-s 保存。
(global-set-key (kbd "C-s") 'save-buffer)
;; 撤銷記錄擴大。
(setq-default kill-ring-max 65535)
;; 開啟備份文件。
(setq-default auto-save-mode t)
(setq-default backup-by-copying t)
;; 設置備份文件時間間隔。這個單位是秒。
(setq-default auto-save-timeout 30)
;; 優化文件樹結構。
(ido-mode t)
;; 鼠標滾輪支持。
(mouse-wheel-mode t)
;; 優化頁面滾動。
(setq-default scroll-step 1 scroll-margin 3 scroll-conservatively 10000)
;; 語法高亮。
(global-font-lock-mode t)
;; 回答 yes/no 改成回答 y/n。
(fset 'yes-or-no-p 'y-or-n-p)
;; 在 buffer 分界條上顯示(24小時制)時間。
(display-time-mode 1)
(setq-default display-time-24hr-format t)
(setq-default display-time-interval 1)
;; 默認字體是 Ubuntu Mono 的 12 號。
;; (set-default-font "Ubuntu Mono-12")
;; 透明度。
(set-frame-parameter (selected-frame) 'alpha (list 90 70))
(add-to-list 'default-frame-alist (cons 'alpha (list 90 70)))
;; C++ 代碼風格。
;; "bsd" = 所有大括號換行。這是真理
;; "java" = 所有大括號不換行。else 接在右大括號后面。
;; "k&r" = "awk" = 只有命名空間旁、定義類、定義函數時的大括號換行。else 接在右大括號后面。
;; "stroustrup" = 只有命名空間旁、定義類、定義函數時的大括號換行。else 換行。
;; "whitesmith" = 所有大括號換行。大括號有一次額外縮進。
;; "gnu" = 所有大括號換行。每次左括號開始,會有一層額外縮進。這是 emacs 默認
;; "linux" = 只有命名空間旁、定義類、定義函數時的大括號換行。else 接在右大括號后面。一般來說,這個風格應該有 8 格的空格縮進。
(setq-default c-default-style "bsd")
;; C++ 代碼縮進長度。
(setq-default c-basic-offset 4)
;; 使用 tab 縮進。
(setq-default indent-tabs-mode t)
;; tab 的長度。務必和縮進長度一致。
(setq-default default-tab-width 4)
(setq-default tab-width 4)
;; 換行的時候自動縮進。
(global-set-key (kbd "RET") 'newline-and-indent)
;; 一鍵編譯。
(defun compile-file ()(interactive)(compile (format "g++ -o %s %s -g -lm -Wall" (file-name-sans-extension (buffer-name))(buffer-name))))
(defun compile-current () (interactive) (eshell-command (format "g++ -o %s %s -g -lm -Wall" (file-name-sans-extension (buffer-name))(buffer-name))))
(global-set-key [f9] 'compile-current)
(global-set-key [f8] 'compile)
;; 一鍵 GDB。
(global-set-key [f10] 'gud-gdb)
;; deeper-blue 配色方案。
(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.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(ansi-color-names-vector
["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#e090d7" "#8cc4ff" "#eeeeec"])
'(cua-mode t nil (cua-base))
'(custom-enabled-themes (quote (deeper-blue)))
'(display-time-mode t)
'(show-paren-mode t)
'(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 (:family "Consolas" :foundry "outline" :slant normal :weight normal :height 143 :width normal)))))