source: dotfiles/emacs/.emacs.d/.emacs-config.org@ 70ccdca

Last change on this file since 70ccdca was 70ccdca, checked in by w96k <w96k.ru@…>, on Oct 6, 2022 at 2:45:53 PM

Delete unused config

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