附带一键编译和运行的配置文件

2019-10-23 23:38:11


(global-linum-mode t) ;;line num 显示行号

(setq-default indent-tabs-mode nil)  ;;将tab转变为空格
(setq c-basic-offset 4)
(setq default-tab-width 4) ;;tab width 设置缩进以及tab键

(electric-pair-mode t)
(electric-layout-mode t)
(electric-indent-mode t)
;;electric pair 括号补全

(show-paren-mode t) ;;show paren 括号配对

(global-hl-line-mode t) ;;high light line 高亮当前行

(global-set-key [f6] 'gdb) ;;摁F6进入gdb调试

(defun mycompile()
  (interactive)
  (save-buffer)
  (compile (format "g++ %s -o %s -Wall -std=c++11 -Wl,--stack=536870912" (buffer-file-name) (substring buffer-file-name 0 -4)))
  )

(defun run()
  (interactive)
  (save-buffer)
  (shell-command (format "echo @echo off ^& ConsolePauser %s.exe ^& exit >> tmp.bat" (substring buffer-file-name 0 -4)))
  (shell-command "start tmp.bat")
  (shell-command "del tmp.bat")
  ) ;;Windows 版

(defun run()
  (interactive)
  (save-buffer)
  (shell-command (format "gnome-terminal -- bash -c \"time %s;read n -1;\"" (substring buffer-file-name 0 -4)))
  ) ;;Linux 版

(global-set-key [f7] 'mycompile) ;;摁F7一键编译
(global-set-key [f8] 'run) ;;摁F8进入shell

虽然看起来及其复杂,但是只要稍微理解一下 lisp 语言的话,这些也只是很基础的模拟而已。