└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # use-packages-examples 2 | 3 | This repository collects community contributed `use-package` configuration examples, covering from 4 | Emacs built-in packages to 3rt party packages. 5 | 6 | ## Built-in packages 7 | 8 | ### env 9 | 10 | Set environment variables: 11 | 12 | ```el 13 | (use-package env 14 | :ensure nil 15 | :config 16 | (setenv "PYTHONIOENCODING" "utf-8")) 17 | ``` 18 | 19 | ### mule and mule-cmds 20 | 21 | Set default input method and coding system: 22 | 23 | ```el 24 | (use-package mule 25 | :ensure nil 26 | :init 27 | (setq default-input-method 'MacOSX) 28 | :config 29 | (set-terminal-coding-system 'utf-8) 30 | (set-keyboard-coding-system 'utf-8)) 31 | 32 | (use-package mule-cmds 33 | :preface (provide 'mule-cmds) 34 | :config 35 | (set-language-environment 'UTF-8)) 36 | ``` 37 | 38 | ### ns-win 39 | 40 | Set Mac modifiers: 41 | 42 | ```el 43 | (use-package ns-win 44 | :ensure nil 45 | :init 46 | (setq mac-command-modifier 'meta 47 | mac-option-modifier 'super)) 48 | ``` 49 | 50 | ### hippie-exp 51 | 52 | Set keybinding to `M-/` and customize the list of expansion functions: 53 | 54 | ```el 55 | (use-package hippie-exp 56 | :ensure nil 57 | :bind ("M-/" . hippie-expand) 58 | :init 59 | (setq hippie-expand-try-functions-list 60 | '(try-expand-dabbrev 61 | try-expand-dabbrev-visible 62 | try-expand-dabbrev-all-buffers 63 | try-expand-dabbrev-from-kill 64 | try-complete-file-name-partially 65 | try-complete-file-name 66 | try-expand-all-abbrevs 67 | try-expand-list 68 | try-expand-line 69 | try-complete-lisp-symbol-partially 70 | try-complete-lisp-symbol))) 71 | ``` 72 | 73 | ### avoid 74 | 75 | Move up mouse when cursor comes: 76 | 77 | ```el 78 | (use-package avoid 79 | :ensure nil 80 | :config 81 | (mouse-avoidance-mode 'animate)) 82 | ``` 83 | 84 | ### tool-bar, scroll-bar, menu-bar 85 | 86 | Disable all of them: 87 | 88 | ```el 89 | (use-package tool-bar 90 | :ensure nil 91 | :config 92 | (tool-bar-mode -1)) 93 | 94 | (use-package scroll-bar 95 | :ensure nil 96 | :config 97 | (scroll-bar-mode -1)) 98 | 99 | (use-package menu-bar 100 | :unless (eq system-type 'darwin) 101 | :ensure nil 102 | :config 103 | (menu-bar-mode -1)) 104 | ``` 105 | 106 | ### time 107 | 108 | ```el 109 | (use-package time 110 | :ensure nil 111 | :init 112 | (setq display-time-day-and-date t 113 | display-time-24hr-format t 114 | display-time-use-mail-icon t 115 | display-time-interval 10) 116 | :config 117 | (display-time)) 118 | ``` 119 | 120 | ### shell 121 | 122 | Kill shell buffer when shell exits: 123 | 124 | ```el 125 | (use-package shell 126 | :ensure nil 127 | :hook (shell-mode . my-shell-mode-hook-func) 128 | :config 129 | (defun my-shell-mode-hook-func () 130 | (set-process-sentinel (get-buffer-process (current-buffer)) 131 | 'my-shell-mode-kill-buffer-on-exit)) 132 | (defun my-shell-mode-kill-buffer-on-exit (process state) 133 | (message "%s" state) 134 | (if (or 135 | (string-match "exited abnormally with code.*" state) 136 | (string-match "finished" state)) 137 | (kill-buffer (current-buffer))))) 138 | ``` 139 | 140 | ### paren 141 | 142 | ```el 143 | (use-package paren 144 | :ensure nil 145 | :init 146 | (setq show-paren-style 'parentheses) 147 | :config 148 | (show-paren-mode t)) 149 | ``` 150 | 151 | ## 3rd party packages 152 | 153 | ### [exec-path-from-shell](https://github.com/purcell/exec-path-from-shell) 154 | 155 | Copy specified environment variables: 156 | 157 | ```el 158 | (use-package exec-path-from-shell 159 | :if (memq window-system '(pgtk mac ns x)) 160 | :ensure t 161 | :init 162 | (setq exec-path-from-shell-variables '("PATH" "MANPATH" "GOPATH" "PYTHONPATH")) 163 | :config 164 | (exec-path-from-shell-initialize)) 165 | ``` 166 | 167 | ### [doom-themes](https://github.com/hlissner/emacs-doom-themes) 168 | 169 | ```el 170 | (use-package doom-themes 171 | :ensure t 172 | :init 173 | ;; Global settings (defaults) 174 | (setq doom-themes-enable-bold t ; if nil, bold is universally disabled 175 | doom-themes-enable-italic t) ; if nil, italics is universally disabled 176 | :config 177 | (load-theme 'doom-one t) 178 | 179 | ;; Enable flashing mode-line on errors 180 | (doom-themes-visual-bell-config) 181 | 182 | (use-package doom-themes-ext-treemacs 183 | :init 184 | (setq doom-themes-treemacs-theme "doom-colors")) ; use the colorful treemacs theme) 185 | (doom-themes-treemacs-config) 186 | 187 | ;; Corrects (and improves) org-mode's native fontification. 188 | (doom-themes-org-config)) 189 | ``` 190 | 191 | ### [doom-modeline](https://github.com/seagle0128/doom-modeline) 192 | 193 | ```el 194 | (use-package doom-modeline 195 | :ensure t 196 | :init 197 | (setq doom-modeline-minor-modes t 198 | doom-modeline-vcs-max-length 20) 199 | :config 200 | (doom-modeline-mode 1)) 201 | ``` 202 | 203 | ### [highlight-indent-guides](https://github.com/DarthFennec/highlight-indent-guides) 204 | 205 | ```el 206 | (use-package highlight-indent-guides 207 | :ensure t 208 | :delight highlight-indent-guides-mode 209 | :init 210 | (setq highlight-indent-guides-method 'character 211 | ;; default is \x2502 but it is very slow on Mac 212 | highlight-indent-guides-character ?\xFFE8 213 | highlight-indent-guides-responsive 'top)) 214 | ``` 215 | 216 | ### [rainbow-delimiters](https://github.com/Fanael/rainbow-delimiters) 217 | 218 | Hook to `prog-mode`: 219 | 220 | ```el 221 | (use-package rainbow-delimiters 222 | :ensure t) 223 | 224 | (use-package prog-mode 225 | :ensure nil 226 | :hook ((prog-mode . rainbow-delimiters-mode))) 227 | ``` 228 | 229 | ### [projectile](https://github.com/bbatsov/projectile) 230 | 231 | ```el 232 | (use-package projectile 233 | :ensure t 234 | :bind-keymap ("s-p" . projectile-command-map) 235 | :init 236 | (setq projectile-mode-line-function '(lambda () (format " [%s]" (projectile-project-name)))) 237 | :config 238 | (projectile-mode +1)) 239 | ``` 240 | 241 | ### [company](https://github.com/company-mode/company-mode) 242 | 243 | ```el 244 | (use-package company 245 | :ensure t 246 | :delight company-mode 247 | :demand t 248 | :init 249 | (setq company-idle-delay 0.1 250 | company-minimum-prefix-length 1) 251 | :bind (:map company-active-map 252 | ("C-n" . company-select-next) 253 | ("C-p". company-select-previous)) 254 | :config 255 | (global-company-mode)) 256 | ``` 257 | --------------------------------------------------------------------------------