1 | #+TITLE: Emacs configuration
|
---|
2 | #+AUTHOR: Kirillov <w96k.dev> Mikhail
|
---|
3 | #+OPTIONS: toc:nil
|
---|
4 | #+PROPERTY: header-args:elisp :results silent
|
---|
5 | #+STARTUP: showeverything
|
---|
6 |
|
---|
7 | * About this Emacs configuration
|
---|
8 |
|
---|
9 | Configuration uses org-mode to tangle its contents to init.el and then
|
---|
10 | be used by emacs. I use guix home for my emacs config on gnu guix
|
---|
11 | system.
|
---|
12 |
|
---|
13 | If you see :tangle nil it means that snippet is not used anymore, but
|
---|
14 | it is left because it might be valuable in a future for me.
|
---|
15 |
|
---|
16 | This configuration is available here:
|
---|
17 | https://w96k.dev/emacs.html
|
---|
18 |
|
---|
19 | The git source code is hosted on Sourcehut:
|
---|
20 | https://git.sr.ht/~w96k/dotfiles/tree/master/item/emacs
|
---|
21 |
|
---|
22 | The license of emacs config and dotfiles is CC0 which is Public Domain.
|
---|
23 |
|
---|
24 | ** Packets
|
---|
25 | Only needed when I need to install a package from Melpa and not GNU Guix
|
---|
26 | #+begin_src elisp :tangle nil
|
---|
27 | (require 'package)
|
---|
28 |
|
---|
29 | (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
|
---|
30 | ("melpa" . "http://melpa.org/packages/")))
|
---|
31 |
|
---|
32 | (when (< emacs-major-version 27)
|
---|
33 | (package-initialize))
|
---|
34 |
|
---|
35 | (require 'gnutls)
|
---|
36 | #+end_src
|
---|
37 |
|
---|
38 | ** EXWM
|
---|
39 |
|
---|
40 | #+begin_src emacs-lisp :tangle nil
|
---|
41 | (require 'exwm)
|
---|
42 | (require 'exwm-config)
|
---|
43 | (exwm-config-example)
|
---|
44 | #+end_src
|
---|
45 |
|
---|
46 |
|
---|
47 | ** Init.el
|
---|
48 | #+begin_src emacs-lisp :tangle init.el
|
---|
49 | ;; -*- lexical-binding: t -*-
|
---|
50 |
|
---|
51 | ;; Show/Hide errors
|
---|
52 | ;; (setq debug-on-error nil)
|
---|
53 | ;; (setq debug-on-quit nil)
|
---|
54 |
|
---|
55 | ;; Timer
|
---|
56 | (add-hook 'emacs-startup-hook
|
---|
57 | (lambda ()
|
---|
58 | (message
|
---|
59 | "Emacs ready in %s with %d garbage collections."
|
---|
60 | (format "%.2f seconds"
|
---|
61 | (float-time
|
---|
62 | (time-subtract after-init-time before-init-time)))
|
---|
63 | gcs-done)))
|
---|
64 |
|
---|
65 | ;; Dont ask when following symlinks
|
---|
66 | (setq vc-follow-symlinks t)
|
---|
67 |
|
---|
68 | ;; Load your custom settings
|
---|
69 | (setq custom-file "~/.emacs.d/custom-settings.el")
|
---|
70 | (load custom-file t)
|
---|
71 | #+end_src
|
---|
72 |
|
---|
73 | * Meta
|
---|
74 | ** About me
|
---|
75 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
76 | ;; Information about me
|
---|
77 | (setq user-full-name "Mikhail Kirillov"
|
---|
78 | user-mail-address "w96k@runbox.com")
|
---|
79 | #+END_SRC
|
---|
80 |
|
---|
81 | ** Configuration
|
---|
82 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
83 | (setq config-dotfiles-path "/home/w96k/projects/dotfiles/emacs/.emacs.d/"
|
---|
84 | config-path "~/.emacs.d/"
|
---|
85 | config-name ".emacs-config.org")
|
---|
86 |
|
---|
87 | (defun config-visit ()
|
---|
88 | (interactive)
|
---|
89 | (find-file (concat config-path config-name)))
|
---|
90 |
|
---|
91 | (defun config-tangle ()
|
---|
92 | (interactive)
|
---|
93 | (org-babel-tangle-file (concat config-dotfiles-path config-name))
|
---|
94 | ;; Configuration stored in another directory,
|
---|
95 | ;; so I need to move files .emacs.d manually
|
---|
96 | ;; (rename-file (concat config-dotfiles-path "early-init.el") config-path t)
|
---|
97 | (rename-file (concat config-dotfiles-path "init.el") config-path t))
|
---|
98 | #+END_SRC
|
---|
99 |
|
---|
100 | * Appereance
|
---|
101 |
|
---|
102 | ** Line numbers
|
---|
103 | Изначально они отключены, но можно вызвать по клавише F7.
|
---|
104 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
105 | (define-key global-map
|
---|
106 | (kbd "<f7>") 'display-line-numbers-mode)
|
---|
107 |
|
---|
108 | (define-key global-map
|
---|
109 | (kbd "<f6>") 'whitespace-mode)
|
---|
110 | #+END_SRC
|
---|
111 |
|
---|
112 | * Editing
|
---|
113 | ** Completion styles
|
---|
114 | #+begin_src emacs-lisp :tangle init.el
|
---|
115 | (setq completion-styles '(basic partial-completion emacs22 substring))
|
---|
116 | #+end_src
|
---|
117 |
|
---|
118 | ** Dired
|
---|
119 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
120 | ;; Show files in KiB
|
---|
121 | (setq dired-listing-switches "-hlap"
|
---|
122 | dired-kill-when-opening-new-dired-buffer t)
|
---|
123 |
|
---|
124 | (customize-set-variable 'global-auto-revert-non-file-buffers t)
|
---|
125 | (global-auto-revert-mode 1)
|
---|
126 | #+END_SRC
|
---|
127 |
|
---|
128 | ** Linter
|
---|
129 | I use Flymake and Flycheck
|
---|
130 | *** Flymake
|
---|
131 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
132 | (add-hook 'prog-mode-hook 'flymake-mode)
|
---|
133 |
|
---|
134 | (require 'psalm)
|
---|
135 |
|
---|
136 | (define-prefix-command 'flymake-map)
|
---|
137 | (global-set-key (kbd "C-q") 'flymake-map)
|
---|
138 | (define-key flymake-map (kbd "n") 'flymake-goto-next-error)
|
---|
139 | (define-key flymake-map (kbd "p") 'flymake-goto-prev-error)
|
---|
140 | (define-key flymake-map (kbd "l") 'flymake-show-diagnostics-buffer)
|
---|
141 | (define-key flymake-map (kbd "e") 'flymake-show-diagnostic)
|
---|
142 | #+END_SRC
|
---|
143 |
|
---|
144 | *** Flycheck
|
---|
145 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
146 | ;; (require 'psalm)
|
---|
147 |
|
---|
148 | (when (package-loaded? "flycheck")
|
---|
149 |
|
---|
150 | (defun flycheck-phanclient-start-daemon ()
|
---|
151 | "Start the phan daemon"
|
---|
152 | (interactive)
|
---|
153 | (let* ((default-directory (php-project-get-root-dir))
|
---|
154 | (phan-executable (or flycheck-phanclient--phan-executable
|
---|
155 | (if (file-exists-p "vendor/bin/phan")
|
---|
156 | (concat default-directory "vendor/bin/phan")
|
---|
157 | (executable-find "phan"))))
|
---|
158 | (cmd (list phan-executable "--daemonize-tcp-port" "4846" "--quick")))
|
---|
159 | (apply #'start-process "PhanDaemon" "*phan daemon*" cmd)))
|
---|
160 |
|
---|
161 | (flycheck-define-checker php-phanclient
|
---|
162 | "Phan"
|
---|
163 | :command ("phan_client" "-l" source-original "-f" source)
|
---|
164 | :error-patterns
|
---|
165 | ((warning line-start (or "Parse" "Fatal" "syntax" "Phan") " error" (any ":" ",") " " (message) " in " (file-name) " on line " line line-end))
|
---|
166 | :modes (php-mode php+-mode))
|
---|
167 |
|
---|
168 | (add-to-list 'flycheck-checkers 'php-phanclient)
|
---|
169 |
|
---|
170 | (flycheck-add-next-checker 'php '(warning . php-phanclient))
|
---|
171 |
|
---|
172 | (add-hook 'prog-mode-hook 'flycheck-mode))
|
---|
173 | #+END_SRC
|
---|
174 |
|
---|
175 | ** Imenu List
|
---|
176 | #+begin_src emacs-lisp :tangle init.el
|
---|
177 | (use-package imenu-list
|
---|
178 | :bind
|
---|
179 | ("C-x C-d" . imenu-list-smart-toggle)
|
---|
180 | :config
|
---|
181 | (setq imenu-list-focus-after-activation nil
|
---|
182 | imenu-list-auto-resize nil
|
---|
183 | imenu-list-mode-line-format '()
|
---|
184 | imenu-list-size 0.4))
|
---|
185 | #+end_src
|
---|
186 |
|
---|
187 | ** Version Control System
|
---|
188 | Модуль VC + Magit.
|
---|
189 |
|
---|
190 | | Operation | VC | Magit |
|
---|
191 | |----------------+-----------------------------------------+----------------------|
|
---|
192 | | Project status | project-vc-dir (C-x p v) | magit-status (C-x g) |
|
---|
193 | | Pull | vc-update (F, in my case) | magit-pull (F p) |
|
---|
194 | | New branch | vc-retrieve-tag (C-u B s) | magit-branch (b c) |
|
---|
195 | | Commit | vc-next-action (C-x v v) | magit-commit (c c) |
|
---|
196 | | Rebase | shell-command (M-!) + git rebase master | magit-rebase (r p) |
|
---|
197 | | Push | vc-push (P or C-u P) | magit-push (P p) |
|
---|
198 | | Stash | mu-vc-git-stash (z) | magit-stash (z) |
|
---|
199 | | Log | vc-print-root-log (L) | magit-log (l l) |
|
---|
200 | https://www.manueluberti.eu//emacs/2021/11/27/vc/
|
---|
201 |
|
---|
202 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
203 | (setq vc-command-messages t)
|
---|
204 |
|
---|
205 | (global-set-key "\C-xvB" 'git-branch-next-action)
|
---|
206 |
|
---|
207 | ;; Use magit only when built-in VC fails
|
---|
208 |
|
---|
209 | (use-package magit
|
---|
210 | :defer t
|
---|
211 | :bind (("C-x g" . magit-status)))
|
---|
212 |
|
---|
213 | (use-package git-timemachine :defer t)
|
---|
214 | #+END_SRC
|
---|
215 |
|
---|
216 | ** Jumps
|
---|
217 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
218 | ;; Jumps by highlighting symbols on screen
|
---|
219 | (use-package avy
|
---|
220 | :defer t
|
---|
221 | :bind (("M-s M-s" . avy-goto-char)
|
---|
222 | ("M-s s" . avy-goto-char)
|
---|
223 | ("M-s g" . avy-goto-line)
|
---|
224 | ("M-s l" . avy-goto-char-in-line)
|
---|
225 | ("M-s M-l" . avy-goto-char-in-line)
|
---|
226 |
|
---|
227 | ("M-g g" . avy-goto-line)
|
---|
228 | ("M-s M-g" . avy-goto-line)))
|
---|
229 |
|
---|
230 | (use-package link-hint
|
---|
231 | :defer t
|
---|
232 | :bind (("M-s j" . link-hint-open-link)))
|
---|
233 |
|
---|
234 | ;; Jumps to last change
|
---|
235 | (use-package goto-chg
|
---|
236 | :defer t
|
---|
237 | :bind (("C-z" . goto-last-change)
|
---|
238 | ("M-z" . goto-last-change-reverse)))
|
---|
239 |
|
---|
240 | ;; Jumps using grep and similar tools
|
---|
241 | (use-package dumb-jump
|
---|
242 | :defer t
|
---|
243 | :bind (("M-g o" . dumb-jump-go-other-window)
|
---|
244 | ("M-g j" . dumb-jump-go)
|
---|
245 | ("M-g b" . dumb-jump-back)
|
---|
246 | ("M-g q" . dumb-jump-quick-look)
|
---|
247 | ("M-g x" . dumb-jump-go-prefer-external)
|
---|
248 | ("M-g z" . dumb-jump-go-prefer-external-other-window)))
|
---|
249 |
|
---|
250 | #+END_SRC
|
---|
251 |
|
---|
252 | ** Проекты
|
---|
253 | Использую встроенный project.el
|
---|
254 | I use built-in project.el
|
---|
255 | ** Ограничение ширины строки
|
---|
256 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
257 | (add-hook 'prog-mode-hook 'display-fill-column-indicator-mode)
|
---|
258 |
|
---|
259 | ;;; Set column width to 79 according to pep8 for python
|
---|
260 | (add-hook 'python-mode-hook
|
---|
261 | (lambda () (set-fill-column 79)))
|
---|
262 | #+END_SRC
|
---|
263 |
|
---|
264 | ** Ввод парных скобок и кавычек (electric)
|
---|
265 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
266 | ;;; Input of pair delimiters
|
---|
267 | (electric-pair-mode)
|
---|
268 | (add-hook 'prog-mode-hook 'electric-pair-mode)
|
---|
269 | (add-hook 'prog-mode-hook 'electric-indent-mode)
|
---|
270 | #+END_SRC
|
---|
271 |
|
---|
272 | ** Kill-ring
|
---|
273 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
274 | (use-package browse-kill-ring
|
---|
275 | :defer t
|
---|
276 | :bind ("C-M-y" . browse-kill-ring))
|
---|
277 | #+END_SRC
|
---|
278 |
|
---|
279 | ** Tags
|
---|
280 | Для прыжков и поиска функций/классов и т.д.
|
---|
281 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
282 | (setq path-to-ctags "~/.guix-home/profile/bin/ctags")
|
---|
283 |
|
---|
284 | (defun tags-create (dir-name)
|
---|
285 | "Create tags file."
|
---|
286 | (interactive "DDirectory: ")
|
---|
287 | (shell-command
|
---|
288 | (format "%s -f TAGS -e -R %s" path-to-ctags
|
---|
289 | (directory-file-name dir-name))))
|
---|
290 |
|
---|
291 | (defun tags-create-python (dir-name)
|
---|
292 | "Create tags with python interpreter"
|
---|
293 | (interactive "DDirectory: ")
|
---|
294 | (shell-command
|
---|
295 | (format "%s -f TAGS -e -R --fields=+l --languages=python --python-kinds=-iv $(python -c \"import os, sys; print(' '.join('{}'.format(d) for d in sys.path if os.path.isdir(d)))\") %s" path-to-ctags
|
---|
296 | (directory-file-name dir-name))))
|
---|
297 | #+END_SRC
|
---|
298 |
|
---|
299 | #+begin_src emacs-lisp :tangle init.el
|
---|
300 | (use-package ggtags
|
---|
301 | :defer t
|
---|
302 | :hook
|
---|
303 | (c-mode . ggtags-mode))
|
---|
304 | #+end_src
|
---|
305 |
|
---|
306 |
|
---|
307 | ** Дебаггер
|
---|
308 | #+begin_src emacs-lisp :tangle nil
|
---|
309 | (when (package-loaded? "realgud")
|
---|
310 | (load "~/.emacs.d/site-lisp/realgud-xdebug/realgud-xdebug.el"))
|
---|
311 | #+end_src
|
---|
312 |
|
---|
313 | #+begin_src emacs-lisp :tangle nil
|
---|
314 | (when (package-loaded? "geben")
|
---|
315 | (setq geben-dbgp-default-port 9003))
|
---|
316 | #+end_src
|
---|
317 |
|
---|
318 | *** Автодополнение кода и документация
|
---|
319 | По большей части я использую дефолтный Completion Buffer и Corfu
|
---|
320 | #+begin_src elisp :tangle nil
|
---|
321 | (when (package-loaded? "corfu")
|
---|
322 | (progn
|
---|
323 | (setq corfu-preview-current 'nil
|
---|
324 | corfu-popupinfo-delay t)
|
---|
325 | (corfu-mode 1)
|
---|
326 | (corfu-popupinfo-mode 1)
|
---|
327 | (defun show-default-completion-buffer ()
|
---|
328 | (interactive)
|
---|
329 | (corfu-quit)
|
---|
330 | (corfu-mode -1)
|
---|
331 | (completion-at-point)
|
---|
332 | (corfu-mode 1)
|
---|
333 | (corfu-popupinfo-mode 1))
|
---|
334 | (define-key corfu-map (kbd "M-TAB") 'show-default-completion-buffer)
|
---|
335 | (define-key corfu-map (kbd "TAB") 'show-default-completion-buffer)
|
---|
336 | (define-key corfu-map (kbd "C-M-i") 'show-default-completion-buffer)
|
---|
337 | (corfu-mode -1)
|
---|
338 | (add-hook 'prog-mode-hook 'corfu-mode)
|
---|
339 |
|
---|
340 | (defun corfu-send-shell (&rest _)
|
---|
341 | "Send completion candidate when inside comint/eshell."
|
---|
342 | (cond
|
---|
343 | ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
|
---|
344 | (eshell-send-input))
|
---|
345 | ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
|
---|
346 | (comint-send-input))))
|
---|
347 |
|
---|
348 | (advice-add #'corfu-insert :after #'corfu-send-shell)
|
---|
349 |
|
---|
350 | (add-hook 'eshell-mode-hook 'corfu-mode)))
|
---|
351 |
|
---|
352 | #+end_src
|
---|
353 | *** Агрессивный дефолтный комплит
|
---|
354 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
355 | (setq aggressive-completion-delay 0.5)
|
---|
356 | (aggressive-completion-mode t)
|
---|
357 | #+END_SRC
|
---|
358 | ** Полнотекстовый поиск
|
---|
359 | Для выхода из поиска -- C-c C-q
|
---|
360 | #+begin_src emacs-lisp :tangle nil
|
---|
361 | (load "deft-autoloads")
|
---|
362 |
|
---|
363 | (define-key global-map
|
---|
364 | (kbd "C-c n s") 'deft)
|
---|
365 |
|
---|
366 | (setq deft-recursive t
|
---|
367 | deft-use-filter-string-for-filename t
|
---|
368 | deft-default-extension "org md"
|
---|
369 | deft-directory "~/projects/at-w96k/content/digarden")
|
---|
370 | #+end_src
|
---|
371 |
|
---|
372 | ** Визуализирование откатов
|
---|
373 | При помощи пакета undo-tree
|
---|
374 | #+begin_src emacs-lisp :tangle init.el
|
---|
375 | (use-package undo-tree
|
---|
376 | :defer t
|
---|
377 | :hook
|
---|
378 | (prog-mode . undo-tree-mode)
|
---|
379 | (org-mode . undo-tree-mode))
|
---|
380 | #+end_src
|
---|
381 |
|
---|
382 | ** Сниппеты
|
---|
383 | #+begin_src emacs-lisp :tangle nil
|
---|
384 | (when (package-loaded? "yasnippet")
|
---|
385 | (progn
|
---|
386 | (add-hook 'prog-mode-hook #'yas-minor-mode)))
|
---|
387 | #+end_src
|
---|
388 |
|
---|
389 | ** Клиент LSP
|
---|
390 | #+begin_src emacs-lisp :tangle init.el
|
---|
391 | (with-eval-after-load 'eglot
|
---|
392 | (add-to-list 'eglot-server-programs
|
---|
393 | '((php-mode phps-mode php-ts-mode) . ("/home/w96k/projects/phpactor/bin/phpactor" "language-server" "-vvv"))))
|
---|
394 |
|
---|
395 | ;; (with-eval-after-load 'eglot
|
---|
396 | ;; (add-to-list 'eglot-server-programs '((php-mode phps-mode) . ("~/projects/phpactor/bin/phpactor" "language-server" "-vvv")))
|
---|
397 | ;; (add-to-list 'eglot-server-programs '((php-mode phps-mode) . ("intelephense" "--stdio")))
|
---|
398 |
|
---|
399 | ;; ;; No event buffers, disable providers cause a lot of hover traffic. Shutdown unused servers.
|
---|
400 | ;; (setq eglot-events-buffer-size 0
|
---|
401 | ;; eglot-ignored-server-capabilities '(:hoverProvider
|
---|
402 | ;; :documentHighlightProvider)
|
---|
403 | ;; eglot-autoshutdown t))
|
---|
404 |
|
---|
405 | ;; Show all of the available eldoc information when we want it. This way Flymake errors
|
---|
406 | ;; don't just get clobbered by docstrings.
|
---|
407 | (add-hook 'eglot-managed-mode-hook
|
---|
408 | (lambda ()
|
---|
409 | "Make sure Eldoc will show us all of the feedback at point."
|
---|
410 | (setq-local eldoc-documentation-strategy
|
---|
411 | #'eldoc-documentation-compose)))
|
---|
412 | #+end_src
|
---|
413 |
|
---|
414 | ** Линтеры
|
---|
415 | #+begin_src emacs-lisp :tangle nil
|
---|
416 | (defun my-php-mode-setup ()
|
---|
417 | "My PHP-mode hook."
|
---|
418 | (require 'flycheck-phpstan)
|
---|
419 | (flycheck-mode t))
|
---|
420 |
|
---|
421 | (add-hook 'php-mode-hook 'my-php-mode-setup)
|
---|
422 | #+end_src
|
---|
423 |
|
---|
424 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
425 | ;; (add-hook 'php-mode-hook 'flymake-php-load)
|
---|
426 | ;; (add-hook 'php-mode-hook 'flymake-phpstan-turn-on)
|
---|
427 |
|
---|
428 | ;; (require 'flycheck-phpstan)
|
---|
429 |
|
---|
430 |
|
---|
431 | ;;(add-to-list 'auto-mode-alist '("\\.\\(php\\|phtml\\)\\'" . phps-mode))
|
---|
432 |
|
---|
433 | ;; (phps-mode-flycheck-setup)
|
---|
434 |
|
---|
435 | ;; (setq phps-mode-async-process t)
|
---|
436 | ;; (setq phps-mode-async-process-using-async-el t)
|
---|
437 | #+END_SRC
|
---|
438 |
|
---|
439 | ** Выделение
|
---|
440 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
441 | (use-package expand-region
|
---|
442 | :defer t
|
---|
443 | :bind (("C-=" . er/expand-region)))
|
---|
444 | #+END_SRC
|
---|
445 |
|
---|
446 | ** Сессия
|
---|
447 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
448 | (desktop-save-mode 1)
|
---|
449 | #+END_SRC
|
---|
450 | ** Скроллинг
|
---|
451 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
452 | (setq scroll-margin 0)
|
---|
453 | #+END_SRC
|
---|
454 | ** Поиск
|
---|
455 | *** Isearch
|
---|
456 | #+begin_src emacs-lisp :tangle init.el
|
---|
457 | (with-eval-after-load 'isearch
|
---|
458 | (define-key isearch-mode-map "\C-h" 'isearch-delete-char)
|
---|
459 | (define-key isearch-mode-map "\C-ch" 'isearch-help-for-help))
|
---|
460 | #+end_src
|
---|
461 |
|
---|
462 | *** Подсчёт кандидатов
|
---|
463 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
464 | (use-package anzu
|
---|
465 | :config
|
---|
466 | (global-anzu-mode t))
|
---|
467 | #+END_SRC
|
---|
468 | *** Swiper (не используется)
|
---|
469 | #+BEGIN_SRC emacs-lisp :result nil :tangle nil
|
---|
470 | (load "swiper-autoloads")
|
---|
471 | (global-set-key (kbd "C-s") 'swiper)
|
---|
472 |
|
---|
473 | (setq swiper-include-line-number-in-search t
|
---|
474 | swiper-use-visual-line t
|
---|
475 | swiper-stay-on-quit t)
|
---|
476 | #+END_SRC
|
---|
477 | ** Which function
|
---|
478 | #+begin_src emacs-lisp :tangle init.el
|
---|
479 | (which-function-mode t)
|
---|
480 | #+end_src
|
---|
481 |
|
---|
482 | ** Подсказка биндов
|
---|
483 | Пакет Which-key
|
---|
484 | #+begin_src elisp :tangle nil
|
---|
485 | (load "which-key-autoloads")
|
---|
486 | (which-key-setup-side-window-right)
|
---|
487 | (which-key-mode)
|
---|
488 |
|
---|
489 | (setq which-key-side-window-max-width 0.5
|
---|
490 | which-key-show-remaining-keys t
|
---|
491 | which-key-max-display-columns 50
|
---|
492 | which-key-max-description-length 35
|
---|
493 | which-key-sort-order 'which-key-local-then-key-order
|
---|
494 | which-key-idle-delay 0.25)
|
---|
495 | #+end_src
|
---|
496 |
|
---|
497 | ** Права суперпользователя
|
---|
498 | Sudo-edit
|
---|
499 | #+begin_src emacs-lisp :tangle init.el
|
---|
500 | (use-package sudo-edit
|
---|
501 | :defer t)
|
---|
502 | #+end_src
|
---|
503 |
|
---|
504 | ** Промежуточный код
|
---|
505 | Показывает собранное состояние будь то собранный куски на ассемблере
|
---|
506 | или байт-код при помощи пакета RMSbolt.
|
---|
507 | #+begin_src emacs-lisp :tangle init.el
|
---|
508 | (use-package rmsbolt
|
---|
509 | :defer t)
|
---|
510 | #+end_src
|
---|
511 |
|
---|
512 | ** Быстрый запуск программы
|
---|
513 | #+begin_src emacs-lisp :tangle nil
|
---|
514 | ;; (when (package-loaded? "quickrun")
|
---|
515 | ;; (define-key global-map (kbd "C-c C-c") 'quickrun))
|
---|
516 | #+end_src
|
---|
517 |
|
---|
518 |
|
---|
519 | * Языки программирования
|
---|
520 | ** Common Lisp
|
---|
521 | *** REPL
|
---|
522 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
523 | (load "sly-autoloads")
|
---|
524 |
|
---|
525 | (setq sly-lisp-implementations
|
---|
526 | '((clisp ("clisp"))
|
---|
527 | (cmucl ("cmucl" "-quiet"))
|
---|
528 | (sbcl ("/opt/sbcl/bin/sbcl") :coding-system utf-8-unix)))
|
---|
529 | #+END_SRC
|
---|
530 |
|
---|
531 | ** Ruby
|
---|
532 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
533 | (when (package-loaded? "inf-ruby")
|
---|
534 | (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode))
|
---|
535 |
|
---|
536 | (when (package-loaded? "inf-ruby")
|
---|
537 | (add-hook 'ruby-mode-hook 'robe-mode))
|
---|
538 | #+END_SRC
|
---|
539 |
|
---|
540 | ** Scheme
|
---|
541 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
542 | (setq geiser-active-implementations '("guile"))
|
---|
543 | #+END_SRC
|
---|
544 |
|
---|
545 | ** Python
|
---|
546 | *** Автодополнение и линт
|
---|
547 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
548 | (when (package-loaded? "anaconda-mode")
|
---|
549 | (progn
|
---|
550 | (add-hook 'python-mode-hook 'anaconda-mode)
|
---|
551 | (add-hook 'python-mode-hook 'anaconda-eldoc-mode)))
|
---|
552 |
|
---|
553 | ;; (when (load "flymake" t)
|
---|
554 | ;; (defun flymake-pylint-init ()
|
---|
555 | ;; (let* ((temp-file (flymake-init-create-temp-buffer-copy
|
---|
556 | ;; 'flymake-create-temp-inplace))
|
---|
557 | ;; (local-file (file-relative-name
|
---|
558 | ;; temp-file
|
---|
559 | ;; (file-name-directory buffer-file-name))))
|
---|
560 | ;; (list "epylint" (list local-file))))
|
---|
561 |
|
---|
562 | ;; (add-to-list 'flymake-allowed-file-name-masks
|
---|
563 | ;; '("\\.py\\'" flymake-pylint-init)))
|
---|
564 |
|
---|
565 | ;; (add-hook 'python-mode-hook 'flymake-mode)
|
---|
566 | #+END_SRC
|
---|
567 | *** Прыжки в функции стандартной библиотеки на си
|
---|
568 | ** SML
|
---|
569 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
570 | (add-hook 'sml-mode-hook 'sml-mode)
|
---|
571 | #+END_SRC
|
---|
572 | ** Java
|
---|
573 | *** Eglot-java
|
---|
574 | For better integration with eclipse.jdt.ls
|
---|
575 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
576 | (unless (package-installed-p 'eglot-java)
|
---|
577 | (package-vc-install "https://github.com/yveszoundi/eglot-java" nil nil 'eglot-java))
|
---|
578 | #+end_src
|
---|
579 |
|
---|
580 | ** PHP
|
---|
581 | *** PHP-Mode
|
---|
582 | Необходимо скачать и распаковать мануал PHP (в формате html) в
|
---|
583 | директорию ~~/.emacs.d/php-manual/~.
|
---|
584 | #+begin_src emacs-lisp :tangle nil
|
---|
585 | ;; (add-to-list 'load-path "~/.emacs.d/site-lisp/realgud-xdebug/")
|
---|
586 | ;; (require 'realgud-xdebug)
|
---|
587 |
|
---|
588 | ;; (defun init-php-mode ()
|
---|
589 | ;; (eglot-ensure))
|
---|
590 |
|
---|
591 | (use-package php-mode
|
---|
592 | :bind ("C-c h" . 'php-quickhelp-at-point)
|
---|
593 | :config
|
---|
594 |
|
---|
595 | (setq php-manual-path
|
---|
596 | "~/projects/php-manual/"
|
---|
597 | php-quickhelp-dir "~/projects/php-manual/"
|
---|
598 | php-quickhelp--dest "~/projects/php-manual/php_manual_en.json"))
|
---|
599 |
|
---|
600 |
|
---|
601 | ;; (add-hook 'php-mode-hook
|
---|
602 | ;; '(lambda ()
|
---|
603 | ;; ;; (auto-complete-mode t)
|
---|
604 |
|
---|
605 | ;; ;; (require 'ac-php)
|
---|
606 | ;; (require 'php-quickhelp)
|
---|
607 | ;; (require 'company)
|
---|
608 | ;; (company-mode t)
|
---|
609 | ;; (require 'company-php)
|
---|
610 | ;; (require 'company-quickhelp)
|
---|
611 |
|
---|
612 | ;; (require 'yasnippet)
|
---|
613 | ;; (require 'yasnippet-snippets)
|
---|
614 |
|
---|
615 | ;; (set (make-local-variable 'company-backends)
|
---|
616 | ;; '((company-ac-php-backend company-dabbrev-code)
|
---|
617 | ;; php-quickhelp-company-php
|
---|
618 | ;; company-capf company-files))
|
---|
619 |
|
---|
620 | ;; (company-quickhelp-mode t)
|
---|
621 |
|
---|
622 | ;; (define-key php-mode-map (kbd "C-M-i") 'company-complete)
|
---|
623 | ;; (define-key company-mode-map (kbd "M-TAB") 'company-complete)
|
---|
624 |
|
---|
625 | ;; ;; (setq ac-sources '(ac-source-php php-quickhelp-company-php))
|
---|
626 | ;; ;; (setq eldoc-documentation-function
|
---|
627 | ;; ;; 'php-quickhelp-eldoc-func)
|
---|
628 |
|
---|
629 | ;; (yas-minor-mode t)
|
---|
630 |
|
---|
631 | ;; ;; (define-key php-mode-map (kbd "C-M-i") 'auto-complete)
|
---|
632 | ;; ;; (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
|
---|
633 |
|
---|
634 | ;; (define-key php-mode-map (kbd "C-c H")
|
---|
635 | ;; 'php-local-manual-search)
|
---|
636 |
|
---|
637 | ;; (define-key php-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
|
---|
638 | ;; (define-key company-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
|
---|
639 |
|
---|
640 | ;; ;; (define-key php-mode-map (kbd "C-c t") 'ac-php-show-tip)
|
---|
641 |
|
---|
642 | ;; ;; Jump to definition (optional)
|
---|
643 | ;; (define-key php-mode-map
|
---|
644 | ;; (kbd "M-.") 'ac-php-find-symbol-at-point)
|
---|
645 |
|
---|
646 | ;; ;; Return back (optional)
|
---|
647 | ;; (define-key php-mode-map
|
---|
648 | ;; (kbd "M-,") 'ac-php-location-stack-back)))
|
---|
649 | ))
|
---|
650 | #+end_src
|
---|
651 |
|
---|
652 | *** Composer
|
---|
653 | #+begin_src emacs-lisp :tangle init.el
|
---|
654 | (setq composer-executable-bin "~/.bin/composer")
|
---|
655 | #+end_src
|
---|
656 |
|
---|
657 | *** Flymake PHP
|
---|
658 | *** REPL
|
---|
659 | *** LSP сервер
|
---|
660 | PHPactor
|
---|
661 | #+begin_src emacs-lisp :tangle nil
|
---|
662 | (setq phpactor-executable "~/.bin/phpactor")
|
---|
663 | (custom-set-variables '(lsp-phpactor-path "~/.bin/phpactor"))
|
---|
664 |
|
---|
665 | (use-package phpactor :ensure t)
|
---|
666 | (use-package company-phpactor :ensure t)
|
---|
667 |
|
---|
668 |
|
---|
669 |
|
---|
670 | ;; (with-eval-after-load 'php-mode
|
---|
671 | ;; (define-key php-mode-map (kbd "M-.") #'phpactor-goto-definition)
|
---|
672 | ;; (define-key php-mode-map (kbd "M-?") #'phpactor-find-references))
|
---|
673 | #+end_src
|
---|
674 |
|
---|
675 | *** Transient меню
|
---|
676 | #+begin_src emacs-lisp :tangle nil
|
---|
677 | (require 'transient)
|
---|
678 | (define-transient-command php-menu ()
|
---|
679 | "Php"
|
---|
680 | [["Class"
|
---|
681 | ("cc" "Copy" phpactor-copy-class)
|
---|
682 | ("cn" "New" phpactor-create-new-class)
|
---|
683 | ("cr" "Move" phpactor-move-class)
|
---|
684 | ("ci" "Inflect" phpactor-inflect-class)
|
---|
685 | ("n" "Namespace" phpactor-fix-namespace)]
|
---|
686 | ["Properties"
|
---|
687 | ("a" "Accessor" phpactor-generate-accessors)
|
---|
688 | ("pc" "Constructor" phpactor-complete-constructor)
|
---|
689 | ("pm" "Add missing props" phpactor-complete-properties)
|
---|
690 | ("r" "Rename var locally" phpactor-rename-variable-local)
|
---|
691 | ("R" "Rename var in file" phpactor-rename-variable-file)]
|
---|
692 | ["Extract"
|
---|
693 | ("ec" "constant" phpactor-extract-constant)
|
---|
694 | ("ee" "expression" phpactor-extract-expression)
|
---|
695 | ("em" "method" phpactor-extract-method)]
|
---|
696 | ["Methods"
|
---|
697 | ("i" "Implement Contracts" phpactor-implement-contracts)
|
---|
698 | ("m" "Generate method" phpactor-generate-method)]
|
---|
699 | ["Navigate"
|
---|
700 | ("x" "List refs" phpactor-list-references)
|
---|
701 | ("X" "Replace refs" phpactor-replace-references)
|
---|
702 | ("." "Goto def" phpactor-goto-definition)]
|
---|
703 | ["Phpactor"
|
---|
704 | ("s" "Status" phpactor-status)
|
---|
705 | ("u" "Install" phpactor-install-or-update)]])
|
---|
706 | #+end_src
|
---|
707 | * Языки декларирования
|
---|
708 | ** SQL
|
---|
709 | to install lsp-server called sqls
|
---|
710 | https://emacs-lsp.github.io/lsp-mode/page/lsp-sqls/
|
---|
711 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
712 | ;; Empty for now (was using emacsql)
|
---|
713 | (setq lsp-sqls-server "~/go/bin/sqls")
|
---|
714 |
|
---|
715 | ;; (setq lsp-sqls-workspace-config-path nil)
|
---|
716 |
|
---|
717 | (setq lsp-sqls-connections
|
---|
718 | '(((driver . "mysql") (dataSourceName . "dbuser:mangoworms@tcp(localhost:3306)/profile24"))))
|
---|
719 | #+END_SRC
|
---|
720 |
|
---|
721 | The main way to interact with SQL is using org-mode
|
---|
722 | #+begin_src emacs-lisp :tangle nil
|
---|
723 | (when (package-loaded? "org-sql")
|
---|
724 | (setq org-sql-files "~/projects/profile24/org"))
|
---|
725 |
|
---|
726 | (add-hook 'sql-interactive-mode-hook
|
---|
727 | (lambda ()
|
---|
728 | (sql-connect "profile24")
|
---|
729 | (toggle-truncate-lines t)))
|
---|
730 |
|
---|
731 | (setq sql-connection-alist
|
---|
732 | '((profile24
|
---|
733 | (sql-product 'mysql)
|
---|
734 | (sql-server "localhost")
|
---|
735 | (sql-user "dbuser")
|
---|
736 | (sql-password "123456")
|
---|
737 | (sql-database "testdb")
|
---|
738 | (sql-port 3306))))
|
---|
739 | #+end_src
|
---|
740 |
|
---|
741 | *** Sql Viewer
|
---|
742 | #+begin_src emacs-lisp :tangle init.el
|
---|
743 | (unless (package-installed-p 'pg)
|
---|
744 | (package-vc-install "https://github.com/emarsden/pg-el" nil nil 'pg))
|
---|
745 | (unless (package-installed-p 'pgmacs)
|
---|
746 | (package-vc-install "https://github.com/emarsden/pgmacs"))
|
---|
747 |
|
---|
748 | (use-package pgmacs)
|
---|
749 | #+end_src
|
---|
750 |
|
---|
751 |
|
---|
752 | ** Веб шаблоны
|
---|
753 | *** Web-mode
|
---|
754 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
755 | (use-package web-mode
|
---|
756 | :defer t
|
---|
757 | :config
|
---|
758 | (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
|
---|
759 | (add-to-list 'auto-mode-alist '("\\.twig.html\\'" . web-mode))
|
---|
760 | (setq web-mode-markup-indent-offset 2)
|
---|
761 | (setq web-mode-enable-auto-pairing t)
|
---|
762 | (setq web-mode-enable-css-colorization t)
|
---|
763 | (setq web-mode-enable-block-face t)
|
---|
764 | (setq web-mode-enable-current-element-highlight t))
|
---|
765 | #+END_SRC
|
---|
766 |
|
---|
767 | ** Org
|
---|
768 | *** Org-mode
|
---|
769 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
770 | (use-package org
|
---|
771 | :defer t
|
---|
772 | :config
|
---|
773 | (org-babel-do-load-languages
|
---|
774 | 'org-babel-load-languages
|
---|
775 | '((R . t)
|
---|
776 | (ditaa . t)
|
---|
777 | (dot . t)
|
---|
778 | ;; (php . t)
|
---|
779 | (emacs-lisp . t)
|
---|
780 | (gnuplot . t)
|
---|
781 | (haskell . nil)
|
---|
782 | (latex . t)
|
---|
783 | ;;(ledger . t)
|
---|
784 | (ocaml . nil)
|
---|
785 | (octave . t)
|
---|
786 | (python . t)
|
---|
787 | (ruby . t)
|
---|
788 | (screen . nil)
|
---|
789 | (shell . t)
|
---|
790 | (sql . t)
|
---|
791 | (js . t)))
|
---|
792 | (setq org-default-notes-file "~/Documents/todo.org"
|
---|
793 | system-time-locale "C"
|
---|
794 | org-use-speed-commands t
|
---|
795 | org-adapt-indentation nil
|
---|
796 | org-return-follows-link t
|
---|
797 | org-agenda-include-diary t
|
---|
798 | org-display-remote-inline-images 'download
|
---|
799 | org-agenda-start-with-log-mode t
|
---|
800 | org-image-actual-width (list 400)
|
---|
801 | org-hide-emphasis-markers t
|
---|
802 | org-outline-path-complete-in-steps nil
|
---|
803 | org-src-tab-acts-natively t
|
---|
804 | org-id-track-globally t
|
---|
805 | org-confirm-babel-evaluate nil)
|
---|
806 | (setq org-todo-keywords
|
---|
807 | (quote ((sequence "TODO(t)"
|
---|
808 | "MIGRATE(m)"
|
---|
809 | "IN PROGRESS(p)"
|
---|
810 | "DONE(d)")
|
---|
811 | (sequence "BLOCKED(w@/!)"
|
---|
812 | "HOLD(h@/!)" "|"
|
---|
813 | "CANCELLED(c@/!)"
|
---|
814 | "PHONE"
|
---|
815 | "MEETING"
|
---|
816 | "NEED CLARIFICATION(t)"
|
---|
817 | ))))
|
---|
818 | (setq org-todo-keyword-faces
|
---|
819 | (quote (("TODO" :foreground "red" :weight bold)
|
---|
820 | ("NEXT" :foreground "blue" :weight bold)
|
---|
821 | ("DONE" :foreground "forest green" :weight bold)
|
---|
822 | ("WAITING" :foreground "orange" :weight bold)
|
---|
823 | ("HOLD" :foreground "magenta" :weight bold)
|
---|
824 | ("CANCELLED" :foreground "forest green" :weight bold)
|
---|
825 | ("MEETING" :foreground "forest cyan" :weight bold)
|
---|
826 | ("PHONE" :foreground "blue" :weight bold))))
|
---|
827 | :bind
|
---|
828 | ("C-c l" . org-store-link)
|
---|
829 | ("C-c a" . org-agenda)
|
---|
830 | ("C-c c" . org-capture)
|
---|
831 | )
|
---|
832 |
|
---|
833 | (defun org-babel-edit-prep:sql (babel-info)
|
---|
834 | (setq-local buffer-file-name (->> babel-info caddr (alist-get :tangle)))
|
---|
835 | (setq-local lsp-buffer-uri (->> babel-info caddr (alist-get :tangle) lsp--path-to-uri))
|
---|
836 | (setq-local lsp-headerline-breadcrumb-enable nil)
|
---|
837 | (lsp))
|
---|
838 |
|
---|
839 | ;; (global-set-key (kbd "M-f") 'org-metaright)
|
---|
840 | ;; (global-set-key (kbd "M-b") 'org-metaleft)
|
---|
841 | ;; (global-set-key (kbd "M-p") 'org-metaup)
|
---|
842 | ;; (global-set-key (kbd "M-n") 'org-metadown)
|
---|
843 | #+END_SRC
|
---|
844 |
|
---|
845 |
|
---|
846 | *** Org-ref
|
---|
847 | #+begin_src emacs-lisp :tangle nil
|
---|
848 | (load "org-ref-autoloads")
|
---|
849 |
|
---|
850 | (setq reftex-default-bibliography '("~/Documents/bibliography/references.bib"))
|
---|
851 |
|
---|
852 | ;; see org-ref for use of these variables
|
---|
853 | (setq org-ref-bibliography-notes "~/Documents/bibliography/notes.org"
|
---|
854 | org-ref-default-bibliography '("~/Documents/Bibliography/references.bib")
|
---|
855 | org-ref-pdf-directory "~/Documents/bibliography/bibtex-pdfs/")
|
---|
856 | #+end_src
|
---|
857 |
|
---|
858 | *** Org-roam
|
---|
859 | #+begin_src emacs-lisp :tangle init.el
|
---|
860 | (use-package org-roam
|
---|
861 | :defer t
|
---|
862 | :bind
|
---|
863 | ("C-c n l" . org-roam-node-insert)
|
---|
864 | ("C-c n b" . org-roam-buffer-toggle)
|
---|
865 | ("C-c n f" . org-roam-node-find)
|
---|
866 | ("C-c n t t" . org-roam-tag-add)
|
---|
867 | ("C-c n t r" . org-roam-tag-remove)
|
---|
868 | ("C-c n i" . org-roam-jump-to-index)
|
---|
869 | ("C-c n g" . org-roam-graph)
|
---|
870 | ("C-c n d" . org-roam-db-build-cache)
|
---|
871 | ("C-c n r" . org-roam-node-random)
|
---|
872 | ("C-c n j" . org-roam-dailies-find-date)
|
---|
873 | :config
|
---|
874 | (setq org-roam-directory (file-truename "~/Zettelkasten")
|
---|
875 | org-roam-v2-ack t
|
---|
876 | org-roam-completion-everywhere t
|
---|
877 | org-roam-index-file (concat org-roam-directory "/20210409054712-жизнь.org")
|
---|
878 | org-roam-dailies-directory (concat org-roam-directory "journals/"))
|
---|
879 |
|
---|
880 | (org-roam-db-autosync-mode t))
|
---|
881 |
|
---|
882 | (defun org-roam-jump-to-index ()
|
---|
883 | "Stub of recreating the function from V1"
|
---|
884 | (interactive)
|
---|
885 | (let
|
---|
886 | ((org-roam-index org-roam-index-file))
|
---|
887 | (find-file org-roam-index)))
|
---|
888 |
|
---|
889 | (use-package org
|
---|
890 | :defer t
|
---|
891 | :config
|
---|
892 | (customize-set-variable 'org-link-descriptive t)
|
---|
893 |
|
---|
894 | (add-to-list 'org-agenda-files
|
---|
895 | "~/Documents/todo.org")
|
---|
896 |
|
---|
897 | (setq org-directory "~/Documents"
|
---|
898 | org-default-notes-file (concat org-directory "/todo.org")))
|
---|
899 | #+end_src
|
---|
900 |
|
---|
901 | ** YAML
|
---|
902 | #+begin_src emacs-lisp :tangle init.el
|
---|
903 | (use-package yaml-mode
|
---|
904 | :defer t)
|
---|
905 | #+end_src
|
---|
906 |
|
---|
907 | * Коммуникации
|
---|
908 | ** Gnus
|
---|
909 | #+begin_src emacs-lisp :tangle init.el
|
---|
910 |
|
---|
911 | #+end_src
|
---|
912 |
|
---|
913 | ** Telega
|
---|
914 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
915 | (use-package telega
|
---|
916 | :bind (("C-c t" . telega-prefix-map)))
|
---|
917 | #+END_SRC
|
---|
918 |
|
---|
919 | ** Mastodon
|
---|
920 | #+begin_src emacs-lisp :tangle init.el
|
---|
921 | (use-package mastodon
|
---|
922 | :defer t
|
---|
923 | :config
|
---|
924 | (setq mastodon-active-user "w96k"
|
---|
925 | mastodon-instance-url "https://fosstodon.org/"))
|
---|
926 | #+end_src
|
---|
927 |
|
---|
928 | * Разное
|
---|
929 | ** *Highlight
|
---|
930 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
931 | (use-package highlight
|
---|
932 | :defer t)
|
---|
933 | #+end_src
|
---|
934 | ** Минорные твики дефолтного имакса
|
---|
935 | *** Короткие ответы на вопросы
|
---|
936 | #+begin_src emacs-lisp :tangle init.el
|
---|
937 | (if (boundp 'use-short-answers)
|
---|
938 | (setq use-short-answers t)
|
---|
939 | (advice-add 'yes-or-no-p :override #'y-or-n-p))
|
---|
940 | #+end_src
|
---|
941 |
|
---|
942 | *** Не сохранять дубликаты в killring
|
---|
943 |
|
---|
944 | *** Подсвечивать текущую строку
|
---|
945 | #+begin_src emacs-lisp :tangle nil
|
---|
946 | (global-hl-line-mode t)
|
---|
947 | #+end_src
|
---|
948 |
|
---|
949 | *** Автодополнение в echo при M-x и других командах
|
---|
950 | #+begin_src emacs-lisp :tangle init.el
|
---|
951 | (icomplete-mode t)
|
---|
952 | #+end_src
|
---|
953 | *** Проверять орфографию
|
---|
954 | #+begin_src emacs-lisp :tangle init.el
|
---|
955 | (flyspell-mode t)
|
---|
956 | #+end_src
|
---|
957 |
|
---|
958 | *** Не спрашивать о несуществующих буферах
|
---|
959 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
960 | (setq-default confirm-nonexistent-file-or-buffer t)
|
---|
961 | #+END_SRC
|
---|
962 |
|
---|
963 | *** Переключение буферов
|
---|
964 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
965 | (global-set-key (kbd "M-o") 'mode-line-other-buffer)
|
---|
966 | #+END_SRC
|
---|
967 |
|
---|
968 | *** Минорные твики
|
---|
969 | #+begin_src emacs-lisp :tangle init.el
|
---|
970 | ;; (setq redisplay-dont-pause t)
|
---|
971 |
|
---|
972 | (setq select-enable-clipboard t
|
---|
973 | select-enable-primary t)
|
---|
974 |
|
---|
975 | (setq completions-detailed nil)
|
---|
976 |
|
---|
977 | (setq kill-buffer-delete-auto-save-files t)
|
---|
978 | (setq next-error-message-highlight t)
|
---|
979 |
|
---|
980 | (setq mode-line-compact 'long)
|
---|
981 |
|
---|
982 | (setq completions-group t)
|
---|
983 |
|
---|
984 | ;;(set-frame-parameter nil 'internal-border-width 0)
|
---|
985 |
|
---|
986 | ;; (set-window-buffer nil (current-buffer))
|
---|
987 |
|
---|
988 | (setq default-directory "~/"
|
---|
989 | custom-safe-themes t
|
---|
990 | delete-old-versions t
|
---|
991 | enable-local-variables t)
|
---|
992 | #+end_src
|
---|
993 |
|
---|
994 | *** Shell
|
---|
995 | #+begin_src emacs-lisp :tangle init.el
|
---|
996 | (setq ansi-color-for-comint-mode t)
|
---|
997 | (setq shell-command-prompt-show-cwd t)
|
---|
998 | #+end_src
|
---|
999 |
|
---|
1000 | *** Переменная PATH в eshell
|
---|
1001 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
1002 | (setq exec-path-from-shell-variables
|
---|
1003 | '("PATH" "MANPATH"))
|
---|
1004 |
|
---|
1005 | (when (and (memq window-system '(mac ns x))
|
---|
1006 | (not (eq system-type 'berkeley-unix)))
|
---|
1007 | (exec-path-from-shell-initialize))
|
---|
1008 | #+END_SRC
|
---|
1009 |
|
---|
1010 | *** Отображение номера колонки
|
---|
1011 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
1012 | (column-number-mode)
|
---|
1013 | #+END_SRC
|
---|
1014 |
|
---|
1015 | *** nobreak символы
|
---|
1016 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
1017 | (setq nobreak-char-display nil)
|
---|
1018 | #+END_SRC
|
---|
1019 |
|
---|
1020 | *** Меню
|
---|
1021 | *** Сохранять временные файлы не в той же директории
|
---|
1022 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
1023 | (defvar backup-dir "~/.emacs.d/backups/")
|
---|
1024 |
|
---|
1025 | (setq
|
---|
1026 | backup-by-copying t
|
---|
1027 | backup-directory-alist
|
---|
1028 | '(("~/.emacs.d/backups/"))
|
---|
1029 | version-control nil)
|
---|
1030 | #+END_SRC
|
---|
1031 |
|
---|
1032 | *** Календарь
|
---|
1033 | Делаем начало недели в понедельник.
|
---|
1034 | #+BEGIN_SRC emacs-lisp :tangle init.el
|
---|
1035 | (setq calendar-week-start-day 1)
|
---|
1036 | #+END_SRC
|
---|
1037 |
|
---|
1038 | *** Вернуться в предыдущий буфер
|
---|
1039 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
1040 | (define-key global-map (kbd "C-q C-q") 'previous-buffer)
|
---|
1041 | (define-key global-map (kbd "C-S-q C-S-q") 'next-buffer)
|
---|
1042 | #+END_SRC
|
---|
1043 | *** Смена раскладки (EN / RU) и поддержка биндов на других языках
|
---|
1044 | Работает на C-\
|
---|
1045 | #+begin_src elisp :tangle init.el
|
---|
1046 | (set-input-method "russian-computer")
|
---|
1047 | (toggle-input-method)
|
---|
1048 | #+end_src
|
---|
1049 |
|
---|
1050 | *** Требовать создания последней пустой строки
|
---|
1051 | #+begin_src emacs-lisp :tangle init.el
|
---|
1052 | (setq require-final-newline t)
|
---|
1053 | #+end_src
|
---|
1054 |
|
---|
1055 | *** Стирать текст на C-h как в Bash
|
---|
1056 | И переназначаем старые бинды
|
---|
1057 | #+begin_src emacs-lisp :tangle nil
|
---|
1058 | (define-key global-map (kbd "C-h") 'delete-backward-char)
|
---|
1059 | (define-key global-map (kbd "C-c h") 'help-command)
|
---|
1060 | #+end_src
|
---|
1061 |
|
---|
1062 | *** Поддержка CamelCase в навигации
|
---|
1063 | #+begin_src emacs-lisp :tangle init.el
|
---|
1064 | (global-subword-mode 1)
|
---|
1065 | #+end_src
|
---|
1066 |
|
---|
1067 | *** Kills
|
---|
1068 | #+begin_src emacs-lisp :tangle init.el
|
---|
1069 | (use-package whole-line-or-region
|
---|
1070 | :bind (("C-k" . kill-region)
|
---|
1071 | ("C-w" . backward-kill-word))
|
---|
1072 | :config
|
---|
1073 | (whole-line-or-region-global-mode))
|
---|
1074 | #+end_src
|
---|
1075 |
|
---|
1076 |
|
---|
1077 | ** Браузер
|
---|
1078 | #+begin_src emacs-lisp :tangle nil
|
---|
1079 | (setq browse-url-browser-function #'eww-browse-url)
|
---|
1080 |
|
---|
1081 | (add-hook 'eww-mode-hook
|
---|
1082 | (lambda ()
|
---|
1083 | (set-fill-column 80)
|
---|
1084 | (display-fill-column-indicator-mode)
|
---|
1085 | (visual-fill-column-mode)))
|
---|
1086 | #+end_src
|
---|
1087 |
|
---|
1088 | ** Tramp
|
---|
1089 | #+begin_src emacs-lisp :tangle nil
|
---|
1090 | (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
|
---|
1091 | #+end_src
|
---|
1092 |
|
---|
1093 | ** Docker
|
---|
1094 | #+begin_src emacs-lisp :tangle init.el
|
---|
1095 | (use-package docker :defer t)
|
---|
1096 | (use-package docker-compose-mode :defer t)
|
---|
1097 | #+end_src
|
---|
1098 | ** Debian
|
---|
1099 | Инструменты для работы с пакетным менеджером Debian'а apt'ом и смежными
|
---|
1100 | инструментами.
|
---|
1101 | #+begin_src elisp :tangle nil
|
---|
1102 | (load "debian-el-autoloads")
|
---|
1103 | (load "dpkg-dev-el-autoloads")
|
---|
1104 | #+end_src
|
---|
1105 |
|
---|
1106 | ** Guix
|
---|
1107 | #+begin_src emacs-lisp :tangle init.el
|
---|
1108 | ;; (use-package geiser-guile :defer t)
|
---|
1109 |
|
---|
1110 | (use-package guix
|
---|
1111 | :defer t
|
---|
1112 | :config
|
---|
1113 | (setq geiser-guile-binary "guile")
|
---|
1114 | (with-eval-after-load 'geiser-guile
|
---|
1115 | (progn
|
---|
1116 | (add-to-list 'geiser-guile-load-path "~/projects/guix/")))
|
---|
1117 |
|
---|
1118 | (let ((guix-copyright "~/projects/guix/etc/copyright.el"))
|
---|
1119 | (if (file-exists-p guix-copyright)
|
---|
1120 | (load-file "~/projects/guix/etc/copyright.el")))
|
---|
1121 |
|
---|
1122 | (setq copyright-names-regexp
|
---|
1123 | (format "%s <%s>" user-full-name user-mail-address)))
|
---|
1124 | #+end_src
|
---|
1125 |
|
---|
1126 | ** Nix
|
---|
1127 | #+begin_src emacs-lisp :tangle init.el
|
---|
1128 | (use-package nix)
|
---|
1129 | #+end_src
|
---|
1130 |
|
---|
1131 | ** Direnv
|
---|
1132 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
1133 | (when (package-loaded? "direnv")
|
---|
1134 | (direnv-mode))
|
---|
1135 | #+END_SRC
|
---|
1136 |
|
---|
1137 | ** Баг-трекеры
|
---|
1138 | *** Debbugs
|
---|
1139 | ** PDF
|
---|
1140 |
|
---|
1141 | ** Увеличение/уменьшение шрифта
|
---|
1142 | #+BEGIN_SRC emacs-lisp :tangle nil
|
---|
1143 | (defun zoom-in ()
|
---|
1144 | (interactive)
|
---|
1145 | (let ((x (+ (face-attribute 'default :height)
|
---|
1146 | 10)))
|
---|
1147 | (set-face-attribute 'default nil :height x)
|
---|
1148 | (set-face-attribute 'mode-line nil :height x)
|
---|
1149 | (set-face-attribute 'mode-line-inactive nil :height x)
|
---|
1150 | (set-face-attribute 'mode-line-position-face nil :height x)))
|
---|
1151 |
|
---|
1152 | (defun zoom-out ()
|
---|
1153 | (interactive)
|
---|
1154 | (let ((x (- (face-attribute 'default :height)
|
---|
1155 | 10)))
|
---|
1156 | (set-face-attribute 'default nil :height x)
|
---|
1157 | (set-face-attribute 'mode-line nil :height x)
|
---|
1158 | (set-face-attribute 'mode-line-inactive nil :height x)
|
---|
1159 | (set-face-attribute 'mode-line-position-face nil :height x)))
|
---|
1160 |
|
---|
1161 | (define-key global-map (kbd "C-=") 'zoom-in)
|
---|
1162 | (define-key global-map (kbd "C-+") 'zoom-out)
|
---|
1163 |
|
---|
1164 | #+END_SRC
|
---|
1165 |
|
---|
1166 | ** Автокомплит у yes-or-no
|
---|
1167 | ** Полный экран
|
---|
1168 | Открывать Emacs на полный экран
|
---|
1169 | #+begin_src emacs-lisp :tangle nil
|
---|
1170 | (add-to-list 'default-frame-alist '(fullscreen . maximized))
|
---|
1171 | #+end_src
|
---|
1172 |
|
---|
1173 | ** Фуллскрин
|
---|
1174 | Отображать ровно столько строчек, сколько вмещает экран.
|
---|
1175 |
|
---|
1176 | Не работает с native-comp.
|
---|
1177 |
|
---|
1178 | #+begin_src elisp :tangle nil
|
---|
1179 | (toggle-frame-fullscreen)
|
---|
1180 |
|
---|
1181 | (defun fullscreen ()
|
---|
1182 | "Fullscreen."
|
---|
1183 | (interactive)
|
---|
1184 | (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
|
---|
1185 | ;; if first parameter is '1', can't toggle fullscreen status
|
---|
1186 | '(1 "_NET_WM_STATE_FULLSCREEN" 0)))
|
---|
1187 | #+end_src
|
---|
1188 | ** Удаление буфера и файла
|
---|
1189 | #+begin_src elisp :tangle init.el
|
---|
1190 | (defun delete-file-and-buffer ()
|
---|
1191 | "Kill the current buffer and deletes the file it is visiting."
|
---|
1192 | (interactive)
|
---|
1193 | (let ((filename (buffer-file-name)))
|
---|
1194 | (if filename
|
---|
1195 | (if (y-or-n-p (concat "Do you really want to delete file " filename " ?"))
|
---|
1196 | (progn
|
---|
1197 | (delete-file filename)
|
---|
1198 | (message "Deleted file %s." filename)
|
---|
1199 | (kill-buffer)))
|
---|
1200 | (message "Not a file visiting buffer!"))))
|
---|
1201 | #+end_src
|
---|
1202 |
|
---|
1203 | ** Длинные строки
|
---|
1204 | #+begin_src emacs-lisp :tangle nil
|
---|
1205 | ;; Better support for files with long lines
|
---|
1206 | (setq-default bidi-paragraph-direction 'left-to-right)
|
---|
1207 | (setq-default bidi-inhibit-bpa t)
|
---|
1208 | (global-so-long-mode 1)
|
---|
1209 | #+end_src
|
---|
1210 |
|
---|
1211 | ** Make shebang (#!) file executable when saved
|
---|
1212 | #+begin_src emacs-lisp :tangle init.el
|
---|
1213 | (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
|
---|
1214 | #+end_src
|
---|
1215 |
|
---|
1216 | ** Enable savehist-mode for command history
|
---|
1217 | #+begin_src emacs-lisp :tangle init.el
|
---|
1218 | (savehist-mode 1)
|
---|
1219 | #+end_src
|
---|
1220 |
|
---|
1221 | ** Ignore case sensitive in completions, search and etc
|
---|
1222 | #+begin_src emacs-lisp :tangle init.el
|
---|
1223 | (setq completion-ignore-case t
|
---|
1224 | read-buffer-completion-ignore-case t
|
---|
1225 | read-file-name-completion-ignore-case t)
|
---|
1226 | #+end_src
|
---|
1227 |
|
---|
1228 | ** Make scripts executable automatically
|
---|
1229 | #+begin_src emacs-lisp :tangle init.el
|
---|
1230 | (add-hook 'after-save-hook
|
---|
1231 | 'executable-make-buffer-file-executable-if-script-p)
|
---|
1232 | #+end_src
|
---|
1233 |
|
---|
1234 | ** F1 for M-x shell and F2 for grep
|
---|
1235 | #+begin_src emacs-lisp :tangle init.el
|
---|
1236 | (global-set-key (kbd "<f1>") 'shell)
|
---|
1237 | (global-set-key (kbd "<f2>") 'rgrep)
|
---|
1238 | #+end_src
|
---|
1239 |
|
---|
1240 | ** Hippie expand
|
---|
1241 | #+begin_src emacs-lisp :tangle init.el
|
---|
1242 | (global-set-key [remap dabbrev-expand] 'hippie-expand)
|
---|
1243 | #+end_src
|
---|
1244 |
|
---|
1245 | ** Window Divider
|
---|
1246 | #+begin_src emacs-lisp :tangle init.el
|
---|
1247 | (window-divider-mode t)
|
---|
1248 | #+end_src
|
---|
1249 |
|
---|
1250 | ** Use specific font for major modes
|
---|
1251 | #+begin_src emacs-lisp :tangle init.el
|
---|
1252 | (buffer-face-mode t)
|
---|
1253 |
|
---|
1254 | (defun set-normal-font ()
|
---|
1255 | "Set normal weight font in current buffer"
|
---|
1256 | (interactive)
|
---|
1257 | (buffer-face-mode 1)
|
---|
1258 | (setq buffer-face-mode-face '(:weight normal))
|
---|
1259 | (buffer-face-mode))
|
---|
1260 |
|
---|
1261 | ;; Use monospaced font faces in current buffer
|
---|
1262 | (defun set-bold-font ()
|
---|
1263 | "Sets a bold font in current buffer"
|
---|
1264 | (interactive)
|
---|
1265 | (buffer-face-mode 1)
|
---|
1266 | (setq buffer-face-mode-face '(:weight bold))
|
---|
1267 | (buffer-face-mode))
|
---|
1268 |
|
---|
1269 | (add-hook 'dired-mode-hook 'set-normal-font)
|
---|
1270 | (add-hook 'org-mode-hook 'set-normal-font)
|
---|
1271 | (add-hook 'Info-mode-hook 'set-normal-font)
|
---|
1272 | #+end_src
|
---|