source: dotfiles/emacs/.emacs.d/.emacs-config.org@ cfa5680

Last change on this file since cfa5680 was cfa5680, checked in by Mikhail Kirillov <w96k@…>, on Sep 18, 2022 at 12:43:50 AM

Emacs: change slime to sly

Because of sticker feature

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