emacs配置
根据个人喜好编写,仅供参考。
upd. on 2019.10.24 删掉了一大堆东西,看起来舒服一些?
upd. on 2019.10.26 开始用考场配置啦
upd. on 2019.11.2 联赛前最后一次改考场配置
upd. on 2020.1.10 把一些没用的删掉了
upd. on 2020.1.27 发现 \(\text{eshell}\) 蛮好的,懒得用 \(\text{gdb}\) 了,删掉了一键编译和打开 \(\text{gdb}\) 的快捷键
upd. on 2020.4.25 改了一下缩进格式
upd. on 2021.2.24 加了一句没什么用的话
upd. on 2021.8.17 加了个滚动效果,顺便贴一个链接
upd. on 2021.9.15 实在太懒,加了句编译快捷键设置 其实早就设置了只是鸽到现在
upd. on 2022.3.20 鸽王回归 寒假改成工程化的多文件配置了,代码啥的全都贴上来好了(逃 不过不得不说 \(\text{Windows}\) 下面用 \(\text{emacs}\) 挺不方便的,不然就把 \(\text{eaf}\) 啃下来了 /kk
;;; init.el --- inititation
;;; Commentary:
;;; Code:
;; Settings for custom variables
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
;; Settings for my lisp files
(add-to-list 'load-path (expand-file-name (concat user-emacs-directory "my-lisp")))
(require 'init-const)
(require 'init-startup)
(require 'init-elpa)
(require 'init-package)
(require 'init-ui)
(require 'init-compile)
(provide 'init)
;;; init.el ends here
;;; init-compile.el --- settings for compiler
;;; Commentary:
;;; Code:
(global-set-key (kbd "RET") 'newline-and-indent)
(global-set-key (kbd "C-a") 'mark-whole-buffer)
(global-set-key (kbd "C-s") 'save-buffer)
(global-set-key [f6] 'compile-file-gcc)
(defun compile-file-gcc ()
(interactive)
(compile (format "gcc -o %s %s -std=c99"
(file-name-sans-extension (buffer-name)) (buffer-name)
(file-name-sans-extension (buffer-name)))))
(global-set-key [f7] 'compile-file-g++)
(defun compile-file-g++ ()
(interactive)
(compile (format "g++ -o %s %s -std=c++11"
(file-name-sans-extension (buffer-name)) (buffer-name)
(file-name-sans-extension (buffer-name)))))
(global-set-key [f8] 'eshell)
(provide 'init-compile)
;;; init-compile.el ends here
;;; init-ui.el --- settings for ui
;;; Commentary:
;;; Code:
(setq default-directory "C:/Sangber/Work")
(setq-default default-tab-width 4)
(setq c-basic-offset 4)
(setq frame-title-format "Emacs of Sangber >>> %b")
(ido-mode t)
(set-frame-parameter (selected-frame) 'alpha (list 85 50))
(set-background-color "gray15")
(set-foreground-color "gray")
(setq scroll-step 1
scroll-margin 3
scroll-conservatively 10000)
(provide 'init-ui)
;;; init-ui.el ends here
;;; init-startup.el --- settings for startup options
;;; Commentary:
;;; Code:
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(setq gc-cons-threshold most-positive-fixnum)
(custom-set-variables
'(inhibit-startup-screen t)
'(menu-bar-mode nil)
'(package-selected-packages '(restart-emacs use-package))
'(scroll-bar-mode nil)
'(show-paren-mode t)
'(tool-bar-mode nil))
(provide 'init-startup)
;;; init-startup.el ends here
;;; init-const.el --- settings for constant variables
;;; Commentary:
;;; Code:
(defconst *is-windows* (or (eq system-type 'ms-dos) (eq system-type 'windows-nt)))
(defconst *is-macOS* (or (eq system-type 'darwin) ))
(defconst *is-linux* (or (eq system-type 'gnu/linux)))
(provide 'init-const)
;;; init-const.el ends here
;;; init-elpa.el --- settings for elpa
;;; Commentary:
;;; Code:
(setq package-archives '(("melpa" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
("gnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("org" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/org/")))
(setq package-check-signature nil)
(require 'package)
(unless (bound-and-true-p package--initialized)
(package-initialize))
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(setq use-package-always-ensure t
use-package-always-defer t
use-package-always-demand t
use-package-expand-minimally t
use-package-verbose t)
(provide 'init-elpa)
;;; init-elpa.el ends here
;;; init-package.el --- settings for packages
;;; Commentary:
;;; Code:
(use-package restart-emacs)
(use-package emacs
:config (defalias 'yes-or-no-p 'y-or-n-p))
(use-package emacs
:if (display-graphic-p)
:config
(if *is-windows*
(progn
(set-face-attribute 'default nil :font "Monaco")
(dolist (charset '(kana han symbol cjk-misc bopomofo))
(set-fontset-font (frame-parameter nil 'font)
charset (font-spec :family "Microsoft Yahei" :size 19))))
(set-face-attribute 'default nil :font "Monaco")))
(use-package emacs
:config
(setq display-line-numbers-type t)
(global-display-line-numbers-mode t))
(use-package drag-stuff
:bind (("<M-up>" . drag-stuff-up)
("<M-down>" . drag-stuff-down)))
(use-package ivy
:defer 1
:hook (after-init . ivy-mode)
:config
(ivy-mode 1)
(setq ivy-use-virtual-buffers t
ivy-initial-inputs-alist nil
ivy-count-format "%d/%d "
enable-recursive-minibuffers t
ivy-re-builders-alist '((t . ivy--regex-ignore-order))))
(use-package counsel
:after ivy
:bind (("M-x" . counsel-M-x)
("C-x C-f" . counsel-find-file)
("C-c f" . counsel-recentf)
("C-c g" . counsel-git)))
(use-package swiper
:after (ivy)
:bind (("C-f" . swiper) ;;("C-s" . swiper)
("C-r" . swiper-isearch-backward))
:config (setq swiper-action-recenter t
swiper-include-line-number-in-search t))
(use-package company
:config
(setq company-dabbrev-code-everywhere t
company-dabbrev-code-modes t
company-dabbrev-code-other-buffers 'all
company-dabbrev-downcase nil
company-dabbrev-ignore-case t
company-dabbrev-other-buffers 'all
company-require-match nil
company-minimum-prefix-length 2
company-show-numbers t
company-tooltip-limit 20
company-idle-delay 0
company-echo-delay 0
company-tooltip-offset-display 'scrollbar
company-begin-command '(self-insert-command))
(push '(company-semantic :with company-yasnippet) company-backends)
:hook ((after-init . global-company-mode)))
(use-package flycheck
:hook (prog-mode . flycheck-mode))
(use-package which-key
:defer nil
:config (which-key-mode))
(use-package ivy-posframe
:init
(setq ivy-posframe-display-functions-alist
'((swiper . ivy-posframe-display-at-frame-center)
(complete-symbol . ivy-posframe-display-at-point)
(counsel-M-x . ivy-posframe-display-at-frame-center)
(counsel-find-file . ivy-posframe-display-at-frame-center)
(ivy-switch-buffer . ivy-posframe-display-at-frame-center)
(t . ivy-posframe-display-at-frame-center)))
(ivy-posframe-mode t))
(use-package ace-window
:bind (("M-o" . 'ace-window)))
(provide 'init-package)
;;; init-package.el ends here