Emacs配置

;; ====== emacs 配置 ====== ;;

;; 要想使这个配置起效,请把它命名为 `.emacs',然后放到你的账户的用户目录下 (/home/<账户名字>/.emacs)。

;; t = True
;; nil = False

;; 默认编码环境。

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

;; 光标形状。'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)


;; 修改透明度
(set-frame-parameter (selected-frame) 'alpha (list 85 50))
(add-to-list 'default-frame-alist (cons 'alpha (list 85 50)))


;; 在 buffer 分界条上显示(24小时制)时间。

(display-time-mode 1)
(setq-default display-time-24hr-format t)
(setq-default display-time-interval 1)


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


;; 改变标题
(setq-default frame-title-format "Code from fexuile.不尝试怎么知道呢?")


;; 一键编译。

(defun compile-file ()(interactive)(compile (format "g++ -o %s %s -g -lm -Wall" (file-name-sans-extension (buffer-name))(buffer-name))))
(global-set-key [f9] 'compile-file)
(global-set-key [f10] 'compile)


;; 一键 GDB。

(global-set-key [f2] '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)
 '(size-indication-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 "Monaco" :foundry "APPL" :slant normal :weight normal :height 120 :width normal)))))

(auto-insert-mode) ;;; Adds hook to find-files-hook
(setq auto-insert-query nil) ;;; If you don't want to be prompted before insertion
(setq auto-insert-directory "~/模板") ;;; Or use custom, *NOTE* Trailing slash important
(define-auto-insert ".cpp" "cpp.cpp")

copyright iotang

原文地址:https://www.cnblogs.com/fexuile/p/12346762.html