source: dotfiles/emacs/.emacs.d/.emacs-config.org@ 805d49d

Last change on this file since 805d49d was 805d49d, checked in by w96k <w96k.ru@…>, on Oct 7, 2022 at 1:03:11 PM

Emacs: change some colors for GNU Trisquel setup

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