source: dotfiles/emacs/.emacs.d/.emacs-config.org@ 8217b6f

Last change on this file since 8217b6f was 8217b6f, checked in by w96k <w96k@…>, on Oct 19, 2022 at 1:42:34 PM

Change packages; Update org-agenda file;

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