source: dotfiles/emacs/.emacs.d/.emacs-config.org@ 5acd0cd

Last change on this file since 5acd0cd was 5acd0cd, checked in by w96k <w96k.ru@…>, on Oct 9, 2022 at 11:26:33 PM

Change Zettelkasten settings. Add deleting files ability.

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