source: dotfiles/emacs/.emacs.d/.emacs-config.org@ 877bb6c

Last change on this file since 877bb6c was 877bb6c, checked in by w96k <w96k.ru@…>, on Oct 13, 2022 at 6:59:43 PM

Add whole-line-or-region

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