source: dotfiles/emacs/.emacs.d/.emacs-config.org@ 7bfb563

Last change on this file since 7bfb563 was 7f6d0e1, checked in by Mikhail Kirillov <w96k@…>, on Jul 31, 2024 at 3:41:20 AM

Update emacs config

  • Property mode set to 100644
File size: 53.4 KB
Line 
1#+TITLE: Конфигурация Emacs
2#+AUTHOR: Кириллов <w96k.dev> Михаил
3#+OPTIONS: toc:nil
4#+PROPERTY: header-args:elisp :results silent
5#+STARTUP: showeverything
6
7* Вклады
8Конфигурация составлена из моего кода, а также кода из конфигураций
9других людей. Их настолько, что все перечислять я не смогу, но оставлю
10интересные конфигурации других людей, в которые я время от времени
11заглядываю.
12
13* Лицензия
14Я выступаю против копирайта и интеллектуальной собственности в целом,
15поэтому стараюсь копирайт избегать. По этой причине свой код
16распространяю на правах общественного достояния вашей страны. Для этого
17используется лицензия [[https://creativecommons.org/publicdomain/zero/1.0/][CC0]]. Если кратко, то можете использовать без
18ограничений вплоть до полной приватизации всего контента. К сожалению за
19чужие сниппеты не могу ручаться, они распространяются по своим лицензиям
20и я их не указывал, впрочем всё равно никто это не проверяет и я бы не
21стал напрягаться из-за авторских прав на конфигурацию текстового
22редактора.
23
24* О конфигурации
25Минимальная конфигурация Emacs. Пакеты ставлю через Guix или package.el
26(elpa и melpa), для разделения ответственности использую грамотное
27программирование при помощи org-mode.
28
29Версия Emacs 28+.
30- В Guix пакет ~emacs-next~
31- В FreeBSD пакет ~emacs-devel~
32- В Ubuntu [[https://launchpad.net/~kelleyk/+archive/ubuntu/emacs][PPA emacs28]] и пакет ~emacs28-native~
33
34Из программирования поддерживаются /C/, Java, /Python/, /Common Lisp /
35Scheme/, Haskell, Idris, Ocaml, /Ruby/, PHP, /SML/, SQL, Erlang,
36редактирование веб-шаблонов и различных форматов конфигураций. Какие-то
37языки в лучшей мере настроены, какие-то хуже, но есть почти все
38плюс-минус популярные.
39
40Для систем контроля версий использую встроенный /VC/ и в некоторых случаях
41/Magit/. Для входа в виртуальные среды используется Direnv.
42
43Для ведения заметок использую методологию Zettelkasten при помощи
44org-roam. Для доступа к оффлайн википедии и другим ресурсам Kiwix
45клиент, который стучится на сервер, который стоит дома.
46
47Для коммуникаций клиент для Telegram /telega/, для IRC /erc/ и электронной
48почты /gnus/, для Mastodon mastodon.el.
49
50Для системного администрирования имеют пакеты для работы с Debian,
51NixOS, Guix. Также есть поддержка Docker, Docker-compose: можно
52запускать/стопать контейнеры, а также залетать в них через TRAMP.
53
54Для установки необходимо установить пакеты Emacs из ~../../guix/user.scm~
55и выполнить tangle файла при помощи /M-x org-babel-tangle-file/. В
56дальнейшем для развёртывания конфигурации можно использовать /M-x
57config-tangle/ или /M-x config-load/.
58
59Данная конфигурация доступна также в сети интернет по адресу, но так как
60сайт обновляется нечасто, то там может лежать старая версия:
61https://w96k.dev/emacs.html
62
63Исходники конфигурации лежат на Sourcehut:
64https://git.sr.ht/~w96k/dotfiles/tree/master/item/emacs
65
66Распространяется на условиях свободной лицензии [[https://gnu.org/licenses/gpl-3.0.ru.html][GNU GPL v3]],
67реиспользование одобряется пока распространяется под той же лицензией.
68
69* Пакеты
70Данная конфигурация использует следующие пакеты:
71
72- Avy :: Прыжки по тексту
73- Anaconda :: Поддержка Python
74- Auctex :: Поддержка Tex и LaTeX
75- Browse Kill Ring :: Обзор буфера обмена
76- Haskell Mode :: Поддержка языка Haskell
77- Idris Mode :: Поддержка языка Idris
78- Magit :: Интерфейс к git
79- Gitpatch :: Создание патчей
80- Goto Cgh :: Переход к последнему изменению в буфере
81- Debbuge :: Интерфейс debbugs (репорт багов Debian)
82- Deft :: Полнотекстовый поиск
83- Direnv :: Изменение окружения при "входе" в директорию
84- Docker и Docker Compose :: Моды для поддержки контейнерных технологий
85- Exec Path From Shell :: Синхронизация PATH переменной из шелла
86- Expand Region :: Семантическое расширение выделения на курсоре
87- Robe :: Прыжки по определениям Ruby
88- Geiser :: Repl для языка Scheme
89- Guix :: Интерфейс к Guix
90- Org Roam :: Zettelkasten заметки в org-mode
91- Gnuplot :: Программное рисование графиков
92- Nix Mode :: Поддержка языка Nix
93- Pdf Tools :: Рендер PDF файлов в Emacs
94- PHP Mode :: Поддержка языка PHP
95- Kiwix :: Чтение скачанных архивов веб-страниц
96- SML Mode :: Поддержка языка Standard ML
97- Sly/Slime :: REPL языка Common Lisp
98- Simple HTTPD :: HTTP Сервер на elisp
99- Telega :: Интерфейс к Telegram
100- Treemacs :: Сайдбар для навигации по проекту
101- Undo Tree :: Визуализация дерева отмен
102- Yasnippet и Yasnippet Snippets :: Сниппеты для текстов и ЯПов
103- Web Mode :: Поддержка шаблонов HTML и прочего
104
105Следующий блок нужен для тех, кто хочет использовать встроенный пакетный
106менеджер. Я использую Guix для большей части взаимодействий со сторонним
107кодом.
108#+begin_src elisp :tangle nil
109 (require 'package)
110
111 (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
112 ("melpa" . "http://melpa.org/packages/")))
113
114 (when (< emacs-major-version 27)
115 (package-initialize))
116
117 (require 'gnutls)
118
119 (progn
120 (package-refresh-contents)
121 (package-install 'avy)
122 (package-install 'php-mode)
123 (package-install 'phps-mode)
124 ;; (package-install 'anzu)
125 (package-install 'anaconda-mode)
126 (package-install 'auctex)
127 ;; (package-install 'rmsbolt)
128 ;; (package-install 'beginend)
129 ;; (package-install 'composer)
130 (package-install 'cinspect)
131 (package-install 'debian-el)
132 (package-install 'dpkg-dev-el)
133 (package-install 'edebug-inline-result)
134 ;;(package-install 'haskell-mode)
135 ;;(package-install 'idris-mode)
136 (package-install 'magit)
137 (package-install 'git-timemachine)
138 (package-install 'git-dwim)
139 (package-install 'gitpatch)
140 (package-install 'goto-chg)
141 (package-install 'debbugs)
142 ;;(package-install 'deft)
143 ;; (package-install 'direnv)
144 (package-install 'dumb-jump)
145 (package-install 'docker)
146 (package-install 'docker-cli)
147 (package-install 'docker-tramp)
148 (package-install 'docker-compose-mode)
149 (package-install 'org-sql)
150 ;;(package-install 'eglot)
151 ;; (package-install 'eglot-java)
152 ;; (package-install 'mastodon)
153 ;; (package-install 'exec-path-from-shell)
154 (package-install 'expand-region)
155 ;; (package-install 'flymake-php)
156 (package-install 'flycheck)
157 (package-install 'flycheck-phpstan)
158 (package-install 'phpactor)
159 ;;(package-install 'robe)
160 (package-install 'geiser)
161 (package-install 'geiser-guile)
162 (package-install 'guix)
163 ;; (package-install 'git-gutter)
164 ;; (package-install 'gnuplot)
165 ;;(package-install 'swiper)
166 ;;(package-install 'sqlite3)
167 (package-install 'org-roam)
168 ;; (package-install 'org-roam-ui)
169 ;; (package-install 'org-download)
170 ;; (package-install 'org-babel-eval-in-repl)
171 ;;(package-install 'ob-php)
172 ;; (package-install 'on-screen)
173 ;;(package-install 'nix-mode)
174 (package-install 'pdf-tools)
175 ;;(package-install 'phpactor)
176 ;; (package-install 'company-quickhelp)
177 ;;(package-install 'ac-php)
178 (package-install 'php-mode)
179 (package-install 'php-quickhelp)
180 (package-install 'phan)
181 ;;(package-install 'php-cs-fixer)
182 ;; (package-install 'company-php)
183 ;;(package-install 'php-eldoc)
184 ;;(package-install 'phps-mode)
185 (package-install 'realgud)
186 ;; (package-install 'realgud-xdebug)
187 ;; (package-install 'kiwix)
188 ;;(package-install 'sml-mode)
189 (package-install 'sly)
190 (package-install 'simple-httpd)
191 (package-install 'sudo-edit)
192 ;;(package-install 'treemacs)
193 (package-install 'undo-tree)
194 ;; (package-install 'yasnippet)
195 ;; (package-install 'yasnippet-snippets)
196 ;; (package-install 'vimrc-mode)
197 ;; (package-install 'flymake-phpcs)
198 ;; (package-install 'flymake-phpstan)
199 ;; (package-install 'no-littering)
200 (package-install 'web-mode)
201 ;; (package-install 'which-key)
202 ;; (package-install 'reverse-im)
203 (package-install 'imenu-list)
204 ;; (package-install 'isearch-mb)
205 (package-install 'visual-fill-column)
206 ;; (package-install 'browse-kill-ring)
207 (package-install 'corfu)
208 ;; (package-install 'inf-ruby)
209 (package-install 'yaml-mode)
210 ;; (package-install 'geben)
211 (package-install 'link-hint)
212 (package-install 'whole-line-or-region)
213 (package-install 'quickrun)
214 ;; (package-install 'psysh)
215 ;; (package-install 'restclient)
216 )
217#+end_src
218
219* Инициализация
220Следующие блоки кода выводят в файл early-init.el
221** Компиляция
222JIT компиляция elisp кода в машинный
223#+begin_src elisp :tangle nil
224 (when (eq window-system 'pgtk)
225 (pgtk-use-im-context t))
226
227 (when (fboundp 'native-compile-async)
228 (setq comp-async-compilation t
229 package-native-compile t
230
231 native-comp-speed 2
232 native-comp-async-jobs-number 1
233 comp-num-cpus 2
234 ;; JIT Compilation
235 native-comp-deferred-compilation t
236 ;; AOT Compilation
237 package-native-compile t
238 comp-async-report-warnings-errors nil))
239#+end_src
240
241*** Ручная компиляция
242#+begin_src elisp :tangle nil :results nil
243 ;; (native-compile-async "~/.emacs.d/elpa/" 'recursively)
244 (native-compile-async "~/.guix-profile/share/emacs/site-lisp" 'recursively)
245
246 ;; block until native compilation has finished
247 (while (or comp-files-queue
248 (> (comp-async-runnings) 0))
249#+end_src
250
251** Отключаем ненужные загрузки
252#+begin_src emacs-lisp :tangle nil
253 ;; Disable guix autoloading and x resources loading
254 (setq site-run-file nil)
255#+end_src
256
257** EXWM
258
259#+begin_src emacs-lisp :tangle nil
260 (require 'exwm)
261 (require 'exwm-config)
262 (exwm-config-example)
263#+end_src
264
265
266** Редакируем GUI
267Удаляем ненужные бары, меняем шрифт и модлайн. Использую дефолтный для
268шрифт DeJavu или недефолтный Agave, так как он является одним из самых интернациональных
269шрифтов по количеству доступных символов после Unifont. Unifont я не
270стал использовать, потому что иксы замыливают этот пиксельный шрифт, что
271делает его использование крайне неприятным.
272
273#+begin_src emacs-lisp :tangle nil
274 ;; Change mode-line-modes to show only major mode
275 (defvar mode-line-major-mode
276 (let ((recursive-edit-help-echo "Recursive edit, type C-M-c to get out"))
277 (list (propertize "%[" 'help-echo recursive-edit-help-echo)
278 `(:propertize ("" mode-name)
279 help-echo "Major mode\n\
280 mouse-1: Display major mode menu\n\
281 mouse-2: Show help for major mode\n\
282 mouse-3: Toggle minor modes"
283 mouse-face mode-line-highlight
284 local-map ,mode-line-major-mode-keymap)
285 '("" mode-line-process)
286 (propertize "%n" 'help-echo "mouse-2: Remove narrowing from buffer"
287 'mouse-face 'mode-line-highlight
288 'local-map (make-mode-line-mouse-map
289 'mouse-2 #'mode-line-widen))
290 (propertize "%]" 'help-echo recursive-edit-help-echo)
291 " "))
292 "Mode line construct for displaying major and minor modes.")
293
294 (put 'mode-line-major-mode 'risky-local-variable t)
295
296 ;; Change mode-line-format
297 (setq-default mode-line-format
298 '("%e"
299 mode-line-front-space
300 mode-line-mule-info
301
302 mode-line-client
303 mode-line-modified
304 mode-line-remote
305 mode-line-frame-identification
306 ;; long-path
307 mode-line-buffer-identification
308 mode-line-misc-info
309 " "
310 mode-line-major-mode
311 " "
312 vc-mode
313 " "
314
315 mode-line-position
316 mode-line-end-spaces
317 ))
318#+end_src
319
320
321#+begin_src emacs-lisp :tangle nil
322 ;; Do not resize the frame at this early stage.
323 (setq frame-inhibit-implied-resize t)
324 (setq use-dialog-box nil)
325
326 ;;; Disable some gui
327 (scroll-bar-mode -1)
328 (tool-bar-mode -1)
329 (menu-bar-mode -1)
330 ;;(tooltip-mode -1)
331
332 ;;; Changing emacs default setting through customize
333 (custom-set-variables
334 '(fill-column 72)
335 '(git-gutter:added-sign " ")
336 '(git-gutter:deleted-sign " ")
337 '(git-gutter:modified-sign " ")
338 '(git-gutter:unchanged-sign " ")
339 '(lsp-headerline-breadcrumb-enable nil)
340 '(scroll-bar-mode 'nil)
341 '(scroll-bar-adjust-thumb-portion nil)
342 '(tool-bar-position 'bottom)
343 '(tool-bar-style 'both-horiz))
344
345 (custom-set-faces
346 '(default ((t (:height 140 :family "Jetbrains Mono" :embolden t))))
347 '(region ((t (:background "gray85"))))
348 '(mode-line ((t (:background "grey70" :foreground "grey10"))))
349 '(mode-line-inactive ((t (:inherit mode-line :background "grey90" :foreground "grey20" :box (:line-width (-2 . -2) :color "grey85") :weight light))))
350 '(mode-line-buffer-id ((t (:weight bold))))
351 '(mode-line-emphasis ((t (:weight bold))))
352 '(lsp-modeline-code-actions-face ((t :inherit mode-line :height 100)))
353 '(tool-bar ((t (:background "grey80" :foreground "grey10"))))
354 '(fill-column-indicator ((t (:foreground "grey95"))))
355 '(hl-line ((t (:background "gray95"))))
356 '(fringe ((t (:background "grey87"))))
357 '(header-line ((t (:inherit mode-line :background "grey90"))))
358 '(vertical-border ((t (:foreground "grey90"))))
359 '(window-divider ((t (:foreground "gray90")))))
360
361 (set-fringe-style (cons 7 7))
362
363 (defun switch-gui ()
364 "Disable/enable menu-bar and tool-bar."
365 (interactive)
366 (if menu-bar-mode
367 (progn
368 (menu-bar-mode -1)
369 (tool-bar-mode -1)
370 (scroll-bar-mode -1))
371 (progn
372 (menu-bar-mode 1)
373 (tool-bar-mode 1)
374 (scroll-bar-mode 1))))
375
376 (defun switch-scroll-bar ()
377 "Disable/enable scroll-bar."
378 (interactive)
379 (if scroll-bar-mode
380 (scroll-bar-mode -1)
381 (scroll-bar-mode)))
382
383 (define-key global-map (kbd "<f5>") 'switch-gui)
384 (define-key global-map (kbd "<f8>") 'switch-scroll-bar)
385
386 (provide 'early-init)
387 ;;; early-init.el ends here
388#+end_src
389
390** Инициализируем остальной конфиг
391Следующие блоки кода выводят в файл init.el.
392#+begin_src emacs-lisp :tangle init.el
393 ;; -*- lexical-binding: t -*-
394
395 ;; Show/Hide errors
396 ;; (setq debug-on-error nil)
397 ;; (setq debug-on-quit nil)
398
399 (require 'package)
400 (package-initialize)
401
402 (defun package-loaded? (string)
403 (if (or (cl-member string package-activated-list :test #'string=)
404 (ignore-errors (load (concat string "-autoloads"))))
405 t
406 (progn
407 (message (concat "Package " string " is not loaded"))
408 nil)))
409
410 ;; Timer
411 (add-hook 'emacs-startup-hook
412 (lambda ()
413 (message
414 "Emacs ready in %s with %d garbage collections."
415 (format "%.2f seconds"
416 (float-time
417 (time-subtract after-init-time before-init-time)))
418 gcs-done)))
419
420 ;; Dont ask when following symlinks
421 (setq vc-follow-symlinks t)
422
423 ;; Load your custom settings
424 (setq custom-file "~/.emacs.d/custom-settings.el")
425 (load custom-file t)
426#+end_src
427
428* Meta
429** Обо мне
430#+BEGIN_SRC emacs-lisp :tangle init.el
431 ;; Information about me
432 (setq user-full-name "Mikhail Kirillov"
433 user-mail-address "w96k@runbox.com")
434#+END_SRC
435
436** Конфигурация
437Базовые функции для манипулирования конфигом в дальнейшем, чтобы не
438приходилось танглить вручную.
439#+BEGIN_SRC emacs-lisp :tangle init.el
440 (setq config-dotfiles-path "~/projects/dotfiles/emacs/.emacs.d/"
441 config-path "~/.emacs.d/"
442 config-name ".emacs-config.org")
443
444 (defun config-visit ()
445 (interactive)
446 (find-file (concat config-path config-name)))
447
448 (defun config-tangle ()
449 (interactive)
450 (org-babel-tangle-file (concat config-dotfiles-path config-name))
451 ;; Configuration stored in another directory,
452 ;; so I need to move files .emacs.d manually
453 ;; (rename-file (concat config-dotfiles-path "early-init.el") config-path t)
454 (rename-file (concat config-dotfiles-path "init.el") config-path t))
455
456 (defun config-load ()
457 (interactive)
458 (org-babel-load-file (concat config-dotfiles-path config-name) t))
459
460#+END_SRC
461
462* Внешний вид
463
464** Отображение номера строк и пробелов
465Изначально они отключены, но можно вызвать по клавише F7.
466#+BEGIN_SRC emacs-lisp :tangle init.el
467 (define-key global-map
468 (kbd "<f7>") 'global-display-line-numbers-mode)
469
470 (define-key global-map
471 (kbd "<f6>") 'whitespace-mode)
472#+END_SRC
473
474* Редактирование
475** Файловый менеджер
476#+BEGIN_SRC emacs-lisp :tangle init.el
477 ;; Show files in KiB
478 (setq dired-listing-switches "-hlap"
479 dired-kill-when-opening-new-dired-buffer t)
480
481 (customize-set-variable 'global-auto-revert-non-file-buffers t)
482 (global-auto-revert-mode 1)
483#+END_SRC
484
485** Линтер
486Использую встроенный Flymake и Flycheck
487*** Flymake
488#+BEGIN_SRC emacs-lisp :tangle nil
489 ;;(add-hook 'prog-mode-hook 'flymake-mode)
490
491 (require 'psalm)
492
493 (define-prefix-command 'flymake-map)
494 (global-set-key (kbd "C-q") 'flymake-map)
495 (define-key flymake-map (kbd "n") 'flymake-goto-next-error)
496 (define-key flymake-map (kbd "p") 'flymake-goto-prev-error)
497 (define-key flymake-map (kbd "l") 'flymake-show-diagnostics-buffer)
498 (define-key flymake-map (kbd "e") 'flymake-show-diagnostic)
499#+END_SRC
500
501*** Flycheck
502#+BEGIN_SRC emacs-lisp :tangle nil
503 ;; (require 'psalm)
504
505 (when (package-loaded? "flycheck")
506
507 (defun flycheck-phanclient-start-daemon ()
508 "Start the phan daemon"
509 (interactive)
510 (let* ((default-directory (php-project-get-root-dir))
511 (phan-executable (or flycheck-phanclient--phan-executable
512 (if (file-exists-p "vendor/bin/phan")
513 (concat default-directory "vendor/bin/phan")
514 (executable-find "phan"))))
515 (cmd (list phan-executable "--daemonize-tcp-port" "4846" "--quick")))
516 (apply #'start-process "PhanDaemon" "*phan daemon*" cmd)))
517
518 (flycheck-define-checker php-phanclient
519 "Phan"
520 :command ("phan_client" "-l" source-original "-f" source)
521 :error-patterns
522 ((warning line-start (or "Parse" "Fatal" "syntax" "Phan") " error" (any ":" ",") " " (message) " in " (file-name) " on line " line line-end))
523 :modes (php-mode php+-mode))
524
525 (add-to-list 'flycheck-checkers 'php-phanclient)
526
527 (flycheck-add-next-checker 'php '(warning . php-phanclient))
528
529 (add-hook 'prog-mode-hook 'flycheck-mode))
530#+END_SRC
531
532** Дерево проекта
533Возможно в дальнейшем откажусь от этого пакета, так как по факту им
534пользуюсь нечасто. Он предоставляет дерево проектов, как в IDE.
535#+BEGIN_SRC emacs-lisp :tangle nil
536 (when (package-loaded? "treemacs")
537 (progn
538 (setq treemacs-width 50
539 treemacs-show-cursor t
540 treemacs-position 'right
541 treemacs-indentation 1
542 treemacs-tag-follow-mode t
543 treemacs-fringe-indicator-mode nil)
544
545 (define-key global-map
546 (kbd "C-x C-d") 'treemacs)))
547#+END_SRC
548
549** Дерево imenu
550#+begin_src emacs-lisp :tangle init.el
551 ;; (when (package-loaded? "imenu-list")
552 (setq imenu-list-focus-after-activation nil
553 imenu-list-auto-resize nil
554 imenu-list-mode-line-format '()
555 imenu-list-size 0.4)
556 (global-set-key (kbd "C-x C-d") #'imenu-list-smart-toggle)
557 ;; )
558#+end_src
559
560** Better Isearch
561#+begin_src emacs-lisp :tangle nil
562 (when (package-loaded? "isearch-mb")
563 (progn
564 (isearch-mb-mode t)
565 (global-set-key (kbd "C-s") 'isearch-forward-regexp)
566 (global-set-key (kbd "C-r") 'isearch-backward-regexp)))
567#+end_src
568
569** Система контроля версий
570Модуль VC + Magit.
571
572| Operation | VC | Magit |
573|----------------+-----------------------------------------+----------------------|
574| Project status | project-vc-dir (C-x p v) | magit-status (C-x g) |
575| Pull | vc-update (F, in my case) | magit-pull (F p) |
576| New branch | vc-retrieve-tag (C-u B s) | magit-branch (b c) |
577| Commit | vc-next-action (C-x v v) | magit-commit (c c) |
578| Rebase | shell-command (M-!) + git rebase master | magit-rebase (r p) |
579| Push | vc-push (P or C-u P) | magit-push (P p) |
580| Stash | mu-vc-git-stash (z) | magit-stash (z) |
581| Log | vc-print-root-log (L) | magit-log (l l) |
582https://www.manueluberti.eu//emacs/2021/11/27/vc/
583
584#+BEGIN_SRC emacs-lisp :tangle init.el
585 (setq vc-command-messages t)
586
587 (global-set-key "\C-xvB" 'git-branch-next-action)
588
589 ;; Use magit only when built-in VC fails
590 (when (package-loaded? "magit")
591 (progn
592 (setq magit-refresh-status-buffer nil)
593 (global-set-key (kbd "C-x g") 'magit-status)))
594
595 (package-loaded? "git-timemachine")
596#+END_SRC
597
598** Прыжки
599#+BEGIN_SRC emacs-lisp :tangle init.el
600 (when (package-loaded? "avy")
601 (progn
602 (define-key global-map (kbd "M-s M-s") 'avy-goto-char)
603 (define-key global-map (kbd "M-s s") 'avy-goto-char)
604 (define-key global-map (kbd "M-s g") 'avy-goto-line)
605 (define-key global-map (kbd "M-s l") 'avy-goto-char-in-line)
606 (define-key global-map (kbd "M-s M-l") 'avy-goto-char-in-line)
607
608 ;; Rewrite default bind to avy
609 (define-key global-map (kbd "M-g g") 'avy-goto-line)
610 (define-key global-map (kbd "M-g M-g") 'avy-goto-line)))
611
612 (when (package-loaded? "link-hint")
613 (progn
614 (define-key global-map (kbd "M-s j") 'link-hint-open-link)))
615
616 ;; Прыжок на последнее изменение
617 (when (package-loaded? "goto-chg")
618 (progn
619 (setq glc-default-span 2)
620 (define-key global-map (kbd "C-z") 'goto-last-change)
621 (define-key global-map (kbd "M-z") 'goto-last-change-reverse)))
622
623 ;; Dumb Jump
624 (when (package-loaded? "dumb-jump")
625 (progn
626 (define-key global-map (kbd "C-.") 'dumb-jump-go)))
627
628#+END_SRC
629
630** Проекты
631Использую встроенный project.el
632I use built-in project.el
633** Ограничение ширины строки
634#+BEGIN_SRC emacs-lisp :tangle init.el
635 (when (package-loaded? "visual-fill-column")
636 (progn
637 ;;; Column width limit highlighter
638 (add-hook 'prog-mode-hook 'display-fill-column-indicator-mode)
639
640 ;;; Set column width to 79 according to pep8 for python
641 (add-hook 'python-mode-hook
642 (lambda () (set-fill-column 79)))))
643#+END_SRC
644
645** Подсвечивание парных скобок
646** Ввод парных скобок и кавычек (electric)
647#+BEGIN_SRC emacs-lisp :tangle init.el
648 ;;; Input of pair delimiters
649 (electric-pair-mode)
650 (add-hook 'prog-mode-hook 'electric-pair-mode)
651 ;; (add-hook 'prog-mode-hook 'rainbow-identifiers-mode)
652#+END_SRC
653
654** Kill-ring
655#+BEGIN_SRC emacs-lisp :tangle nil
656 (when (package-loaded? "browse-kill-ring")
657 (define-key global-map (kbd "C-M-y") 'browse-kill-ring))
658#+END_SRC
659
660** Tags
661Для прыжков и поиска функций/классов и т.д.
662#+BEGIN_SRC emacs-lisp :tangle nil
663 (setq path-to-ctags "~/.guix-profile/bin/ctags")
664
665 (defun tags-create (dir-name)
666 "Create tags file."
667 (interactive "DDirectory: ")
668 (shell-command
669 (format "%s -f TAGS -e -R %s" path-to-ctags
670 (directory-file-name dir-name))))
671
672 (defun tags-create-python (dir-name)
673 "Create tags with python interpreter"
674 (interactive "DDirectory: ")
675 (shell-command
676 (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
677 (directory-file-name dir-name))))
678#+END_SRC
679
680** Дополнение
681** Дебаггер
682#+begin_src emacs-lisp :tangle nil
683 (when (package-loaded? "realgud")
684 (load "~/.emacs.d/site-lisp/realgud-xdebug/realgud-xdebug.el"))
685#+end_src
686
687#+begin_src emacs-lisp :tangle nil
688 (when (package-loaded? "geben")
689 (setq geben-dbgp-default-port 9003))
690#+end_src
691
692*** Автодополнение кода и документация
693По большей части я использую дефолтный Completion Buffer и Corfu
694#+begin_src elisp :tangle nil
695 (when (package-loaded? "corfu")
696 (progn
697 (setq corfu-preview-current 'nil
698 corfu-popupinfo-delay t)
699 (corfu-mode 1)
700 (corfu-popupinfo-mode 1)
701 (defun show-default-completion-buffer ()
702 (interactive)
703 (corfu-quit)
704 (corfu-mode -1)
705 (completion-at-point)
706 (corfu-mode 1)
707 (corfu-popupinfo-mode 1))
708 (define-key corfu-map (kbd "M-TAB") 'show-default-completion-buffer)
709 (define-key corfu-map (kbd "TAB") 'show-default-completion-buffer)
710 (define-key corfu-map (kbd "C-M-i") 'show-default-completion-buffer)
711 (corfu-mode -1)
712 (add-hook 'prog-mode-hook 'corfu-mode)
713
714 (defun corfu-send-shell (&rest _)
715 "Send completion candidate when inside comint/eshell."
716 (cond
717 ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
718 (eshell-send-input))
719 ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
720 (comint-send-input))))
721
722 (advice-add #'corfu-insert :after #'corfu-send-shell)
723
724 (add-hook 'eshell-mode-hook 'corfu-mode)))
725
726#+end_src
727*** Модификация дефолта
728#+BEGIN_SRC emacs-lisp :tangle nil
729 (setq completion-styles '(basic partial-completion substring flex emacs22)
730 completion-ignore-case t
731 read-buffer-completion-ignore-case t
732 read-file-name-completion-ignore-case t)
733#+END_SRC
734*** Агрессивный дефолтный комплит
735#+BEGIN_SRC emacs-lisp :tangle nil
736 (setq aggressive-completion-delay 0.5)
737 (aggressive-completion-mode t)
738#+END_SRC
739** Полнотекстовый поиск
740Для выхода из поиска -- C-c C-q
741#+begin_src emacs-lisp :tangle nil
742 (load "deft-autoloads")
743
744 (define-key global-map
745 (kbd "C-c n s") 'deft)
746
747 (setq deft-recursive t
748 deft-use-filter-string-for-filename t
749 deft-default-extension "org md"
750 deft-directory "~/projects/at-w96k/content/digarden")
751#+end_src
752
753** Визуализирование откатов
754При помощи пакета undo-tree
755#+begin_src emacs-lisp :tangle init.el
756 (when (package-loaded? "undo-tree")
757 (progn
758 (add-hook 'prog-mode-hook #'undo-tree-mode)
759 (add-hook 'org-mode-hook #'undo-tree-mode)
760 (setq undo-tree-auto-save-history nil)))
761#+end_src
762
763** Сниппеты
764#+begin_src emacs-lisp :tangle nil
765 (when (package-loaded? "yasnippet")
766 (progn
767 (add-hook 'prog-mode-hook #'yas-minor-mode)))
768#+end_src
769
770** Клиент LSP
771#+begin_src emacs-lisp :tangle init.el
772 ;; (with-eval-after-load 'eglot
773 ;; (add-to-list 'eglot-server-programs '((php-mode phps-mode) . ("~/projects/phpactor/bin/phpactor" "language-server" "-vvv")))
774 ;; (add-to-list 'eglot-server-programs '((php-mode phps-mode) . ("intelephense" "--stdio")))
775
776 ;; ;; No event buffers, disable providers cause a lot of hover traffic. Shutdown unused servers.
777 ;; (setq eglot-events-buffer-size 0
778 ;; eglot-ignored-server-capabilities '(:hoverProvider
779 ;; :documentHighlightProvider)
780 ;; eglot-autoshutdown t))
781
782 ;; Show all of the available eldoc information when we want it. This way Flymake errors
783 ;; don't just get clobbered by docstrings.
784 (add-hook 'eglot-managed-mode-hook
785 (lambda ()
786 "Make sure Eldoc will show us all of the feedback at point."
787 (setq-local eldoc-documentation-strategy
788 #'eldoc-documentation-compose)))
789#+end_src
790
791** Линтеры
792#+begin_src emacs-lisp :tangle nil
793 (defun my-php-mode-setup ()
794 "My PHP-mode hook."
795 (require 'flycheck-phpstan)
796 (flycheck-mode t))
797
798 (add-hook 'php-mode-hook 'my-php-mode-setup)
799#+end_src
800
801#+BEGIN_SRC emacs-lisp :tangle nil
802 ;; (add-hook 'php-mode-hook 'flymake-php-load)
803 ;; (add-hook 'php-mode-hook 'flymake-phpstan-turn-on)
804
805 ;; (require 'flycheck-phpstan)
806
807
808 ;;(add-to-list 'auto-mode-alist '("\\.\\(php\\|phtml\\)\\'" . phps-mode))
809
810 ;; (phps-mode-flycheck-setup)
811
812 ;; (setq phps-mode-async-process t)
813 ;; (setq phps-mode-async-process-using-async-el t)
814#+END_SRC
815
816** Выделение
817#+BEGIN_SRC emacs-lisp :tangle init.el
818 (when (package-loaded? "expand-region")
819 (global-set-key (kbd "C-=") 'er/expand-region))
820#+END_SRC
821
822** Сессия
823#+BEGIN_SRC emacs-lisp :tangle nil
824 (desktop-save-mode 1)
825#+END_SRC
826** Скроллинг
827#+BEGIN_SRC emacs-lisp :tangle init.el
828 (setq scroll-margin 0)
829#+END_SRC
830** Поиск
831*** Isearch
832#+begin_src emacs-lisp :tangle init.el
833 (with-eval-after-load 'isearch
834 (define-key isearch-mode-map "\C-h" 'isearch-delete-char)
835 (define-key isearch-mode-map "\C-ch" 'isearch-help-for-help))
836#+end_src
837
838*** Подсчёт кандидатов
839#+BEGIN_SRC emacs-lisp :tangle nil
840(global-anzu-mode t)
841#+END_SRC
842*** Swiper (не используется)
843#+BEGIN_SRC emacs-lisp :result nil :tangle nil
844 (load "swiper-autoloads")
845 (global-set-key (kbd "C-s") 'swiper)
846
847 (setq swiper-include-line-number-in-search t
848 swiper-use-visual-line t
849 swiper-stay-on-quit t)
850#+END_SRC
851** Подсказка биндов
852Пакет Which-key
853#+begin_src elisp :tangle nil
854 (load "which-key-autoloads")
855 (which-key-setup-side-window-right)
856 (which-key-mode)
857
858 (setq which-key-side-window-max-width 0.5
859 which-key-show-remaining-keys t
860 which-key-max-display-columns 50
861 which-key-max-description-length 35
862 which-key-sort-order 'which-key-local-then-key-order
863 which-key-idle-delay 0.25)
864#+end_src
865
866** Права суперпользователя
867Sudo-edit
868#+begin_src emacs-lisp
869 (package-loaded? "sudo-edit")
870#+end_src
871
872** Промежуточный код
873Показывает собранное состояние будь то собранный куски на ассемблере
874или байт-код при помощи пакета RMSbolt.
875#+begin_src emacs-lisp :tangle nil
876 (add-hook 'prog-mode-hook 'rmsbolt-mode)
877#+end_src
878
879** Быстрый запуск программы
880#+begin_src emacs-lisp :tangle nil
881 ;; (when (package-loaded? "quickrun")
882 ;; (define-key global-map (kbd "C-c C-c") 'quickrun))
883#+end_src
884
885
886* Языки программирования
887** Common Lisp
888*** REPL
889#+BEGIN_SRC emacs-lisp :tangle nil
890 (load "sly-autoloads")
891
892 (setq sly-lisp-implementations
893 '((clisp ("clisp"))
894 (cmucl ("cmucl" "-quiet"))
895 (sbcl ("/opt/sbcl/bin/sbcl") :coding-system utf-8-unix)))
896#+END_SRC
897
898** Erlang
899#+BEGIN_SRC emacs-lisp :tangle nil
900 (load "erlang-autoloads")
901#+END_SRC
902
903** Ruby
904#+BEGIN_SRC emacs-lisp :tangle nil
905 (when (package-loaded? "inf-ruby")
906 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode))
907
908 (when (package-loaded? "inf-ruby")
909 (add-hook 'ruby-mode-hook 'robe-mode))
910#+END_SRC
911
912** Scheme
913#+BEGIN_SRC emacs-lisp :tangle init.el
914 (setq geiser-active-implementations '("guile"))
915#+END_SRC
916
917** Python
918*** Автодополнение и линт
919#+BEGIN_SRC emacs-lisp :tangle nil
920 (when (package-loaded? "anaconda-mode")
921 (progn
922 (add-hook 'python-mode-hook 'anaconda-mode)
923 (add-hook 'python-mode-hook 'anaconda-eldoc-mode)))
924
925 ;; (when (load "flymake" t)
926 ;; (defun flymake-pylint-init ()
927 ;; (let* ((temp-file (flymake-init-create-temp-buffer-copy
928 ;; 'flymake-create-temp-inplace))
929 ;; (local-file (file-relative-name
930 ;; temp-file
931 ;; (file-name-directory buffer-file-name))))
932 ;; (list "epylint" (list local-file))))
933
934 ;; (add-to-list 'flymake-allowed-file-name-masks
935 ;; '("\\.py\\'" flymake-pylint-init)))
936
937 ;; (add-hook 'python-mode-hook 'flymake-mode)
938#+END_SRC
939*** Прыжки в функции стандартной библиотеки на си
940** SML
941#+BEGIN_SRC emacs-lisp :tangle nil
942 (add-hook 'sml-mode-hook 'sml-mode)
943#+END_SRC
944
945** PHP
946*** PHP-Mode
947Необходимо скачать и распаковать мануал PHP (в формате html) в
948директорию ~~/.emacs.d/php-manual/~.
949#+begin_src emacs-lisp :tangle nil
950 ;; (add-to-list 'load-path "~/.emacs.d/site-lisp/realgud-xdebug/")
951 ;; (require 'realgud-xdebug)
952
953 ;; (defun init-php-mode ()
954 ;; (eglot-ensure))
955
956 (with-eval-after-load 'php-mode
957
958 ;; (add-hook 'php-mode-hook #'init-php-mode)
959 )
960
961 (when (package-loaded? "php-mode")
962 (progn
963 (add-hook 'php-mode-hook 'php-enable-symfony2-coding-style)
964 (setq lsp-intelephense-php-version "8.1.16")
965 (defvar phpactor-executable "~/.bin/phpactor")
966 (custom-set-variables '(lsp-phpactor-path "~/usr/local/bin/phpactor"))
967
968 (add-hook 'php-mode-hook
969 '(lambda ()
970 ;; (require 'yasnippet)
971 ;; (require 'yasnippet-snippets)
972
973 (set-fill-column 120)
974
975 ;; (make-local-variable 'eldoc-documentation-function)
976 ;; (setq eldoc-documentation-function
977 ;; 'phpactor-hover)
978 ;; (yas-minor-mode t)
979 (define-key php-mode-map (kbd "C-c h") 'php-quickhelp-at-point)))
980
981 (setq php-manual-path
982 "~/php/php-manual/"
983 php-quickhelp-dir "~/php/php-manual/"
984 php-quickhelp--dest "~/.emacs.d/php-manual/php_manual_en.json")
985
986
987 ;; (add-hook 'php-mode-hook
988 ;; '(lambda ()
989 ;; ;; (auto-complete-mode t)
990
991 ;; ;; (require 'ac-php)
992 ;; (require 'php-quickhelp)
993 ;; (require 'company)
994 ;; (company-mode t)
995 ;; (require 'company-php)
996 ;; (require 'company-quickhelp)
997
998 ;; (require 'yasnippet)
999 ;; (require 'yasnippet-snippets)
1000
1001 ;; (set (make-local-variable 'company-backends)
1002 ;; '((company-ac-php-backend company-dabbrev-code)
1003 ;; php-quickhelp-company-php
1004 ;; company-capf company-files))
1005
1006 ;; (company-quickhelp-mode t)
1007
1008 ;; (define-key php-mode-map (kbd "C-M-i") 'company-complete)
1009 ;; (define-key company-mode-map (kbd "M-TAB") 'company-complete)
1010
1011 ;; ;; (setq ac-sources '(ac-source-php php-quickhelp-company-php))
1012 ;; ;; (setq eldoc-documentation-function
1013 ;; ;; 'php-quickhelp-eldoc-func)
1014
1015 ;; (yas-minor-mode t)
1016
1017 ;; ;; (define-key php-mode-map (kbd "C-M-i") 'auto-complete)
1018 ;; ;; (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
1019
1020 ;; (define-key php-mode-map (kbd "C-c H")
1021 ;; 'php-local-manual-search)
1022
1023 ;; (define-key php-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
1024 ;; (define-key company-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
1025
1026 ;; ;; (define-key php-mode-map (kbd "C-c t") 'ac-php-show-tip)
1027
1028 ;; ;; Jump to definition (optional)
1029 ;; (define-key php-mode-map
1030 ;; (kbd "M-.") 'ac-php-find-symbol-at-point)
1031
1032 ;; ;; Return back (optional)
1033 ;; (define-key php-mode-map
1034 ;; (kbd "M-,") 'ac-php-location-stack-back)))
1035 ))
1036#+end_src
1037
1038*** Composer
1039#+begin_src emacs-lisp :tangle init.el
1040 (setq composer-executable-bin "~/.bin/composer")
1041#+end_src
1042
1043*** Flymake PHP
1044*** REPL
1045*** LSP сервер
1046PHPactor
1047#+begin_src emacs-lisp :tangle nil
1048 (setq phpactor-executable "~/.bin/phpactor")
1049 (custom-set-variables '(lsp-phpactor-path "~/.bin/phpactor"))
1050
1051 (use-package phpactor :ensure t)
1052 (use-package company-phpactor :ensure t)
1053
1054
1055
1056 ;; (with-eval-after-load 'php-mode
1057 ;; (define-key php-mode-map (kbd "M-.") #'phpactor-goto-definition)
1058 ;; (define-key php-mode-map (kbd "M-?") #'phpactor-find-references))
1059#+end_src
1060
1061*** Transient меню
1062#+begin_src emacs-lisp :tangle nil
1063 (require 'transient)
1064 (define-transient-command php-menu ()
1065 "Php"
1066 [["Class"
1067 ("cc" "Copy" phpactor-copy-class)
1068 ("cn" "New" phpactor-create-new-class)
1069 ("cr" "Move" phpactor-move-class)
1070 ("ci" "Inflect" phpactor-inflect-class)
1071 ("n" "Namespace" phpactor-fix-namespace)]
1072 ["Properties"
1073 ("a" "Accessor" phpactor-generate-accessors)
1074 ("pc" "Constructor" phpactor-complete-constructor)
1075 ("pm" "Add missing props" phpactor-complete-properties)
1076 ("r" "Rename var locally" phpactor-rename-variable-local)
1077 ("R" "Rename var in file" phpactor-rename-variable-file)]
1078 ["Extract"
1079 ("ec" "constant" phpactor-extract-constant)
1080 ("ee" "expression" phpactor-extract-expression)
1081 ("em" "method" phpactor-extract-method)]
1082 ["Methods"
1083 ("i" "Implement Contracts" phpactor-implement-contracts)
1084 ("m" "Generate method" phpactor-generate-method)]
1085 ["Navigate"
1086 ("x" "List refs" phpactor-list-references)
1087 ("X" "Replace refs" phpactor-replace-references)
1088 ("." "Goto def" phpactor-goto-definition)]
1089 ["Phpactor"
1090 ("s" "Status" phpactor-status)
1091 ("u" "Install" phpactor-install-or-update)]])
1092#+end_src
1093* Языки декларирования
1094** SQL
1095 to install lsp-server called sqls
1096https://emacs-lsp.github.io/lsp-mode/page/lsp-sqls/
1097#+BEGIN_SRC emacs-lisp :tangle nil
1098 ;; Empty for now (was using emacsql)
1099 (setq lsp-sqls-server "~/go/bin/sqls")
1100
1101 ;; (setq lsp-sqls-workspace-config-path nil)
1102
1103 (setq lsp-sqls-connections
1104 '(((driver . "mysql") (dataSourceName . "dbuser:mangoworms@tcp(localhost:3306)/profile24"))))
1105#+END_SRC
1106
1107The main way to interact with SQL is using org-mode
1108#+begin_src emacs-lisp :tangle nil
1109 (when (package-loaded? "org-sql")
1110 (setq org-sql-files "~/projects/profile24/org"))
1111
1112 (add-hook 'sql-interactive-mode-hook
1113 (lambda ()
1114 (sql-connect "profile24")
1115 (toggle-truncate-lines t)))
1116
1117 (setq sql-connection-alist
1118 '((profile24
1119 (sql-product 'mysql)
1120 (sql-server "localhost")
1121 (sql-user "dbuser")
1122 (sql-password "123456")
1123 (sql-database "testdb")
1124 (sql-port 3306))))
1125#+end_src
1126
1127
1128** Веб шаблоны
1129*** Web-mode
1130#+BEGIN_SRC emacs-lisp :tangle init.el
1131 (when (package-loaded? "web-mode")
1132 (progn
1133
1134 (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
1135 (add-to-list 'auto-mode-alist '("\\.twig.html\\'" . web-mode))
1136
1137 (setq web-mode-markup-indent-offset 2)
1138 (setq web-mode-enable-auto-pairing t)
1139 (setq web-mode-enable-css-colorization t)
1140 (setq web-mode-enable-block-face t)
1141 (setq web-mode-enable-current-element-highlight t)))
1142#+END_SRC
1143
1144** Org
1145*** Org-mode
1146#+BEGIN_SRC emacs-lisp :tangle init.el
1147 (org-babel-do-load-languages
1148 'org-babel-load-languages
1149 '((R . t)
1150 (ditaa . t)
1151 (dot . t)
1152 ;; (php . t)
1153 (emacs-lisp . t)
1154 (gnuplot . t)
1155 (haskell . nil)
1156 (latex . t)
1157 ;;(ledger . t)
1158 (ocaml . nil)
1159 (octave . t)
1160 (python . t)
1161 (ruby . t)
1162 (screen . nil)
1163 (shell . t)
1164 (sql . t)
1165 (js . t)))
1166
1167 (defun org-babel-edit-prep:sql (babel-info)
1168 (setq-local buffer-file-name (->> babel-info caddr (alist-get :tangle)))
1169 (setq-local lsp-buffer-uri (->> babel-info caddr (alist-get :tangle) lsp--path-to-uri))
1170 (setq-local lsp-headerline-breadcrumb-enable nil)
1171 (lsp))
1172
1173 (global-set-key (kbd "C-c l") 'org-store-link)
1174 (global-set-key (kbd "C-c a") 'org-agenda)
1175 (global-set-key (kbd "C-c c") 'org-capture)
1176 ;; (global-set-key (kbd "M-f") 'org-metaright)
1177 ;; (global-set-key (kbd "M-b") 'org-metaleft)
1178 ;; (global-set-key (kbd "M-p") 'org-metaup)
1179 ;; (global-set-key (kbd "M-n") 'org-metadown)
1180
1181 (setq org-default-notes-file "~/Documents/todo.org"
1182 system-time-locale "C"
1183 org-use-speed-commands t
1184 org-adapt-indentation nil
1185 org-return-follows-link t
1186 org-agenda-include-diary t
1187 org-display-remote-inline-images 'download
1188 org-agenda-start-with-log-mode t
1189 org-image-actual-width (list 400)
1190 org-hide-emphasis-markers t
1191 org-outline-path-complete-in-steps nil
1192 org-src-tab-acts-natively t
1193 org-id-track-globally t
1194 org-confirm-babel-evaluate nil)
1195
1196 (setq org-todo-keywords
1197 (quote ((sequence "TODO(t)"
1198 "MIGRATE(m)" "|"
1199 "IN PROGRESS(p)"
1200 "DONE(d)")
1201 (sequence "BLOCKED(w@/!)"
1202 "HOLD(h@/!)" "|"
1203 "CANCELLED(c@/!)"
1204 "PHONE"
1205 "MEETING"
1206 "NEED CLARIFICATION(t)"
1207 ))))
1208 (setq org-todo-keyword-faces
1209 (quote (("TODO" :foreground "red" :weight bold)
1210 ("NEXT" :foreground "blue" :weight bold)
1211 ("DONE" :foreground "forest green" :weight bold)
1212 ("WAITING" :foreground "orange" :weight bold)
1213 ("HOLD" :foreground "magenta" :weight bold)
1214 ("CANCELLED" :foreground "forest green" :weight bold)
1215 ("MEETING" :foreground "forest cyan" :weight bold)
1216 ("PHONE" :foreground "blue" :weight bold))))
1217#+END_SRC
1218
1219*** Org-ref (не используется)
1220
1221#+begin_src emacs-lisp :tangle nil
1222 (load "org-ref-autoloads")
1223
1224 (setq reftex-default-bibliography '("~/Documents/bibliography/references.bib"))
1225
1226 ;; see org-ref for use of these variables
1227 (setq org-ref-bibliography-notes "~/Documents/bibliography/notes.org"
1228 org-ref-default-bibliography '("~/Documents/Bibliography/references.bib")
1229 org-ref-pdf-directory "~/Documents/bibliography/bibtex-pdfs/")
1230#+end_src
1231
1232*** Org-roam
1233#+begin_src emacs-lisp :tangle init.el
1234 (when (package-loaded? "org-roam")
1235 (progn
1236 (setq org-roam-directory (file-truename "~/Zettelkasten")
1237 org-roam-v2-ack t
1238 org-roam-completion-everywhere t
1239 org-roam-index-file (concat org-roam-directory "/20210409054712-жизнь.org")
1240 org-roam-dailies-directory (concat org-roam-directory "journals/"))
1241
1242 (org-roam-db-autosync-mode t)
1243
1244 (defun org-roam-jump-to-index ()
1245 "Stub of recreating the function from V1"
1246 (interactive)
1247 (let
1248 ((org-roam-index org-roam-index-file))
1249 (find-file org-roam-index)))
1250
1251 (define-key global-map
1252 (kbd "C-c n l") 'org-roam-node-insert)
1253 (define-key global-map
1254 (kbd "C-c n f") 'org-roam-node-find)
1255 (define-key global-map
1256 (kbd "C-c n b") 'org-roam-buffer-toggle)
1257 (define-key global-map
1258 (kbd "C-c n t t") 'org-roam-tag-add)
1259 (define-key global-map
1260 (kbd "C-c n t r") 'org-roam-tag-remove)
1261 (define-key global-map
1262 (kbd "C-c n i") 'org-roam-jump-to-index)
1263 (define-key global-map
1264 (kbd "C-c n g") 'org-roam-graph)
1265 (define-key global-map
1266 (kbd "C-c n d") 'org-roam-db-build-cache)
1267 (define-key global-map
1268 (kbd "C-c n r") 'org-roam-node-random)
1269 (define-key global-map
1270 (kbd "C-c n j") 'org-roam-dailies-find-date)))
1271
1272 (customize-set-variable 'org-link-descriptive t)
1273#+end_src
1274
1275*** Агенда и Capture
1276#+begin_src emacs-lisp :tangle init.el
1277 (add-to-list 'org-agenda-files
1278 "~/Documents/todo.org")
1279
1280 (setq org-directory "~/Documents"
1281 org-default-notes-file (concat org-directory "/todo.org"))
1282#+end_src
1283
1284** YAML
1285#+begin_src emacs-lisp
1286 (package-loaded? "yaml-mode")
1287#+end_src
1288
1289* Коммуникации
1290** Gnus
1291#+begin_src emacs-lisp :tangle init.el
1292
1293#+end_src
1294
1295** Telega
1296#+BEGIN_SRC emacs-lisp :tangle init.el
1297 (when (package-loaded? "telega")
1298 (setq telega-filter-custom-show-folders t
1299 telega-chat-fill-column 40
1300 telega-root-fill-column 60
1301 telega-url-shorten-use-images t)
1302
1303 (define-key global-map (kbd "C-c t") telega-prefix-map))
1304#+END_SRC
1305
1306** Mastodon
1307#+begin_src emacs-lisp :tangle nil
1308 (when (package-loaded? "mastodon")
1309 (setq mastodon-active-user "w96k"
1310 mastodon-instance-url "https://fosstodon.org/"))
1311#+end_src
1312
1313* Наука
1314* Разное
1315
1316** Минорные твики дефолтного имакса
1317*** Короткие ответы на вопросы
1318#+begin_src emacs-lisp :tangle init.el
1319 (if (boundp 'use-short-answers)
1320 (setq use-short-answers t)
1321 (advice-add 'yes-or-no-p :override #'y-or-n-p))
1322#+end_src
1323
1324*** Не сохранять дубликаты в killring
1325
1326*** Удалять выделенный регион при вводе текста
1327#+begin_src emacs-lisp :tangle init.el
1328 (delete-selection-mode 1)
1329#+end_src
1330
1331*** Подсвечивать текущую строку
1332#+begin_src emacs-lisp :tangle nil
1333 (global-hl-line-mode 1)
1334#+end_src
1335
1336*** Открывать список буферов в отдельном фрейме
1337#+begin_src emacs-lisp :tangle nil
1338 (add-to-list 'special-display-buffer-names "*Buffer List*")
1339 (setq Buffer-menu-files-only t)
1340#+end_src
1341
1342*** Автодополнение в echo при M-x и других командах
1343#+begin_src emacs-lisp :tangle init.el
1344 (icomplete-mode 1)
1345#+end_src
1346*** Проверять орфографию
1347#+begin_src emacs-lisp :tangle init.el
1348 (flyspell-mode 1)
1349#+end_src
1350
1351*** Не спрашивать о несуществующих буферах
1352#+BEGIN_SRC emacs-lisp :tangle init.el
1353 (setq-default confirm-nonexistent-file-or-buffer t)
1354#+END_SRC
1355
1356*** Переключение буферов
1357#+BEGIN_SRC emacs-lisp :tangle init.el
1358 (global-set-key (kbd "M-o") 'mode-line-other-buffer)
1359#+END_SRC
1360
1361*** Минорные твики
1362#+begin_src emacs-lisp :tangle init.el
1363 ;; (setq redisplay-dont-pause t)
1364
1365 (setq select-enable-clipboard t
1366 select-enable-primary t)
1367
1368 (setq completions-detailed nil)
1369
1370 (setq kill-buffer-delete-auto-save-files t)
1371 (setq next-error-message-highlight t)
1372
1373 (setq mode-line-compact 'long)
1374
1375 (setq completions-group t)
1376
1377 ;;(set-frame-parameter nil 'internal-border-width 0)
1378
1379 ;; (set-window-buffer nil (current-buffer))
1380
1381 (setq default-directory "~/"
1382 delete-seleciton-mode t
1383 inhibit-startup-message t
1384 initial-scratch-message nil
1385 custom-safe-themes t
1386 delete-old-versions t
1387 confirm-kill-processes nil
1388 enable-local-variables t)
1389#+end_src
1390
1391*** Shell
1392#+begin_src emacs-lisp :tangle init.el
1393 (setq ansi-color-for-comint-mode t)
1394 (setq shell-command-prompt-show-cwd t)
1395#+end_src
1396
1397*** Переменная PATH в eshell
1398#+BEGIN_SRC emacs-lisp :tangle nil
1399 (setq exec-path-from-shell-variables
1400 '("PATH" "MANPATH"))
1401
1402 (when (and (memq window-system '(mac ns x))
1403 (not (eq system-type 'berkeley-unix)))
1404 (exec-path-from-shell-initialize))
1405#+END_SRC
1406
1407*** Отображение номера колонки
1408#+BEGIN_SRC emacs-lisp :tangle init.el
1409 (column-number-mode)
1410#+END_SRC
1411
1412*** nobreak символы
1413#+BEGIN_SRC emacs-lisp :tangle init.el
1414 (setq nobreak-char-display nil)
1415#+END_SRC
1416
1417*** Меню
1418*** Сохранять временные файлы не в той же директории
1419#+BEGIN_SRC emacs-lisp :tangle init.el
1420 (defvar backup-dir "~/.emacs.d/backups/")
1421
1422 (setq
1423 backup-by-copying t
1424 backup-directory-alist
1425 '(("~/.emacs.d/backups/"))
1426 version-control nil)
1427#+END_SRC
1428
1429*** Календарь
1430Делаем начало недели в понедельник.
1431#+BEGIN_SRC emacs-lisp :tangle init.el
1432 (setq calendar-week-start-day 1)
1433#+END_SRC
1434
1435*** Вернуться в предыдущий буфер
1436#+BEGIN_SRC emacs-lisp :tangle nil
1437 (define-key global-map (kbd "C-q C-q") 'previous-buffer)
1438 (define-key global-map (kbd "C-S-q C-S-q") 'next-buffer)
1439#+END_SRC
1440*** Смена раскладки (EN / RU) и поддержка биндов на других языках
1441Работает на C-\
1442#+begin_src elisp :tangle init.el
1443 (set-input-method "russian-computer")
1444 (toggle-input-method)
1445#+end_src
1446
1447*** Требовать создания последней пустой строки
1448#+begin_src emacs-lisp :tangle init.el
1449 (setq require-final-newline t)
1450#+end_src
1451
1452*** Стирать текст на C-h как в Bash
1453И переназначаем старые бинды
1454#+begin_src emacs-lisp :tangle nil
1455 (define-key global-map (kbd "C-h") 'delete-backward-char)
1456 (define-key global-map (kbd "C-c h") 'help-command)
1457#+end_src
1458
1459*** Поддержка CamelCase в навигации
1460#+begin_src emacs-lisp :tangle init.el
1461 (global-subword-mode 1)
1462#+end_src
1463
1464*** Kills
1465#+begin_src emacs-lisp :tangle init.el
1466 (define-key global-map (kbd "C-k") 'kill-region)
1467
1468 (when (package-loaded? "whole-line-or-region")
1469 (whole-line-or-region-global-mode))
1470
1471 (define-key global-map (kbd "C-w") 'backward-kill-word)
1472#+end_src
1473
1474
1475** Браузер
1476#+begin_src emacs-lisp :tangle nil
1477 (setq browse-url-browser-function #'eww-browse-url)
1478
1479 (add-hook 'eww-mode-hook
1480 (lambda ()
1481 (set-fill-column 80)
1482 (display-fill-column-indicator-mode)
1483 (visual-fill-column-mode)))
1484#+end_src
1485
1486** Tramp
1487#+begin_src emacs-lisp :tangle nil
1488 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1489#+end_src
1490
1491** Docker
1492#+begin_src emacs-lisp :tangle init.el
1493 (package-loaded? "docker")
1494 (package-loaded? "docker-compose-mode")
1495#+end_src
1496** Debian
1497Инструменты для работы с пакетным менеджером Debian'а apt'ом и смежными
1498инструментами.
1499#+begin_src elisp :tangle nil
1500 (load "debian-el-autoloads")
1501 (load "dpkg-dev-el-autoloads")
1502#+end_src
1503
1504** Guix
1505#+begin_src emacs-lisp :tangle init.el
1506 (package-loaded? "geiser-guile")
1507
1508 (package-loaded? "guix")
1509
1510 (setq geiser-guile-binary "guile")
1511
1512 (with-eval-after-load 'geiser-guile
1513 (progn
1514 (add-to-list 'geiser-guile-load-path "~/projects/guix/")))
1515
1516 (let ((guix-copyright "~/projects/guix/etc/copyright.el"))
1517 (if (file-exists-p guix-copyright)
1518 (load-file "~/projects/guix/etc/copyright.el")))
1519
1520 (setq copyright-names-regexp
1521 (format "%s <%s>" user-full-name user-mail-address))
1522#+end_src
1523
1524** Nix
1525#+begin_src emacs-lisp :tangle nil
1526 (package-loaded? "nix")
1527#+end_src
1528
1529** Direnv
1530#+BEGIN_SRC emacs-lisp :tangle nil
1531 (when (package-loaded? "direnv")
1532 (direnv-mode))
1533#+END_SRC
1534
1535** Баг-трекеры
1536*** Debbugs
1537** PDF
1538
1539** Увеличение/уменьшение шрифта
1540#+BEGIN_SRC emacs-lisp :tangle nil
1541 (defun zoom-in ()
1542 (interactive)
1543 (let ((x (+ (face-attribute 'default :height)
1544 10)))
1545 (set-face-attribute 'default nil :height x)
1546 (set-face-attribute 'mode-line nil :height x)
1547 (set-face-attribute 'mode-line-inactive nil :height x)
1548 (set-face-attribute 'mode-line-position-face nil :height x)))
1549
1550 (defun zoom-out ()
1551 (interactive)
1552 (let ((x (- (face-attribute 'default :height)
1553 10)))
1554 (set-face-attribute 'default nil :height x)
1555 (set-face-attribute 'mode-line nil :height x)
1556 (set-face-attribute 'mode-line-inactive nil :height x)
1557 (set-face-attribute 'mode-line-position-face nil :height x)))
1558
1559 (define-key global-map (kbd "C-=") 'zoom-in)
1560 (define-key global-map (kbd "C-+") 'zoom-out)
1561
1562#+END_SRC
1563
1564** Автокомплит у yes-or-no
1565** Полный экран
1566Открывать Emacs на полный экран
1567#+begin_src emacs-lisp :tangle nil
1568 (add-to-list 'default-frame-alist '(fullscreen . maximized))
1569#+end_src
1570
1571** Фуллскрин
1572Отображать ровно столько строчек, сколько вмещает экран.
1573
1574Не работает с native-comp.
1575
1576#+begin_src elisp :tangle nil
1577 (toggle-frame-fullscreen)
1578
1579 (defun fullscreen ()
1580 "Fullscreen."
1581 (interactive)
1582 (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
1583 ;; if first parameter is '1', can't toggle fullscreen status
1584 '(1 "_NET_WM_STATE_FULLSCREEN" 0)))
1585#+end_src
1586** Удаление буфера и файла
1587#+begin_src elisp :tangle init.el
1588 (defun delete-file-and-buffer ()
1589 "Kill the current buffer and deletes the file it is visiting."
1590 (interactive)
1591 (let ((filename (buffer-file-name)))
1592 (if filename
1593 (if (y-or-n-p (concat "Do you really want to delete file " filename " ?"))
1594 (progn
1595 (delete-file filename)
1596 (message "Deleted file %s." filename)
1597 (kill-buffer)))
1598 (message "Not a file visiting buffer!"))))
1599#+end_src
1600
1601** Длинные строки
1602#+begin_src emacs-lisp :tangle nil
1603 ;; Better support for files with long lines
1604 (setq-default bidi-paragraph-direction 'left-to-right)
1605 (setq-default bidi-inhibit-bpa t)
1606 (global-so-long-mode 1)
1607#+end_src
1608
1609** Make shebang (#!) file executable when saved
1610#+begin_src emacs-lisp :tangle init.el
1611 (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
1612#+end_src
1613
1614** Enable savehist-mode for command history
1615#+begin_src emacs-lisp :tangle init.el
1616 (savehist-mode 1)
1617#+end_src
1618
1619** Ignore case sensitive in completions, search and etc
1620#+begin_src emacs-lisp :tangle init.el
1621 (setq completion-ignore-case t)
1622#+end_src
Note: See TracBrowser for help on using the repository browser.