Skip to content

Latest commit

 

History

History
252 lines (211 loc) · 7.61 KB

starter-kit-gui.org

File metadata and controls

252 lines (211 loc) · 7.61 KB

Starter Kit Gui

Starter Kit Gui

All kinds of preferences

(setq echo-keystrokes 0.1
      font-lock-maximum-decoration t
      transient-mark-mode t
      color-theme-is-global t
      delete-by-moving-to-trash t
      shift-select-mode nil
      truncate-partial-width-windows nil
      uniquify-buffer-name-style 'forward
      whitespace-style '(trailing lines space-before-tab
                                  indentation space-after-tab
                                  empty)
      whitespace-line-column 100
      ediff-window-setup-function 'ediff-setup-windows-plain
      oddmuse-directory (concat starter-kit-dir "oddmuse")
      xterm-mouse-mode t)

Visible bell

I can’t recognize frame flashing. So flash the mode-line instead.

(defvar visible-bell-time-last 0.1
  "Time last for visible bell.")

(defun my-visible-bell ()
  (invert-face 'mode-line)
  (run-with-timer visible-bell-time-last nil 'invert-face 'mode-line))

(setq visible-bell nil)
(setq ring-bell-function #'my-visible-bell)

Line number in terminal

There is no fringe in terminal and it’s hard to distinguish line number and code if there is no margin between. Approach as follows just mimic the fringe in GUI Emacs.

(unless window-system
  (defun set-linum-format-str ()
    (setq-local linum-format-fmt
                (let ((w (length (number-to-string
                                  (count-lines (point-min) (point-max))))))
                  (concat "%" (number-to-string w) "d"))))

  (add-hook 'linum-before-numbering-hook 'set-linum-format-str)

  (defun linum-format-fn (line)
    (concat
     (propertize (format linum-format-fmt line) 'face 'linum)
     (propertize " " 'face 'secondary-selection)))

  (setq linum-format 'linum-format-fn))

Rainbow delimiters

I use rainbow-delimiters in editing latex or lisp. But in most of the time, I don’t need it.

(with-eval-after-load 'rainbow-delimiters
  (require 'color)

  ;; using stronger colors
  (cl-loop
   for index from 1 to rainbow-delimiters-max-face-count
   do
   (let ((face (intern (format "rainbow-delimiters-depth-%d-face" index))))
     (cl-callf color-saturate-name (face-foreground face) 30)))

  ;; making unmatched parens stand out more
  (set-face-attribute 'rainbow-delimiters-unmatched-face nil
                      :foreground 'unspecified
                      :inherit 'error
                      :strike-through t))

Emacs Layout

Set Emacs split to horizontal by default.

(setq split-height-threshold nil)
(setq split-width-threshold 160)

All kinds of bars

You really don’t need this; trust me.

(menu-bar-mode -1)
(column-number-mode 1)
(when window-system
  (setq frame-title-format '(buffer-file-name "%f" (:eval default-directory)))
  (blink-cursor-mode -1)
  (scroll-bar-mode -1)
  (tooltip-mode -1)
  (tool-bar-mode -1)
  (when (require 'mwheel nil 'no-error) (mouse-wheel-mode t)))

UTF-8 coding system

(when *windows*
  (setq utf-translate-cjk-mode nil))
(setq locale-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(unless *windows*
  (set-selection-coding-system 'utf-8))
(prefer-coding-system 'utf-8)

Diminish minor modes

The minor mode list is too long and occupy all the mode line. I want to know other data on the mode line.

(eval-after-load "undo-tree"               '(diminish 'undo-tree-mode))
(eval-after-load "flyspell"                '(diminish 'flyspell-mode))
(eval-after-load "auto-complete"           '(diminish 'auto-complete-mode))
(eval-after-load "eldoc"                   '(diminish 'eldoc-mode))
(eval-after-load "magit"                   '(diminish 'magit-auto-revert-mode))
(eval-after-load "smartparens"             '(diminish 'smartparens-mode))
(with-eval-after-load 'cdlatex
  (diminish 'org-cdlatex-mode)
  (diminish 'cdlatex-mode))
(eval-after-load "outline"                 '(diminish 'outline-minor-mode))
(eval-after-load "abbrev"                  '(diminish 'abbrev-mode))
(eval-after-load "highlight-indentation"   '(diminish 'highlight-indentation-current-column-mode))
(eval-after-load "hideshow"                '(diminish 'hs-minor-mode))
(eval-after-load "whitespace-cleanup-mode" '(diminish 'whitespace-cleanup-mode))
(eval-after-load "fic-mode"                '(diminish 'fic-mode))
(eval-after-load "yasnippet"               '(diminish 'yas-minor-mode))
(eval-after-load "anzu"                    '(diminish 'anzu-mode))
(eval-after-load "key-combo"               '(diminish 'key-combo-mode))
(eval-after-load "simple"                  '(diminish 'visual-line-mode))
(eval-after-load "simple"                  '(diminish 'auto-fill-function))
(eval-after-load "sphinx-doc"              '(diminish 'sphinx-doc-mode))
(eval-after-load "anaconda-mode"           '(diminish 'anaconda-mode))
(eval-after-load "company"                 '(diminish 'company-mode))
(eval-after-load "compile"                 '(diminish 'compilation-shell-minor-mode))
(eval-after-load "reftex"                  '(diminish 'reftex-mode))

Font for English and Chinese

(set-face-attribute 'default (selected-frame) :height 120)
(when (window-system)
  (catch 'en-font-found
    (mapc
     (lambda (ft)
       (when (x-list-fonts ft)
         (set-face-attribute
          'default nil :font ft)
         (throw 'en-font-found ft)))
 '("Inconsolata" "Consolas")))
  (catch 'zh-font-found
    (mapc
     (lambda (ft)
       (when (x-list-fonts ft)
         (dolist (charset '(kana han symbol cjk-misc bopomofo))
           (set-fontset-font (frame-parameter nil 'font)
                             charset
                             (font-spec :family ft :size 14)))
         (throw 'zh-font-found ft)))
     '("WenQuanYi Micro Hei Mono" "Microsoft Yahei"))))
(when (window-system)
  (require 'chinese-fonts-setup))

Install font

Windows

Open Windows explorer and enter C:\WINDOWS\fonts -> file -> install new font -> click the font file.

Linux

  • Install fontconfig.
  • Copy font file to ~/.fonts/.
  • Shell command: fc-cache ~/.fonts/

WenQuanYi

WenQuanYi can be installed by fontconfig but Emacs can’t recognize it. (x-list-fonts “WenQuanYi Micro Hei”) returns nil.

Fringe

(when (window-system)
  (fringe-mode '(4 . 0)))

Disable recentering

For smooth scrolling and disabling the auto-recentering of emacs screen when moving cursor. Set scroll margin to be 4 so that an ape can see the following lines of codes.

(setq scroll-step 1
      scroll-conservatively 10000
      auto-window-vscroll nil)
(setq scroll-margin 4)

Theme

Theme zenburn

(load-theme 'zenburn t)
(global-hl-line-mode 1)
(with-eval-after-load 'python
  (require 'highlight-indentation)
  (set-face-background 'highlight-indentation-current-column-face "#4F4F4F"))

Theme ample

(load-theme 'ample t t)
(load-theme 'ample-flat t t)
(load-theme 'ample-light t t)
(enable-theme 'ample-light)
(with-eval-after-load 'python
  (require 'highlight-indentation)
  ;; ample/region=dark
  (set-face-background 'highlight-indentation-current-column-face "#ABA991"))
(with-eval-after-load 'dired
  (add-hook 'dired-after-readin-hook #'hl-line-mode))