emacs(考场+平时)配置方案

考场配置:

;;在配置后面会对语句逐一解释的

(global-set-key (kbd "C-z") 'undo)
(global-set-key (kbd "RET") 'newline-and-indent)
(global-set-key [f9] 'compile-file)
(global-set-key [f10] 'eshell)
(defun compile-file ()
    (interactive)
    (compile (format "g++ -o %s %s -g -lm -Wall"  (file-name-sans-extension (buffer-name))(buffer-name))))

(cua-mode t)
(show-paren-mode t)
(global-linum-mode t)
(electric-pair-mode t)
(global-hl-line-mode 1)
(setq kill-ring-max 200)
(setq default-cursor-type 'bar)
(setq default-tab-width 4)
(setq c-default-style "awk")
(set-frame-parameter (selected-frame) 'alpha (list 85 50))

(setq default-frame-alist'(
    (background-color . "black")
    (foreground-color . "grey")
    (cursor-color . "gold1")
    )
)

语句解释:

(global-set-key (kbd "C-z") 'undo)
(global-set-key (kbd "RET") 'newline-and-indent)
(global-set-key [f9] 'compile-file)
(global-set-key [f10] 'eshell)
(defun compile-file ()
    (interactive)
    (compile (format "g++ -o %s %s -g -lm -Wall"  (file-name-sans-extension (buffer-name))(buffer-name))))
;;快捷键第一行是撤销,第二行自动缩进,第三行编译,第四行进入eshell界面准备运行,后面一段是一键编译(按F9执行)。

(cua-mode t)
;;Windows的复制粘贴键(在emacs上方菜单栏即options中有开关选项!

(show-paren-mode t)
(global-linum-mode t)
;;括号匹配和显示行号

(electric-pair-mode t)
;;这个真的敲级好用,一行配置直接打开(大中小)括号和引号的自动补全!!!

(global-hl-line-mode 1)
;;显示当前行(使当前行颜色不同,便于区分)-

(setq kill-ring-max 200)
;;设置撤销的缓存,可以开大点避免失误,这里博主开了200!

(setq default-cursor-type 'bar)
;;光标为竖线(要防止光标闪烁,在菜单的options里有开关选项!)

(setq default-tab-width 4)
;;默认tab宽度为 4

(setq c-default-style "awk")
;;缩进风格(考场挂了QAQ

(set-frame-parameter (selected-frame) 'alpha (list 85 50))
;;透明度(一边敲代码一边看题不用老是切换页面)
;;前一个数字表示你选中这个页面时的透明度,后一个数字是你没选中此页面时的透明度


(setq default-frame-alist'(
    (width . 200)
    (height . 43)
    (background-color . "black")
    (foreground-color . "grey")
    (cursor-color . "gold1")
    (tool-bar-lines . 0)
    )
);;初始设置:宽度,高度,背景颜色,字体颜色,光标颜色,以及是否有菜单工具栏

注意事项:

1.## 不要弄太多配置,考场容易码错
2.## 一般考试会提前20分钟入场,这段时间可以码配置(如果管得比较松

平时码代码添加的一些小配置:

(setq frame-title-format "%b by xiao-wen")
;;改变emacs标题栏的标题(特爽)

(set-face-foreground 'region "gold1")
(set-face-background 'region "gray15")
;;(区域)选择的背景和主题

;;(set-face-foreground 'highlight "white")
(set-face-background 'highlight "gray15")
;; 设置语法高亮显示的背景和主题(第一个去分号使用

(defun up-slightly () (interactive) (scroll-up 3)) 
(defun down-slightly () (interactive) (scroll-down 3)) 
(global-set-key [mouse-4] 'down-slightly) 
(global-set-key [mouse-5] 'up-slightly)
;;上下滚动时不会太快(一次只上下移动三行,极舒服)

(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
 '(column-number-mode t)
 '(cua-mode t nil (cua-base))
 '(display-time-mode t)
 '(inhibit-startup-screen t)
 '(show-paren-mode t)
 '(tool-bar-mode nil))
(custom-set-faces
 '(default ((t (:family "Ubuntu Mono" :foundry "unknown" :slant normal :weight normal :height 143 :width normal)))))
(auto-insert-mode)
(setq auto-insert-directory "~/.emacs.d/mytemplates/")
(setq auto-insert-query nil)
(define-auto-insert "\." "moban.cpp")
(electric-pair-mode t)
;;这个是部分emacs自带的(有时间字体的基础配置

其他:

;;(setq inhibit-startup-message t)
;;启动画面关闭

;;(c-set-style "stroustrup")
;;(c-toggle-auto-state)
;;(c-toggle-hungry-state)
;;(setq c-basic-offset 4)
;;(imenu-add-menubar-index)
;;(which-function-mode)))
;;把C++语言风格设置为stroustrup风格,博主也不知道是啥东西

提醒一下:语句要去掉前面两个分号使用

以上代码直接复制到emacs配置可以正常运行!


(global-set-key (kbd "C-z") 'undo)
(global-set-key (kbd "C-a") 'mark-whole-buffer)
(global-set-key [f9] 'compile-file)
(global-set-key [f10] 'eshell)
(defun compile-file ()
    (interactive)
    (compile (format "g++ -o %s %s -g -lm -Wall -D ONLINE_JUDGE"  (file-name-sans-extension (buffer-name))(buffer-name))))

(cua-mode t)
(show-paren-mode t)
(global-linum-mode t)
(global-hl-line-mode 1)
(setq kill-ring-max 200)
(setq default-cursor-type 'bar)
(setq default-tab-width 4)
(setq c-default-style "awk")
(set-frame-parameter (selected-frame) 'alpha (list 85 50))

(setq default-frame-alist'(
    (vertical-scroll-bars)
    (width . 200)
    (height . 43)
    (background-color . "black")
    (foreground-color . "grey")
    (cursor-color . "gold1")
    (mouse-color . "gold1")
    (tool-bar-lines . 0)
    (menu-bar-lines . 1)
    )
)

(setq frame-title-format "%b by xiao-wen")
(setq x-select-enable-clipboard t)
(setq auto-save-mode nil)

(set-face-foreground 'region "gold1")
(set-face-background 'region "gray15")
(set-face-background 'highlight "gray15")

(defun up-slightly () (interactive) (scroll-up 3)) 
(defun down-slightly () (interactive) (scroll-down 3)) 
(global-set-key [mouse-4] 'down-slightly) 
(global-set-key [mouse-5] 'up-slightly)


(custom-set-variables
 '(column-number-mode t)
 '(cua-mode t nil (cua-base))
 '(display-time-mode t)
 '(inhibit-startup-screen t)
 '(show-paren-mode t)
 '(tool-bar-mode nil))
(custom-set-faces
 '(default ((t (:family "Ubuntu Mono" :foundry "unknown" :slant normal :weight normal :height 143 :width normal)))))
(auto-insert-mode)
(setq auto-insert-directory "~/.emacs.d/mytemplates/")
(setq auto-insert-query nil)
(define-auto-insert "\." "moban.cpp")
(electric-pair-mode t)

你可能感兴趣的:(emacs(考场+平时)配置方案)