Posts Emacs Configuration
Post
Cancel

Emacs Configuration

References:

Key settings

  • Set Command as the meta key.
    1
    2
    3
    4
    
    ;; key bindings
    (when (eq system-type 'darwin) ;; mac specific settings
        (setq mac-option-modifier 'meta)
        )
    
  • Switch Ctrl and Caps Lock in System settings. Caps Lock is used less often and is more convient for Emacs use based on my habit.

Initialization file settings

Before installing the required emacs packages, run M-x list-packages to upgrade packages.

After testing different themes, including doom themes, the default material theme, and many other themes in MELPA, I chose zenburn-theme. It is easy on my eyes and the coloring scheme fits me. Run M-x package-install <Return> zenburn-theme to install the package.

The following is my ~/.emacs file. Check the comments for details.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
;; ==================  Update date: Apr. 10  ==================
;; set the spacing format of line numbers
(setq linum-format "%4d \u2502")
;; silence warnings about python indentation
(setq python-indent-guess-indent-offset-verbose nil)

;; show which parenthesis matches the one you are looking at
(show-paren-mode 1)
;; auto close bracket insertion
(electric-pair-mode 1)
;; ==============   Update date: Apr. 10  ==============
;; Reference: https://realpython.com/emacs-the-best-python-editor/
;; ===================================
;; MELPA Package Support
;; ===================================
;; Enables basic packaging support
(require 'package)

;; Adds the Melpa archive to the list of available repositories
(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/") t)

;; Initializes the package infrastructure
(package-initialize)

;; Installs packages
;;
;; myPackages contains a list of package names
(defvar myPackages
  '(better-defaults                 ;; Set up some better Emacs defaults
    elpy                            ;; Emacs Lisp Python Environment
    flycheck                        ;; On the fly syntax checking
    ein                             ;; Emacs IPython Notebook
    material-theme                  ;; Theme
    doom-themes                     ;; Doom-Themes
    )
  )

;; Scans the list in myPackages
;; If the package listed is not already installed, install it
(mapc #'(lambda (package)
          (unless (package-installed-p package)
            (package-install package)))
      myPackages)

;; ===================================
;; Basic Customization
;; ===================================
(setq inhibit-startup-message t)    ;; Hide the startup message
(load-theme 'zenburn t)          ;; Load Doom dark+ theme
;;(load-theme 'material t)            ;; Load material theme
(global-linum-mode t)               ;; Enable line numbers globally

;; ====================================
;; Development Setup
;; ====================================
;; Enable elpy
(elpy-enable)

;; Use IPython for REPL
(setq elpy-shell-echo-output nil
      python-shell-interpreter "ipython3"
      python-shell-interpreter-args "--simple-prompt -c exec('__import__(\\'readline\\')') -i")

;; Enable Flycheck
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

;; User-Defined init.el ends here
(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.
 '(package-selected-packages
   (quote
    (markdown-mode zenburn-theme doom-themes material-theme better-defaults))))
(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.
 )


;; ===================  Update date: Apr. 8  ================
;; key bindings
(when (eq system-type 'darwin) ;; mac specific settings
  (setq mac-option-modifier 'meta)
  )
This post is licensed under CC BY 4.0