source: dotfiles/emacs/.emacs.d/.emacs-config.org@ ead573e

Last change on this file since ead573e was ead573e, checked in by Mikhail Kirillov <w96k@…>, on Sep 27, 2024 at 4:51:30 AM

Update emacs config

  • Property mode set to 100644
File size: 36.6 KB
RevLine 
[fde9de8]1#+TITLE: Emacs configuration
2#+AUTHOR: Kirillov <w96k.dev> Mikhail
[e915268]3#+OPTIONS: toc:nil
4#+PROPERTY: header-args:elisp :results silent
[3600aa2]5#+STARTUP: showeverything
[e915268]6
[fde9de8]7* About this Emacs configuration
8
9Configuration uses org-mode to tangle its contents to init.el and then
10be used by emacs. I use guix home for my emacs config on gnu guix
11system.
12
13If you see :tangle nil it means that snippet is not used anymore, but
14it is left because it might be valuable in a future for me.
15
16This configuration is available here:
[51683a8]17https://w96k.dev/emacs.html
18
[fde9de8]19The git source code is hosted on Sourcehut:
[51683a8]20https://git.sr.ht/~w96k/dotfiles/tree/master/item/emacs
[128f35c]21
[fde9de8]22The license of emacs config and dotfiles is CC0 which is Public Domain.
23
24** Packets
25Only needed when I need to install a package from Melpa and not GNU Guix
[43feba7]26#+begin_src elisp :tangle nil
[4b9efc5]27 (require 'package)
[8217b6f]28
29 (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
[fc6fa17]30 ("melpa" . "http://melpa.org/packages/")))
[8217b6f]31
32 (when (< emacs-major-version 27)
33 (package-initialize))
34
35 (require 'gnutls)
[8658e39]36#+end_src
37
[3ec75a9]38** EXWM
39
[6782e9b]40#+begin_src emacs-lisp :tangle nil
[3ec75a9]41 (require 'exwm)
42 (require 'exwm-config)
43 (exwm-config-example)
44#+end_src
45
46
[fde9de8]47** Init.el
[8658e39]48#+begin_src emacs-lisp :tangle init.el
[128f35c]49 ;; -*- lexical-binding: t -*-
[b968867]50
[8658e39]51 ;; Show/Hide errors
52 ;; (setq debug-on-error nil)
53 ;; (setq debug-on-quit nil)
[b968867]54
[8658e39]55 ;; Timer
56 (add-hook 'emacs-startup-hook
57 (lambda ()
58 (message
59 "Emacs ready in %s with %d garbage collections."
60 (format "%.2f seconds"
61 (float-time
62 (time-subtract after-init-time before-init-time)))
63 gcs-done)))
[b968867]64
[8658e39]65 ;; Dont ask when following symlinks
66 (setq vc-follow-symlinks t)
[b968867]67
[128f35c]68 ;; Load your custom settings
[8658e39]69 (setq custom-file "~/.emacs.d/custom-settings.el")
70 (load custom-file t)
71#+end_src
[68658dc]72
[f61bcc6]73* Meta
[fde9de8]74** About me
[128f35c]75#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]76 ;; Information about me
77 (setq user-full-name "Mikhail Kirillov"
[0d11196]78 user-mail-address "w96k@runbox.com")
[8658e39]79#+END_SRC
[68658dc]80
[fde9de8]81** Configuration
[23f3d53]82#+BEGIN_SRC emacs-lisp :tangle init.el
[254aa1d]83 (setq config-dotfiles-path "/home/w96k/projects/dotfiles/emacs/.emacs.d/"
[fc6fa17]84 config-path "~/.emacs.d/"
85 config-name ".emacs-config.org")
[23f3d53]86
87 (defun config-visit ()
88 (interactive)
89 (find-file (concat config-path config-name)))
90
91 (defun config-tangle ()
92 (interactive)
93 (org-babel-tangle-file (concat config-dotfiles-path config-name))
94 ;; Configuration stored in another directory,
95 ;; so I need to move files .emacs.d manually
[3ec75a9]96 ;; (rename-file (concat config-dotfiles-path "early-init.el") config-path t)
[74b40da]97 (rename-file (concat config-dotfiles-path "init.el") config-path t))
[23f3d53]98#+END_SRC
[426ea33]99
[fde9de8]100* Appereance
[68658dc]101
[fde9de8]102** Line numbers
[bb02749]103Изначально они отключены, но можно вызвать по клавише F7.
[128f35c]104#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]105 (define-key global-map
[5211578]106 (kbd "<f7>") 'display-line-numbers-mode)
[0d11196]107
[8658e39]108 (define-key global-map
109 (kbd "<f6>") 'whitespace-mode)
110#+END_SRC
[68658dc]111
[fde9de8]112* Editing
[5211578]113** Completion styles
114#+begin_src emacs-lisp :tangle init.el
115 (setq completion-styles '(basic partial-completion emacs22 substring))
116#+end_src
117
[fde9de8]118** Dired
[128f35c]119#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]120 ;; Show files in KiB
[e915268]121 (setq dired-listing-switches "-hlap"
122 dired-kill-when-opening-new-dired-buffer t)
123
[8e15ad4]124 (customize-set-variable 'global-auto-revert-non-file-buffers t)
125 (global-auto-revert-mode 1)
[8658e39]126#+END_SRC
[68658dc]127
[fde9de8]128** Linter
129I use Flymake and Flycheck
[52f2a29]130*** Flymake
[43feba7]131#+BEGIN_SRC emacs-lisp :tangle nil
[fde9de8]132 (add-hook 'prog-mode-hook 'flymake-mode)
[52f2a29]133
[6188d2e]134 (require 'psalm)
135
[8658e39]136 (define-prefix-command 'flymake-map)
[569fe43]137 (global-set-key (kbd "C-q") 'flymake-map)
[8658e39]138 (define-key flymake-map (kbd "n") 'flymake-goto-next-error)
139 (define-key flymake-map (kbd "p") 'flymake-goto-prev-error)
140 (define-key flymake-map (kbd "l") 'flymake-show-diagnostics-buffer)
141 (define-key flymake-map (kbd "e") 'flymake-show-diagnostic)
142#+END_SRC
[0979ded]143
[52f2a29]144*** Flycheck
[3ec75a9]145#+BEGIN_SRC emacs-lisp :tangle nil
[74bc208]146 ;; (require 'psalm)
[6188d2e]147
[b968867]148 (when (package-loaded? "flycheck")
[6188d2e]149
150 (defun flycheck-phanclient-start-daemon ()
151 "Start the phan daemon"
152 (interactive)
153 (let* ((default-directory (php-project-get-root-dir))
154 (phan-executable (or flycheck-phanclient--phan-executable
155 (if (file-exists-p "vendor/bin/phan")
156 (concat default-directory "vendor/bin/phan")
157 (executable-find "phan"))))
158 (cmd (list phan-executable "--daemonize-tcp-port" "4846" "--quick")))
159 (apply #'start-process "PhanDaemon" "*phan daemon*" cmd)))
160
161 (flycheck-define-checker php-phanclient
[74bc208]162 "Phan"
[6188d2e]163 :command ("phan_client" "-l" source-original "-f" source)
164 :error-patterns
165 ((warning line-start (or "Parse" "Fatal" "syntax" "Phan") " error" (any ":" ",") " " (message) " in " (file-name) " on line " line line-end))
166 :modes (php-mode php+-mode))
167
168 (add-to-list 'flycheck-checkers 'php-phanclient)
169
[74bc208]170 (flycheck-add-next-checker 'php '(warning . php-phanclient))
[6188d2e]171
172 (add-hook 'prog-mode-hook 'flycheck-mode))
[52f2a29]173#+END_SRC
174
[fde9de8]175** Imenu List
[3cb0c7b]176#+begin_src emacs-lisp :tangle init.el
[5211578]177 (use-package imenu-list
178 :bind
179 ("C-x C-d" . imenu-list-smart-toggle)
180 :config
181 (setq imenu-list-focus-after-activation nil
182 imenu-list-auto-resize nil
183 imenu-list-mode-line-format '()
184 imenu-list-size 0.4))
[58d51ef]185#+end_src
186
[fde9de8]187** Version Control System
[bb02749]188Модуль VC + Magit.
[70a99de]189
[a9e4461]190| Operation | VC | Magit |
191|----------------+-----------------------------------------+----------------------|
192| Project status | project-vc-dir (C-x p v) | magit-status (C-x g) |
193| Pull | vc-update (F, in my case) | magit-pull (F p) |
194| New branch | vc-retrieve-tag (C-u B s) | magit-branch (b c) |
195| Commit | vc-next-action (C-x v v) | magit-commit (c c) |
196| Rebase | shell-command (M-!) + git rebase master | magit-rebase (r p) |
197| Push | vc-push (P or C-u P) | magit-push (P p) |
198| Stash | mu-vc-git-stash (z) | magit-stash (z) |
199| Log | vc-print-root-log (L) | magit-log (l l) |
200https://www.manueluberti.eu//emacs/2021/11/27/vc/
201
[128f35c]202#+BEGIN_SRC emacs-lisp :tangle init.el
[4d3a58c]203 (setq vc-command-messages t)
204
205 (global-set-key "\C-xvB" 'git-branch-next-action)
206
207 ;; Use magit only when built-in VC fails
[86d2deb]208
[fde9de8]209 (use-package magit
210 :defer t
211 :bind (("C-x g" . magit-status)))
212
213 (use-package git-timemachine :defer t)
[8658e39]214#+END_SRC
[68658dc]215
[fde9de8]216** Jumps
[128f35c]217#+BEGIN_SRC emacs-lisp :tangle init.el
[fde9de8]218 ;; Jumps by highlighting symbols on screen
219 (use-package avy
220 :defer t
221 :bind (("M-s M-s" . avy-goto-char)
[5211578]222 ("M-s s" . avy-goto-char)
223 ("M-s g" . avy-goto-line)
224 ("M-s l" . avy-goto-char-in-line)
225 ("M-s M-l" . avy-goto-char-in-line)
[fde9de8]226
[5211578]227 ("M-g g" . avy-goto-line)
228 ("M-s M-g" . avy-goto-line)))
[fde9de8]229
230 (use-package link-hint
231 :defer t
232 :bind (("M-s j" . link-hint-open-link)))
233
234 ;; Jumps to last change
235 (use-package goto-chg
236 :defer t
237 :bind (("C-z" . goto-last-change)
[5211578]238 ("M-z" . goto-last-change-reverse)))
[fde9de8]239
240 ;; Jumps using grep and similar tools
241 (use-package dumb-jump
242 :defer t
[5211578]243 :bind (("M-g o" . dumb-jump-go-other-window)
244 ("M-g j" . dumb-jump-go)
245 ("M-g b" . dumb-jump-back)
246 ("M-g q" . dumb-jump-quick-look)
247 ("M-g x" . dumb-jump-go-prefer-external)
248 ("M-g z" . dumb-jump-go-prefer-external-other-window)))
[d100c77]249
[8658e39]250#+END_SRC
[68658dc]251
[0979ded]252** Проекты
[8658e39]253Использую встроенный project.el
254I use built-in project.el
[d1eb4b0]255** Ограничение ширины строки
[128f35c]256#+BEGIN_SRC emacs-lisp :tangle init.el
[fde9de8]257 (add-hook 'prog-mode-hook 'display-fill-column-indicator-mode)
[8c09fc7]258
[fde9de8]259 ;;; Set column width to 79 according to pep8 for python
260 (add-hook 'python-mode-hook
261 (lambda () (set-fill-column 79)))
[8658e39]262#+END_SRC
[68658dc]263
[9691479]264** Ввод парных скобок и кавычек (electric)
[128f35c]265#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]266 ;;; Input of pair delimiters
267 (electric-pair-mode)
268 (add-hook 'prog-mode-hook 'electric-pair-mode)
[fde9de8]269 (add-hook 'prog-mode-hook 'electric-indent-mode)
[8658e39]270#+END_SRC
[68658dc]271
[68217df]272** Kill-ring
[fde9de8]273#+BEGIN_SRC emacs-lisp :tangle init.el
274 (use-package browse-kill-ring
275 :defer t
276 :bind ("C-M-y" . browse-kill-ring))
[8658e39]277#+END_SRC
[68658dc]278
[3aa3dbc]279** Tags
[8658e39]280Для прыжков и поиска функций/классов и т.д.
[5211578]281#+BEGIN_SRC emacs-lisp :tangle init.el
282 (setq path-to-ctags "~/.guix-home/profile/bin/ctags")
283
[8658e39]284 (defun tags-create (dir-name)
285 "Create tags file."
286 (interactive "DDirectory: ")
287 (shell-command
288 (format "%s -f TAGS -e -R %s" path-to-ctags
[5211578]289 (directory-file-name dir-name))))
290
[8658e39]291 (defun tags-create-python (dir-name)
292 "Create tags with python interpreter"
293 (interactive "DDirectory: ")
294 (shell-command
295 (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
[5211578]296 (directory-file-name dir-name))))
[8658e39]297#+END_SRC
[68658dc]298
[5211578]299#+begin_src emacs-lisp :tangle init.el
300 (use-package ggtags
301 :defer t
302 :hook
303 (c-mode . ggtags-mode))
304#+end_src
305
306
[d000862]307** Дебаггер
[3ec75a9]308#+begin_src emacs-lisp :tangle nil
[d000862]309 (when (package-loaded? "realgud")
310 (load "~/.emacs.d/site-lisp/realgud-xdebug/realgud-xdebug.el"))
311#+end_src
312
[3ec75a9]313#+begin_src emacs-lisp :tangle nil
[864b0b5]314 (when (package-loaded? "geben")
315 (setq geben-dbgp-default-port 9003))
316#+end_src
317
[07d6016]318*** Автодополнение кода и документация
319По большей части я использую дефолтный Completion Buffer и Corfu
[3ec75a9]320#+begin_src elisp :tangle nil
[09e91e8]321 (when (package-loaded? "corfu")
322 (progn
323 (setq corfu-preview-current 'nil
324 corfu-popupinfo-delay t)
325 (corfu-mode 1)
326 (corfu-popupinfo-mode 1)
327 (defun show-default-completion-buffer ()
328 (interactive)
329 (corfu-quit)
[279dc2a]330 (corfu-mode -1)
[09e91e8]331 (completion-at-point)
332 (corfu-mode 1)
333 (corfu-popupinfo-mode 1))
334 (define-key corfu-map (kbd "M-TAB") 'show-default-completion-buffer)
335 (define-key corfu-map (kbd "TAB") 'show-default-completion-buffer)
336 (define-key corfu-map (kbd "C-M-i") 'show-default-completion-buffer)
337 (corfu-mode -1)
338 (add-hook 'prog-mode-hook 'corfu-mode)
[d881dae]339
[09e91e8]340 (defun corfu-send-shell (&rest _)
341 "Send completion candidate when inside comint/eshell."
342 (cond
343 ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
344 (eshell-send-input))
345 ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
346 (comint-send-input))))
[d881dae]347
[09e91e8]348 (advice-add #'corfu-insert :after #'corfu-send-shell)
349
350 (add-hook 'eshell-mode-hook 'corfu-mode)))
[d881dae]351
[951b531]352#+end_src
[bf3cbfb]353*** Агрессивный дефолтный комплит
[e915268]354#+BEGIN_SRC emacs-lisp :tangle nil
[ff56340]355 (setq aggressive-completion-delay 0.5)
[bf3cbfb]356 (aggressive-completion-mode t)
357#+END_SRC
[32f04fb]358** Полнотекстовый поиск
[8658e39]359Для выхода из поиска -- C-c C-q
[ab9549b]360#+begin_src emacs-lisp :tangle nil
[8658e39]361 (load "deft-autoloads")
362
363 (define-key global-map
364 (kbd "C-c n s") 'deft)
365
366 (setq deft-recursive t
367 deft-use-filter-string-for-filename t
368 deft-default-extension "org md"
[5acd0cd]369 deft-directory "~/projects/at-w96k/content/digarden")
[8658e39]370#+end_src
[68658dc]371
[62b2200]372** Визуализирование откатов
[8658e39]373При помощи пакета undo-tree
[4f6c5c4]374#+begin_src emacs-lisp :tangle init.el
[fde9de8]375 (use-package undo-tree
376 :defer t
377 :hook
378 (prog-mode . undo-tree-mode)
379 (org-mode . undo-tree-mode))
[8658e39]380#+end_src
[62b2200]381
[f67dddc]382** Сниппеты
[1e08614]383#+begin_src emacs-lisp :tangle nil
[8c09fc7]384 (when (package-loaded? "yasnippet")
385 (progn
386 (add-hook 'prog-mode-hook #'yas-minor-mode)))
[8658e39]387#+end_src
[68658dc]388
[09d671c]389** Клиент LSP
[6782e9b]390#+begin_src emacs-lisp :tangle init.el
[5211578]391 (with-eval-after-load 'eglot
392 (add-to-list 'eglot-server-programs
393 '((php-mode phps-mode php-ts-mode) . ("/home/w96k/projects/phpactor/bin/phpactor" "language-server" "-vvv"))))
394
[6782e9b]395 ;; (with-eval-after-load 'eglot
396 ;; (add-to-list 'eglot-server-programs '((php-mode phps-mode) . ("~/projects/phpactor/bin/phpactor" "language-server" "-vvv")))
397 ;; (add-to-list 'eglot-server-programs '((php-mode phps-mode) . ("intelephense" "--stdio")))
[09e91e8]398
[6782e9b]399 ;; ;; No event buffers, disable providers cause a lot of hover traffic. Shutdown unused servers.
400 ;; (setq eglot-events-buffer-size 0
401 ;; eglot-ignored-server-capabilities '(:hoverProvider
402 ;; :documentHighlightProvider)
403 ;; eglot-autoshutdown t))
[09e91e8]404
405 ;; Show all of the available eldoc information when we want it. This way Flymake errors
406 ;; don't just get clobbered by docstrings.
407 (add-hook 'eglot-managed-mode-hook
[5211578]408 (lambda ()
409 "Make sure Eldoc will show us all of the feedback at point."
410 (setq-local eldoc-documentation-strategy
411 #'eldoc-documentation-compose)))
[8658e39]412#+end_src
[09e91e8]413
[f63641c]414** Линтеры
[3ec75a9]415#+begin_src emacs-lisp :tangle nil
[864b0b5]416 (defun my-php-mode-setup ()
417 "My PHP-mode hook."
418 (require 'flycheck-phpstan)
419 (flycheck-mode t))
420
421 (add-hook 'php-mode-hook 'my-php-mode-setup)
422#+end_src
423
[0d11196]424#+BEGIN_SRC emacs-lisp :tangle nil
[09e91e8]425 ;; (add-hook 'php-mode-hook 'flymake-php-load)
426 ;; (add-hook 'php-mode-hook 'flymake-phpstan-turn-on)
427
428 ;; (require 'flycheck-phpstan)
429
[e915268]430
431 ;;(add-to-list 'auto-mode-alist '("\\.\\(php\\|phtml\\)\\'" . phps-mode))
432
[8c09fc7]433 ;; (phps-mode-flycheck-setup)
[e915268]434
[8c09fc7]435 ;; (setq phps-mode-async-process t)
436 ;; (setq phps-mode-async-process-using-async-el t)
[f63641c]437#+END_SRC
[e915268]438
[d43c749]439** Выделение
440#+BEGIN_SRC emacs-lisp :tangle init.el
[fde9de8]441 (use-package expand-region
442 :defer t
443 :bind (("C-=" . er/expand-region)))
[d43c749]444#+END_SRC
445
[8b20cb2]446** Сессия
[fde9de8]447#+BEGIN_SRC emacs-lisp :tangle init.el
[0d11196]448 (desktop-save-mode 1)
[8b20cb2]449#+END_SRC
[e2cb5ad]450** Скроллинг
451#+BEGIN_SRC emacs-lisp :tangle init.el
452 (setq scroll-margin 0)
453#+END_SRC
[41796cb]454** Поиск
[34558f1]455*** Isearch
456#+begin_src emacs-lisp :tangle init.el
457 (with-eval-after-load 'isearch
458 (define-key isearch-mode-map "\C-h" 'isearch-delete-char)
459 (define-key isearch-mode-map "\C-ch" 'isearch-help-for-help))
460#+end_src
461
[ca768b6]462*** Подсчёт кандидатов
[fde9de8]463#+BEGIN_SRC emacs-lisp :tangle init.el
464 (use-package anzu
465 :config
466 (global-anzu-mode t))
[ca768b6]467#+END_SRC
468*** Swiper (не используется)
[054e643]469#+BEGIN_SRC emacs-lisp :result nil :tangle nil
[41796cb]470 (load "swiper-autoloads")
471 (global-set-key (kbd "C-s") 'swiper)
472
473 (setq swiper-include-line-number-in-search t
474 swiper-use-visual-line t
475 swiper-stay-on-quit t)
476#+END_SRC
[fde9de8]477** Which function
478#+begin_src emacs-lisp :tangle init.el
479 (which-function-mode t)
480#+end_src
481
[c39a878]482** Подсказка биндов
483Пакет Which-key
[1f45158]484#+begin_src elisp :tangle nil
[c39a878]485 (load "which-key-autoloads")
486 (which-key-setup-side-window-right)
487 (which-key-mode)
488
[ece4aba]489 (setq which-key-side-window-max-width 0.5
[c39a878]490 which-key-show-remaining-keys t
491 which-key-max-display-columns 50
[fd65e09]492 which-key-max-description-length 35
[c39a878]493 which-key-sort-order 'which-key-local-then-key-order
[fd65e09]494 which-key-idle-delay 0.25)
[c39a878]495#+end_src
496
[8f5263a]497** Права суперпользователя
498Sudo-edit
[fde9de8]499#+begin_src emacs-lisp :tangle init.el
500 (use-package sudo-edit
501 :defer t)
[b968867]502#+end_src
503
[a649060]504** Промежуточный код
505Показывает собранное состояние будь то собранный куски на ассемблере
506или байт-код при помощи пакета RMSbolt.
[fde9de8]507#+begin_src emacs-lisp :tangle init.el
508 (use-package rmsbolt
[fc6fa17]509 :defer t)
[a649060]510#+end_src
[8f5263a]511
[864b0b5]512** Быстрый запуск программы
[7f6d0e1]513#+begin_src emacs-lisp :tangle nil
514 ;; (when (package-loaded? "quickrun")
515 ;; (define-key global-map (kbd "C-c C-c") 'quickrun))
[864b0b5]516#+end_src
517
518
[f61bcc6]519* Языки программирования
[9989e84]520** Common Lisp
521*** REPL
[3ec75a9]522#+BEGIN_SRC emacs-lisp :tangle nil
[cfa5680]523 (load "sly-autoloads")
524
525 (setq sly-lisp-implementations
526 '((clisp ("clisp"))
527 (cmucl ("cmucl" "-quiet"))
528 (sbcl ("/opt/sbcl/bin/sbcl") :coding-system utf-8-unix)))
[8658e39]529#+END_SRC
[68658dc]530
[559d5be]531** Ruby
[0d11196]532#+BEGIN_SRC emacs-lisp :tangle nil
[8c09fc7]533 (when (package-loaded? "inf-ruby")
534 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode))
535
536 (when (package-loaded? "inf-ruby")
537 (add-hook 'ruby-mode-hook 'robe-mode))
[8658e39]538#+END_SRC
[68658dc]539
[b38b2f3]540** Scheme
[128f35c]541#+BEGIN_SRC emacs-lisp :tangle init.el
[4deaed7]542 (setq geiser-active-implementations '("guile"))
[8658e39]543#+END_SRC
[68658dc]544
[559d5be]545** Python
[c3f858e]546*** Автодополнение и линт
[3ec75a9]547#+BEGIN_SRC emacs-lisp :tangle nil
[8c09fc7]548 (when (package-loaded? "anaconda-mode")
549 (progn
550 (add-hook 'python-mode-hook 'anaconda-mode)
[4f6c5c4]551 (add-hook 'python-mode-hook 'anaconda-eldoc-mode)))
[c3f858e]552
[bf3e737]553 ;; (when (load "flymake" t)
554 ;; (defun flymake-pylint-init ()
555 ;; (let* ((temp-file (flymake-init-create-temp-buffer-copy
556 ;; 'flymake-create-temp-inplace))
557 ;; (local-file (file-relative-name
558 ;; temp-file
559 ;; (file-name-directory buffer-file-name))))
560 ;; (list "epylint" (list local-file))))
561
562 ;; (add-to-list 'flymake-allowed-file-name-masks
563 ;; '("\\.py\\'" flymake-pylint-init)))
564
565 ;; (add-hook 'python-mode-hook 'flymake-mode)
[8658e39]566#+END_SRC
[c3f858e]567*** Прыжки в функции стандартной библиотеки на си
[37c47af]568** SML
[ab9549b]569#+BEGIN_SRC emacs-lisp :tangle nil
[8658e39]570 (add-hook 'sml-mode-hook 'sml-mode)
571#+END_SRC
[ead573e]572** Java
573*** Eglot-java
574For better integration with eclipse.jdt.ls
575#+BEGIN_SRC emacs-lisp :tangle init.el
576 (unless (package-installed-p 'eglot-java)
577 (package-vc-install "https://github.com/yveszoundi/eglot-java" nil nil 'eglot-java))
578#+end_src
[68658dc]579
[4ece9d5]580** PHP
[e741bd8]581*** PHP-Mode
[56a7a86]582Необходимо скачать и распаковать мануал PHP (в формате html) в
583директорию ~~/.emacs.d/php-manual/~.
[3ec75a9]584#+begin_src emacs-lisp :tangle nil
[8c09fc7]585 ;; (add-to-list 'load-path "~/.emacs.d/site-lisp/realgud-xdebug/")
586 ;; (require 'realgud-xdebug)
[e915268]587
[864b0b5]588 ;; (defun init-php-mode ()
589 ;; (eglot-ensure))
[56a7a86]590
[5211578]591 (use-package php-mode
592 :bind ("C-c h" . 'php-quickhelp-at-point)
593 :config
[be6d215]594
[5211578]595 (setq php-manual-path
596 "~/projects/php-manual/"
597 php-quickhelp-dir "~/projects/php-manual/"
598 php-quickhelp--dest "~/projects/php-manual/php_manual_en.json"))
[b968867]599
600
[5211578]601 ;; (add-hook 'php-mode-hook
602 ;; '(lambda ()
603 ;; ;; (auto-complete-mode t)
[43749e5]604
[5211578]605 ;; ;; (require 'ac-php)
606 ;; (require 'php-quickhelp)
607 ;; (require 'company)
608 ;; (company-mode t)
609 ;; (require 'company-php)
610 ;; (require 'company-quickhelp)
[951b531]611
[5211578]612 ;; (require 'yasnippet)
613 ;; (require 'yasnippet-snippets)
[951b531]614
[5211578]615 ;; (set (make-local-variable 'company-backends)
616 ;; '((company-ac-php-backend company-dabbrev-code)
617 ;; php-quickhelp-company-php
618 ;; company-capf company-files))
[951b531]619
[5211578]620 ;; (company-quickhelp-mode t)
[951b531]621
[5211578]622 ;; (define-key php-mode-map (kbd "C-M-i") 'company-complete)
623 ;; (define-key company-mode-map (kbd "M-TAB") 'company-complete)
[951b531]624
[5211578]625 ;; ;; (setq ac-sources '(ac-source-php php-quickhelp-company-php))
626 ;; ;; (setq eldoc-documentation-function
627 ;; ;; 'php-quickhelp-eldoc-func)
[b7d25b5]628
[5211578]629 ;; (yas-minor-mode t)
[b7d25b5]630
[5211578]631 ;; ;; (define-key php-mode-map (kbd "C-M-i") 'auto-complete)
632 ;; ;; (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
[b7d25b5]633
[5211578]634 ;; (define-key php-mode-map (kbd "C-c H")
635 ;; 'php-local-manual-search)
[be6d215]636
[5211578]637 ;; (define-key php-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
638 ;; (define-key company-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
[b7d25b5]639
[5211578]640 ;; ;; (define-key php-mode-map (kbd "C-c t") 'ac-php-show-tip)
[b7d25b5]641
[5211578]642 ;; ;; Jump to definition (optional)
643 ;; (define-key php-mode-map
644 ;; (kbd "M-.") 'ac-php-find-symbol-at-point)
[43749e5]645
[5211578]646 ;; ;; Return back (optional)
647 ;; (define-key php-mode-map
648 ;; (kbd "M-,") 'ac-php-location-stack-back)))
649 ))
[4ece9d5]650#+end_src
651
[e741bd8]652*** Composer
[6782e9b]653#+begin_src emacs-lisp :tangle init.el
654 (setq composer-executable-bin "~/.bin/composer")
655#+end_src
656
[e741bd8]657*** Flymake PHP
658*** REPL
659*** LSP сервер
660PHPactor
[43749e5]661#+begin_src emacs-lisp :tangle nil
[6782e9b]662 (setq phpactor-executable "~/.bin/phpactor")
663 (custom-set-variables '(lsp-phpactor-path "~/.bin/phpactor"))
664
665 (use-package phpactor :ensure t)
666 (use-package company-phpactor :ensure t)
667
668
669
670 ;; (with-eval-after-load 'php-mode
671 ;; (define-key php-mode-map (kbd "M-.") #'phpactor-goto-definition)
672 ;; (define-key php-mode-map (kbd "M-?") #'phpactor-find-references))
[e741bd8]673#+end_src
674
[af9ef4a]675*** Transient меню
[c39a878]676#+begin_src emacs-lisp :tangle nil
[d100c77]677 (require 'transient)
[f63641c]678 (define-transient-command php-menu ()
[d100c77]679 "Php"
680 [["Class"
681 ("cc" "Copy" phpactor-copy-class)
682 ("cn" "New" phpactor-create-new-class)
683 ("cr" "Move" phpactor-move-class)
684 ("ci" "Inflect" phpactor-inflect-class)
685 ("n" "Namespace" phpactor-fix-namespace)]
686 ["Properties"
687 ("a" "Accessor" phpactor-generate-accessors)
688 ("pc" "Constructor" phpactor-complete-constructor)
689 ("pm" "Add missing props" phpactor-complete-properties)
690 ("r" "Rename var locally" phpactor-rename-variable-local)
691 ("R" "Rename var in file" phpactor-rename-variable-file)]
692 ["Extract"
693 ("ec" "constant" phpactor-extract-constant)
694 ("ee" "expression" phpactor-extract-expression)
695 ("em" "method" phpactor-extract-method)]
696 ["Methods"
697 ("i" "Implement Contracts" phpactor-implement-contracts)
698 ("m" "Generate method" phpactor-generate-method)]
699 ["Navigate"
700 ("x" "List refs" phpactor-list-references)
701 ("X" "Replace refs" phpactor-replace-references)
702 ("." "Goto def" phpactor-goto-definition)]
703 ["Phpactor"
704 ("s" "Status" phpactor-status)
705 ("u" "Install" phpactor-install-or-update)]])
[af9ef4a]706#+end_src
[d06a87f]707* Языки декларирования
708** SQL
[7f6d0e1]709 to install lsp-server called sqls
[93c87eb]710https://emacs-lsp.github.io/lsp-mode/page/lsp-sqls/
[0d11196]711#+BEGIN_SRC emacs-lisp :tangle nil
[8658e39]712 ;; Empty for now (was using emacsql)
[b08cfaa]713 (setq lsp-sqls-server "~/go/bin/sqls")
[313ec50]714
[ee24a4b]715 ;; (setq lsp-sqls-workspace-config-path nil)
[313ec50]716
717 (setq lsp-sqls-connections
[ee24a4b]718 '(((driver . "mysql") (dataSourceName . "dbuser:mangoworms@tcp(localhost:3306)/profile24"))))
[8658e39]719#+END_SRC
[f63641c]720
[a198d42]721The main way to interact with SQL is using org-mode
[0d11196]722#+begin_src emacs-lisp :tangle nil
[a198d42]723 (when (package-loaded? "org-sql")
724 (setq org-sql-files "~/projects/profile24/org"))
[313ec50]725
[acdb8ab]726 (add-hook 'sql-interactive-mode-hook
[8faea87]727 (lambda ()
[e6b57ae]728 (sql-connect "profile24")
[8faea87]729 (toggle-truncate-lines t)))
[acdb8ab]730
[313ec50]731 (setq sql-connection-alist
[ee24a4b]732 '((profile24
733 (sql-product 'mysql)
734 (sql-server "localhost")
735 (sql-user "dbuser")
[0d11196]736 (sql-password "123456")
737 (sql-database "testdb")
[ee24a4b]738 (sql-port 3306))))
[a198d42]739#+end_src
740
[5211578]741*** Sql Viewer
742#+begin_src emacs-lisp :tangle init.el
743 (unless (package-installed-p 'pg)
744 (package-vc-install "https://github.com/emarsden/pg-el" nil nil 'pg))
745 (unless (package-installed-p 'pgmacs)
746 (package-vc-install "https://github.com/emarsden/pgmacs"))
747
748 (use-package pgmacs)
749#+end_src
750
[a198d42]751
[f61bcc6]752** Веб шаблоны
753*** Web-mode
[128f35c]754#+BEGIN_SRC emacs-lisp :tangle init.el
[fde9de8]755 (use-package web-mode
756 :defer t
757 :config
758 (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
759 (add-to-list 'auto-mode-alist '("\\.twig.html\\'" . web-mode))
760 (setq web-mode-markup-indent-offset 2)
761 (setq web-mode-enable-auto-pairing t)
762 (setq web-mode-enable-css-colorization t)
763 (setq web-mode-enable-block-face t)
764 (setq web-mode-enable-current-element-highlight t))
[8658e39]765#+END_SRC
[68658dc]766
[e53abd3]767** Org
768*** Org-mode
[128f35c]769#+BEGIN_SRC emacs-lisp :tangle init.el
[fde9de8]770 (use-package org
771 :defer t
772 :config
773 (org-babel-do-load-languages
774 'org-babel-load-languages
775 '((R . t)
776 (ditaa . t)
777 (dot . t)
778 ;; (php . t)
779 (emacs-lisp . t)
780 (gnuplot . t)
781 (haskell . nil)
782 (latex . t)
783 ;;(ledger . t)
784 (ocaml . nil)
785 (octave . t)
786 (python . t)
787 (ruby . t)
788 (screen . nil)
789 (shell . t)
790 (sql . t)
791 (js . t)))
792 (setq org-default-notes-file "~/Documents/todo.org"
[877bb6c]793 system-time-locale "C"
[c39a878]794 org-use-speed-commands t
795 org-adapt-indentation nil
796 org-return-follows-link t
[7f6d0e1]797 org-agenda-include-diary t
[ea0b945]798 org-display-remote-inline-images 'download
[7f6d0e1]799 org-agenda-start-with-log-mode t
[edf34a3]800 org-image-actual-width (list 400)
[c39a878]801 org-hide-emphasis-markers t
802 org-outline-path-complete-in-steps nil
803 org-src-tab-acts-natively t
[09e91e8]804 org-id-track-globally t
[c39a878]805 org-confirm-babel-evaluate nil)
[fde9de8]806 (setq org-todo-keywords
[c39a878]807 (quote ((sequence "TODO(t)"
[254aa1d]808 "MIGRATE(m)"
[c39a878]809 "IN PROGRESS(p)"
810 "DONE(d)")
[7f6d0e1]811 (sequence "BLOCKED(w@/!)"
[c39a878]812 "HOLD(h@/!)" "|"
813 "CANCELLED(c@/!)"
814 "PHONE"
[7f6d0e1]815 "MEETING"
816 "NEED CLARIFICATION(t)"
817 ))))
[fde9de8]818 (setq org-todo-keyword-faces
[c39a878]819 (quote (("TODO" :foreground "red" :weight bold)
820 ("NEXT" :foreground "blue" :weight bold)
821 ("DONE" :foreground "forest green" :weight bold)
822 ("WAITING" :foreground "orange" :weight bold)
823 ("HOLD" :foreground "magenta" :weight bold)
824 ("CANCELLED" :foreground "forest green" :weight bold)
825 ("MEETING" :foreground "forest cyan" :weight bold)
826 ("PHONE" :foreground "blue" :weight bold))))
[fde9de8]827 :bind
828 ("C-c l" . org-store-link)
829 ("C-c a" . org-agenda)
830 ("C-c c" . org-capture)
831 )
832
833 (defun org-babel-edit-prep:sql (babel-info)
834 (setq-local buffer-file-name (->> babel-info caddr (alist-get :tangle)))
835 (setq-local lsp-buffer-uri (->> babel-info caddr (alist-get :tangle) lsp--path-to-uri))
836 (setq-local lsp-headerline-breadcrumb-enable nil)
837 (lsp))
838
839 ;; (global-set-key (kbd "M-f") 'org-metaright)
840 ;; (global-set-key (kbd "M-b") 'org-metaleft)
841 ;; (global-set-key (kbd "M-p") 'org-metaup)
842 ;; (global-set-key (kbd "M-n") 'org-metadown)
[8658e39]843#+END_SRC
[68658dc]844
[fde9de8]845
846*** Org-ref
[d3c0bac]847#+begin_src emacs-lisp :tangle nil
[8658e39]848 (load "org-ref-autoloads")
849
850 (setq reftex-default-bibliography '("~/Documents/bibliography/references.bib"))
851
852 ;; see org-ref for use of these variables
853 (setq org-ref-bibliography-notes "~/Documents/bibliography/notes.org"
854 org-ref-default-bibliography '("~/Documents/Bibliography/references.bib")
855 org-ref-pdf-directory "~/Documents/bibliography/bibtex-pdfs/")
856#+end_src
[e53abd3]857
[d61c4ab]858*** Org-roam
[d652ebb]859#+begin_src emacs-lisp :tangle init.el
[fde9de8]860 (use-package org-roam
861 :defer t
862 :bind
863 ("C-c n l" . org-roam-node-insert)
864 ("C-c n b" . org-roam-buffer-toggle)
865 ("C-c n f" . org-roam-node-find)
866 ("C-c n t t" . org-roam-tag-add)
867 ("C-c n t r" . org-roam-tag-remove)
868 ("C-c n i" . org-roam-jump-to-index)
869 ("C-c n g" . org-roam-graph)
870 ("C-c n d" . org-roam-db-build-cache)
871 ("C-c n r" . org-roam-node-random)
872 ("C-c n j" . org-roam-dailies-find-date)
873 :config
874 (setq org-roam-directory (file-truename "~/Zettelkasten")
875 org-roam-v2-ack t
876 org-roam-completion-everywhere t
877 org-roam-index-file (concat org-roam-directory "/20210409054712-жизнь.org")
878 org-roam-dailies-directory (concat org-roam-directory "journals/"))
879
880 (org-roam-db-autosync-mode t))
881
882 (defun org-roam-jump-to-index ()
883 "Stub of recreating the function from V1"
884 (interactive)
885 (let
886 ((org-roam-index org-roam-index-file))
887 (find-file org-roam-index)))
[395b6b5]888
[fde9de8]889 (use-package org
890 :defer t
891 :config
892 (customize-set-variable 'org-link-descriptive t)
[d61c4ab]893
[fde9de8]894 (add-to-list 'org-agenda-files
895 "~/Documents/todo.org")
[3a19ca7]896
[fde9de8]897 (setq org-directory "~/Documents"
898 org-default-notes-file (concat org-directory "/todo.org")))
[cc591cc]899#+end_src
900
[2bb7684]901** YAML
[fde9de8]902#+begin_src emacs-lisp :tangle init.el
903 (use-package yaml-mode
904 :defer t)
[2bb7684]905#+end_src
906
[f61bcc6]907* Коммуникации
[7f6d0e1]908** Gnus
909#+begin_src emacs-lisp :tangle init.el
910
911#+end_src
912
[f61892c]913** Telega
[3ec75a9]914#+BEGIN_SRC emacs-lisp :tangle init.el
[fde9de8]915 (use-package telega
916 :bind (("C-c t" . telega-prefix-map)))
[8658e39]917#+END_SRC
[68658dc]918
[1c49a32]919** Mastodon
[fde9de8]920#+begin_src emacs-lisp :tangle init.el
921 (use-package mastodon
922 :defer t
923 :config
[b968867]924 (setq mastodon-active-user "w96k"
925 mastodon-instance-url "https://fosstodon.org/"))
[1c49a32]926#+end_src
927
[f61bcc6]928* Разное
[fde9de8]929** *Highlight
930#+BEGIN_SRC emacs-lisp :tangle init.el
931 (use-package highlight
932 :defer t)
933#+end_src
[d184fc7]934** Минорные твики дефолтного имакса
[8e15ad4]935*** Короткие ответы на вопросы
[0d11196]936#+begin_src emacs-lisp :tangle init.el
[8e15ad4]937 (if (boundp 'use-short-answers)
938 (setq use-short-answers t)
939 (advice-add 'yes-or-no-p :override #'y-or-n-p))
940#+end_src
941
942*** Не сохранять дубликаты в killring
943
[d80bfc6]944*** Подсвечивать текущую строку
[0d11196]945#+begin_src emacs-lisp :tangle nil
[fde9de8]946 (global-hl-line-mode t)
[395b6b5]947#+end_src
948
[d184fc7]949*** Автодополнение в echo при M-x и других командах
[3ec75a9]950#+begin_src emacs-lisp :tangle init.el
[fde9de8]951 (icomplete-mode t)
[d184fc7]952#+end_src
953*** Проверять орфографию
954#+begin_src emacs-lisp :tangle init.el
[fde9de8]955 (flyspell-mode t)
[ec71c8e]956#+end_src
957
[f61bcc6]958*** Не спрашивать о несуществующих буферах
[128f35c]959#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]960 (setq-default confirm-nonexistent-file-or-buffer t)
961#+END_SRC
[68658dc]962
[373ed2d]963*** Переключение буферов
[0d11196]964#+BEGIN_SRC emacs-lisp :tangle init.el
[373ed2d]965 (global-set-key (kbd "M-o") 'mode-line-other-buffer)
966#+END_SRC
[ef88711]967
[01e632c]968*** Минорные твики
969#+begin_src emacs-lisp :tangle init.el
[0d11196]970 ;; (setq redisplay-dont-pause t)
[3aaa66b]971
972 (setq select-enable-clipboard t
973 select-enable-primary t)
974
[2107e51]975 (setq completions-detailed nil)
[3aaa66b]976
977 (setq kill-buffer-delete-auto-save-files t)
978 (setq next-error-message-highlight t)
979
980 (setq mode-line-compact 'long)
981
[2107e51]982 (setq completions-group t)
983
[01e632c]984 ;;(set-frame-parameter nil 'internal-border-width 0)
985
986 ;; (set-window-buffer nil (current-buffer))
987
[0d11196]988 (setq default-directory "~/"
[01e632c]989 custom-safe-themes t
990 delete-old-versions t
991 enable-local-variables t)
992#+end_src
993
[e93b7a8]994*** Shell
[128f35c]995#+begin_src emacs-lisp :tangle init.el
[8658e39]996 (setq ansi-color-for-comint-mode t)
997 (setq shell-command-prompt-show-cwd t)
998#+end_src
[68658dc]999
[f61bcc6]1000*** Переменная PATH в eshell
[0d11196]1001#+BEGIN_SRC emacs-lisp :tangle nil
[6eb7430]1002 (setq exec-path-from-shell-variables
1003 '("PATH" "MANPATH"))
1004
[f63641c]1005 (when (and (memq window-system '(mac ns x))
1006 (not (eq system-type 'berkeley-unix)))
1007 (exec-path-from-shell-initialize))
[8658e39]1008#+END_SRC
[68658dc]1009
[f61bcc6]1010*** Отображение номера колонки
[128f35c]1011#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]1012 (column-number-mode)
1013#+END_SRC
[68658dc]1014
[cc8263e]1015*** nobreak символы
[128f35c]1016#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]1017 (setq nobreak-char-display nil)
1018#+END_SRC
[68658dc]1019
[2a1b24a]1020*** Меню
[3176064]1021*** Сохранять временные файлы не в той же директории
[128f35c]1022#+BEGIN_SRC emacs-lisp :tangle init.el
[3aaa66b]1023 (defvar backup-dir "~/.emacs.d/backups/")
1024
[8658e39]1025 (setq
1026 backup-by-copying t
1027 backup-directory-alist
[0d11196]1028 '(("~/.emacs.d/backups/"))
[e915268]1029 version-control nil)
[8658e39]1030#+END_SRC
[68658dc]1031
[1e93232]1032*** Календарь
[8658e39]1033Делаем начало недели в понедельник.
[128f35c]1034#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]1035 (setq calendar-week-start-day 1)
1036#+END_SRC
[68658dc]1037
[30915d2]1038*** Вернуться в предыдущий буфер
[2107e51]1039#+BEGIN_SRC emacs-lisp :tangle nil
[30915d2]1040 (define-key global-map (kbd "C-q C-q") 'previous-buffer)
1041 (define-key global-map (kbd "C-S-q C-S-q") 'next-buffer)
1042#+END_SRC
[bbdcdf6]1043*** Смена раскладки (EN / RU) и поддержка биндов на других языках
1044Работает на C-\
[c39a878]1045#+begin_src elisp :tangle init.el
[bbdcdf6]1046 (set-input-method "russian-computer")
1047 (toggle-input-method)
1048#+end_src
1049
[41a06b7]1050*** Требовать создания последней пустой строки
1051#+begin_src emacs-lisp :tangle init.el
1052 (setq require-final-newline t)
1053#+end_src
1054
[e915268]1055*** Стирать текст на C-h как в Bash
[34558f1]1056И переназначаем старые бинды
[be6d215]1057#+begin_src emacs-lisp :tangle nil
[e915268]1058 (define-key global-map (kbd "C-h") 'delete-backward-char)
1059 (define-key global-map (kbd "C-c h") 'help-command)
1060#+end_src
1061
[499be9d]1062*** Поддержка CamelCase в навигации
1063#+begin_src emacs-lisp :tangle init.el
1064 (global-subword-mode 1)
1065#+end_src
1066
[797073d]1067*** Kills
[0901186]1068#+begin_src emacs-lisp :tangle init.el
[fde9de8]1069 (use-package whole-line-or-region
1070 :bind (("C-k" . kill-region)
1071 ("C-w" . backward-kill-word))
1072 :config
[877bb6c]1073 (whole-line-or-region-global-mode))
[797073d]1074#+end_src
1075
[499be9d]1076
[3d43263]1077** Браузер
[3ec75a9]1078#+begin_src emacs-lisp :tangle nil
[864b0b5]1079 (setq browse-url-browser-function #'eww-browse-url)
1080
[8658e39]1081 (add-hook 'eww-mode-hook
1082 (lambda ()
1083 (set-fill-column 80)
1084 (display-fill-column-indicator-mode)
1085 (visual-fill-column-mode)))
1086#+end_src
[68658dc]1087
[e915268]1088** Tramp
[43feba7]1089#+begin_src emacs-lisp :tangle nil
[0d11196]1090 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
[e915268]1091#+end_src
1092
[b737271]1093** Docker
[b968867]1094#+begin_src emacs-lisp :tangle init.el
[fde9de8]1095 (use-package docker :defer t)
1096 (use-package docker-compose-mode :defer t)
[b968867]1097#+end_src
[4bde91a]1098** Debian
1099Инструменты для работы с пакетным менеджером Debian'а apt'ом и смежными
1100инструментами.
[8c09fc7]1101#+begin_src elisp :tangle nil
[4bde91a]1102 (load "debian-el-autoloads")
1103 (load "dpkg-dev-el-autoloads")
1104#+end_src
1105
[a5e2104]1106** Guix
1107#+begin_src emacs-lisp :tangle init.el
[fde9de8]1108 ;; (use-package geiser-guile :defer t)
[96b30c6]1109
[fde9de8]1110 (use-package guix
1111 :defer t
1112 :config
1113 (setq geiser-guile-binary "guile")
1114 (with-eval-after-load 'geiser-guile
1115 (progn
1116 (add-to-list 'geiser-guile-load-path "~/projects/guix/")))
[96b30c6]1117
[fde9de8]1118 (let ((guix-copyright "~/projects/guix/etc/copyright.el"))
1119 (if (file-exists-p guix-copyright)
1120 (load-file "~/projects/guix/etc/copyright.el")))
[96b30c6]1121
[fde9de8]1122 (setq copyright-names-regexp
1123 (format "%s <%s>" user-full-name user-mail-address)))
[a5e2104]1124#+end_src
1125
[212c521]1126** Nix
[fde9de8]1127#+begin_src emacs-lisp :tangle init.el
1128 (use-package nix)
[212c521]1129#+end_src
[68658dc]1130
[fcd469c]1131** Direnv
[0d11196]1132#+BEGIN_SRC emacs-lisp :tangle nil
[8c09fc7]1133 (when (package-loaded? "direnv")
1134 (direnv-mode))
[8658e39]1135#+END_SRC
[68658dc]1136
[f61bcc6]1137** Баг-трекеры
1138*** Debbugs
1139** PDF
[68658dc]1140
[25269dd]1141** Увеличение/уменьшение шрифта
[8c09fc7]1142#+BEGIN_SRC emacs-lisp :tangle nil
[8658e39]1143 (defun zoom-in ()
1144 (interactive)
1145 (let ((x (+ (face-attribute 'default :height)
1146 10)))
1147 (set-face-attribute 'default nil :height x)
1148 (set-face-attribute 'mode-line nil :height x)
1149 (set-face-attribute 'mode-line-inactive nil :height x)
1150 (set-face-attribute 'mode-line-position-face nil :height x)))
1151
1152 (defun zoom-out ()
1153 (interactive)
1154 (let ((x (- (face-attribute 'default :height)
1155 10)))
1156 (set-face-attribute 'default nil :height x)
1157 (set-face-attribute 'mode-line nil :height x)
1158 (set-face-attribute 'mode-line-inactive nil :height x)
1159 (set-face-attribute 'mode-line-position-face nil :height x)))
1160
1161 (define-key global-map (kbd "C-=") 'zoom-in)
[ec5c135]1162 (define-key global-map (kbd "C-+") 'zoom-out)
[8658e39]1163
1164#+END_SRC
[25b6477]1165
[1e08614]1166** Автокомплит у yes-or-no
[688b524]1167** Полный экран
1168Открывать Emacs на полный экран
[6650241]1169#+begin_src emacs-lisp :tangle nil
[688b524]1170 (add-to-list 'default-frame-alist '(fullscreen . maximized))
1171#+end_src
1172
[c39a878]1173** Фуллскрин
1174Отображать ровно столько строчек, сколько вмещает экран.
1175
1176Не работает с native-comp.
1177
[1e08614]1178#+begin_src elisp :tangle nil
[c39a878]1179 (toggle-frame-fullscreen)
[dbba6d8]1180
1181 (defun fullscreen ()
1182 "Fullscreen."
1183 (interactive)
1184 (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
1185 ;; if first parameter is '1', can't toggle fullscreen status
1186 '(1 "_NET_WM_STATE_FULLSCREEN" 0)))
[c39a878]1187#+end_src
[5acd0cd]1188** Удаление буфера и файла
1189#+begin_src elisp :tangle init.el
1190 (defun delete-file-and-buffer ()
1191 "Kill the current buffer and deletes the file it is visiting."
1192 (interactive)
1193 (let ((filename (buffer-file-name)))
1194 (if filename
1195 (if (y-or-n-p (concat "Do you really want to delete file " filename " ?"))
1196 (progn
1197 (delete-file filename)
1198 (message "Deleted file %s." filename)
1199 (kill-buffer)))
1200 (message "Not a file visiting buffer!"))))
1201#+end_src
[d652ebb]1202
1203** Длинные строки
[3ec75a9]1204#+begin_src emacs-lisp :tangle nil
[d652ebb]1205 ;; Better support for files with long lines
1206 (setq-default bidi-paragraph-direction 'left-to-right)
1207 (setq-default bidi-inhibit-bpa t)
1208 (global-so-long-mode 1)
1209#+end_src
1210
1211** Make shebang (#!) file executable when saved
1212#+begin_src emacs-lisp :tangle init.el
1213 (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
1214#+end_src
1215
1216** Enable savehist-mode for command history
1217#+begin_src emacs-lisp :tangle init.el
1218 (savehist-mode 1)
1219#+end_src
[7f6d0e1]1220
1221** Ignore case sensitive in completions, search and etc
1222#+begin_src emacs-lisp :tangle init.el
[fde9de8]1223 (setq completion-ignore-case t
1224 read-buffer-completion-ignore-case t
1225 read-file-name-completion-ignore-case t)
[7f6d0e1]1226#+end_src
[fde9de8]1227
1228** Make scripts executable automatically
1229#+begin_src emacs-lisp :tangle init.el
1230 (add-hook 'after-save-hook
1231 'executable-make-buffer-file-executable-if-script-p)
1232#+end_src
1233
1234** F1 for M-x shell and F2 for grep
1235#+begin_src emacs-lisp :tangle init.el
1236 (global-set-key (kbd "<f1>") 'shell)
1237 (global-set-key (kbd "<f2>") 'rgrep)
1238#+end_src
1239
1240** Hippie expand
1241#+begin_src emacs-lisp :tangle init.el
1242 (global-set-key [remap dabbrev-expand] 'hippie-expand)
1243#+end_src
1244
[fc6fa17]1245** Window Divider
1246#+begin_src emacs-lisp :tangle init.el
1247 (window-divider-mode t)
1248#+end_src
1249
1250** Use specific font for major modes
1251#+begin_src emacs-lisp :tangle init.el
1252 (buffer-face-mode t)
1253
1254 (defun set-normal-font ()
1255 "Set normal weight font in current buffer"
1256 (interactive)
1257 (buffer-face-mode 1)
1258 (setq buffer-face-mode-face '(:weight normal))
1259 (buffer-face-mode))
1260
1261 ;; Use monospaced font faces in current buffer
1262 (defun set-bold-font ()
1263 "Sets a bold font in current buffer"
1264 (interactive)
1265 (buffer-face-mode 1)
1266 (setq buffer-face-mode-face '(:weight bold))
1267 (buffer-face-mode))
1268
1269 (add-hook 'dired-mode-hook 'set-normal-font)
1270 (add-hook 'org-mode-hook 'set-normal-font)
[5211578]1271 (add-hook 'Info-mode-hook 'set-normal-font)
[fc6fa17]1272#+end_src
Note: See TracBrowser for help on using the repository browser.