source: dotfiles/emacs/.emacs.d/.emacs-config.org@ 451fd67

Last change on this file since 451fd67 was 451fd67, checked in by w96k <w96k.ru@…>, on Oct 5, 2022 at 11:57:22 PM

EMACS: Change some faces

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