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

Last change on this file since 5211578 was 5211578, checked in by Mikhail Kirillov <w96k@…>, on Sep 25, 2024 at 11:43:27 PM

Update dotfiles

  • Property mode set to 100644
File size: 36.3 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
[68658dc]572
[4ece9d5]573** PHP
[e741bd8]574*** PHP-Mode
[56a7a86]575Необходимо скачать и распаковать мануал PHP (в формате html) в
576директорию ~~/.emacs.d/php-manual/~.
[3ec75a9]577#+begin_src emacs-lisp :tangle nil
[8c09fc7]578 ;; (add-to-list 'load-path "~/.emacs.d/site-lisp/realgud-xdebug/")
579 ;; (require 'realgud-xdebug)
[e915268]580
[864b0b5]581 ;; (defun init-php-mode ()
582 ;; (eglot-ensure))
[56a7a86]583
[5211578]584 (use-package php-mode
585 :bind ("C-c h" . 'php-quickhelp-at-point)
586 :config
[be6d215]587
[5211578]588 (setq php-manual-path
589 "~/projects/php-manual/"
590 php-quickhelp-dir "~/projects/php-manual/"
591 php-quickhelp--dest "~/projects/php-manual/php_manual_en.json"))
[b968867]592
593
[5211578]594 ;; (add-hook 'php-mode-hook
595 ;; '(lambda ()
596 ;; ;; (auto-complete-mode t)
[43749e5]597
[5211578]598 ;; ;; (require 'ac-php)
599 ;; (require 'php-quickhelp)
600 ;; (require 'company)
601 ;; (company-mode t)
602 ;; (require 'company-php)
603 ;; (require 'company-quickhelp)
[951b531]604
[5211578]605 ;; (require 'yasnippet)
606 ;; (require 'yasnippet-snippets)
[951b531]607
[5211578]608 ;; (set (make-local-variable 'company-backends)
609 ;; '((company-ac-php-backend company-dabbrev-code)
610 ;; php-quickhelp-company-php
611 ;; company-capf company-files))
[951b531]612
[5211578]613 ;; (company-quickhelp-mode t)
[951b531]614
[5211578]615 ;; (define-key php-mode-map (kbd "C-M-i") 'company-complete)
616 ;; (define-key company-mode-map (kbd "M-TAB") 'company-complete)
[951b531]617
[5211578]618 ;; ;; (setq ac-sources '(ac-source-php php-quickhelp-company-php))
619 ;; ;; (setq eldoc-documentation-function
620 ;; ;; 'php-quickhelp-eldoc-func)
[b7d25b5]621
[5211578]622 ;; (yas-minor-mode t)
[b7d25b5]623
[5211578]624 ;; ;; (define-key php-mode-map (kbd "C-M-i") 'auto-complete)
625 ;; ;; (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
[b7d25b5]626
[5211578]627 ;; (define-key php-mode-map (kbd "C-c H")
628 ;; 'php-local-manual-search)
[be6d215]629
[5211578]630 ;; (define-key php-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
631 ;; (define-key company-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
[b7d25b5]632
[5211578]633 ;; ;; (define-key php-mode-map (kbd "C-c t") 'ac-php-show-tip)
[b7d25b5]634
[5211578]635 ;; ;; Jump to definition (optional)
636 ;; (define-key php-mode-map
637 ;; (kbd "M-.") 'ac-php-find-symbol-at-point)
[43749e5]638
[5211578]639 ;; ;; Return back (optional)
640 ;; (define-key php-mode-map
641 ;; (kbd "M-,") 'ac-php-location-stack-back)))
642 ))
[4ece9d5]643#+end_src
644
[e741bd8]645*** Composer
[6782e9b]646#+begin_src emacs-lisp :tangle init.el
647 (setq composer-executable-bin "~/.bin/composer")
648#+end_src
649
[e741bd8]650*** Flymake PHP
651*** REPL
652*** LSP сервер
653PHPactor
[43749e5]654#+begin_src emacs-lisp :tangle nil
[6782e9b]655 (setq phpactor-executable "~/.bin/phpactor")
656 (custom-set-variables '(lsp-phpactor-path "~/.bin/phpactor"))
657
658 (use-package phpactor :ensure t)
659 (use-package company-phpactor :ensure t)
660
661
662
663 ;; (with-eval-after-load 'php-mode
664 ;; (define-key php-mode-map (kbd "M-.") #'phpactor-goto-definition)
665 ;; (define-key php-mode-map (kbd "M-?") #'phpactor-find-references))
[e741bd8]666#+end_src
667
[af9ef4a]668*** Transient меню
[c39a878]669#+begin_src emacs-lisp :tangle nil
[d100c77]670 (require 'transient)
[f63641c]671 (define-transient-command php-menu ()
[d100c77]672 "Php"
673 [["Class"
674 ("cc" "Copy" phpactor-copy-class)
675 ("cn" "New" phpactor-create-new-class)
676 ("cr" "Move" phpactor-move-class)
677 ("ci" "Inflect" phpactor-inflect-class)
678 ("n" "Namespace" phpactor-fix-namespace)]
679 ["Properties"
680 ("a" "Accessor" phpactor-generate-accessors)
681 ("pc" "Constructor" phpactor-complete-constructor)
682 ("pm" "Add missing props" phpactor-complete-properties)
683 ("r" "Rename var locally" phpactor-rename-variable-local)
684 ("R" "Rename var in file" phpactor-rename-variable-file)]
685 ["Extract"
686 ("ec" "constant" phpactor-extract-constant)
687 ("ee" "expression" phpactor-extract-expression)
688 ("em" "method" phpactor-extract-method)]
689 ["Methods"
690 ("i" "Implement Contracts" phpactor-implement-contracts)
691 ("m" "Generate method" phpactor-generate-method)]
692 ["Navigate"
693 ("x" "List refs" phpactor-list-references)
694 ("X" "Replace refs" phpactor-replace-references)
695 ("." "Goto def" phpactor-goto-definition)]
696 ["Phpactor"
697 ("s" "Status" phpactor-status)
698 ("u" "Install" phpactor-install-or-update)]])
[af9ef4a]699#+end_src
[d06a87f]700* Языки декларирования
701** SQL
[7f6d0e1]702 to install lsp-server called sqls
[93c87eb]703https://emacs-lsp.github.io/lsp-mode/page/lsp-sqls/
[0d11196]704#+BEGIN_SRC emacs-lisp :tangle nil
[8658e39]705 ;; Empty for now (was using emacsql)
[b08cfaa]706 (setq lsp-sqls-server "~/go/bin/sqls")
[313ec50]707
[ee24a4b]708 ;; (setq lsp-sqls-workspace-config-path nil)
[313ec50]709
710 (setq lsp-sqls-connections
[ee24a4b]711 '(((driver . "mysql") (dataSourceName . "dbuser:mangoworms@tcp(localhost:3306)/profile24"))))
[8658e39]712#+END_SRC
[f63641c]713
[a198d42]714The main way to interact with SQL is using org-mode
[0d11196]715#+begin_src emacs-lisp :tangle nil
[a198d42]716 (when (package-loaded? "org-sql")
717 (setq org-sql-files "~/projects/profile24/org"))
[313ec50]718
[acdb8ab]719 (add-hook 'sql-interactive-mode-hook
[8faea87]720 (lambda ()
[e6b57ae]721 (sql-connect "profile24")
[8faea87]722 (toggle-truncate-lines t)))
[acdb8ab]723
[313ec50]724 (setq sql-connection-alist
[ee24a4b]725 '((profile24
726 (sql-product 'mysql)
727 (sql-server "localhost")
728 (sql-user "dbuser")
[0d11196]729 (sql-password "123456")
730 (sql-database "testdb")
[ee24a4b]731 (sql-port 3306))))
[a198d42]732#+end_src
733
[5211578]734*** Sql Viewer
735#+begin_src emacs-lisp :tangle init.el
736 (unless (package-installed-p 'pg)
737 (package-vc-install "https://github.com/emarsden/pg-el" nil nil 'pg))
738 (unless (package-installed-p 'pgmacs)
739 (package-vc-install "https://github.com/emarsden/pgmacs"))
740
741 (use-package pgmacs)
742#+end_src
743
[a198d42]744
[f61bcc6]745** Веб шаблоны
746*** Web-mode
[128f35c]747#+BEGIN_SRC emacs-lisp :tangle init.el
[fde9de8]748 (use-package web-mode
749 :defer t
750 :config
751 (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
752 (add-to-list 'auto-mode-alist '("\\.twig.html\\'" . web-mode))
753 (setq web-mode-markup-indent-offset 2)
754 (setq web-mode-enable-auto-pairing t)
755 (setq web-mode-enable-css-colorization t)
756 (setq web-mode-enable-block-face t)
757 (setq web-mode-enable-current-element-highlight t))
[8658e39]758#+END_SRC
[68658dc]759
[e53abd3]760** Org
761*** Org-mode
[128f35c]762#+BEGIN_SRC emacs-lisp :tangle init.el
[fde9de8]763 (use-package org
764 :defer t
765 :config
766 (org-babel-do-load-languages
767 'org-babel-load-languages
768 '((R . t)
769 (ditaa . t)
770 (dot . t)
771 ;; (php . t)
772 (emacs-lisp . t)
773 (gnuplot . t)
774 (haskell . nil)
775 (latex . t)
776 ;;(ledger . t)
777 (ocaml . nil)
778 (octave . t)
779 (python . t)
780 (ruby . t)
781 (screen . nil)
782 (shell . t)
783 (sql . t)
784 (js . t)))
785 (setq org-default-notes-file "~/Documents/todo.org"
[877bb6c]786 system-time-locale "C"
[c39a878]787 org-use-speed-commands t
788 org-adapt-indentation nil
789 org-return-follows-link t
[7f6d0e1]790 org-agenda-include-diary t
[ea0b945]791 org-display-remote-inline-images 'download
[7f6d0e1]792 org-agenda-start-with-log-mode t
[edf34a3]793 org-image-actual-width (list 400)
[c39a878]794 org-hide-emphasis-markers t
795 org-outline-path-complete-in-steps nil
796 org-src-tab-acts-natively t
[09e91e8]797 org-id-track-globally t
[c39a878]798 org-confirm-babel-evaluate nil)
[fde9de8]799 (setq org-todo-keywords
[c39a878]800 (quote ((sequence "TODO(t)"
[254aa1d]801 "MIGRATE(m)"
[c39a878]802 "IN PROGRESS(p)"
803 "DONE(d)")
[7f6d0e1]804 (sequence "BLOCKED(w@/!)"
[c39a878]805 "HOLD(h@/!)" "|"
806 "CANCELLED(c@/!)"
807 "PHONE"
[7f6d0e1]808 "MEETING"
809 "NEED CLARIFICATION(t)"
810 ))))
[fde9de8]811 (setq org-todo-keyword-faces
[c39a878]812 (quote (("TODO" :foreground "red" :weight bold)
813 ("NEXT" :foreground "blue" :weight bold)
814 ("DONE" :foreground "forest green" :weight bold)
815 ("WAITING" :foreground "orange" :weight bold)
816 ("HOLD" :foreground "magenta" :weight bold)
817 ("CANCELLED" :foreground "forest green" :weight bold)
818 ("MEETING" :foreground "forest cyan" :weight bold)
819 ("PHONE" :foreground "blue" :weight bold))))
[fde9de8]820 :bind
821 ("C-c l" . org-store-link)
822 ("C-c a" . org-agenda)
823 ("C-c c" . org-capture)
824 )
825
826 (defun org-babel-edit-prep:sql (babel-info)
827 (setq-local buffer-file-name (->> babel-info caddr (alist-get :tangle)))
828 (setq-local lsp-buffer-uri (->> babel-info caddr (alist-get :tangle) lsp--path-to-uri))
829 (setq-local lsp-headerline-breadcrumb-enable nil)
830 (lsp))
831
832 ;; (global-set-key (kbd "M-f") 'org-metaright)
833 ;; (global-set-key (kbd "M-b") 'org-metaleft)
834 ;; (global-set-key (kbd "M-p") 'org-metaup)
835 ;; (global-set-key (kbd "M-n") 'org-metadown)
[8658e39]836#+END_SRC
[68658dc]837
[fde9de8]838
839*** Org-ref
[d3c0bac]840#+begin_src emacs-lisp :tangle nil
[8658e39]841 (load "org-ref-autoloads")
842
843 (setq reftex-default-bibliography '("~/Documents/bibliography/references.bib"))
844
845 ;; see org-ref for use of these variables
846 (setq org-ref-bibliography-notes "~/Documents/bibliography/notes.org"
847 org-ref-default-bibliography '("~/Documents/Bibliography/references.bib")
848 org-ref-pdf-directory "~/Documents/bibliography/bibtex-pdfs/")
849#+end_src
[e53abd3]850
[d61c4ab]851*** Org-roam
[d652ebb]852#+begin_src emacs-lisp :tangle init.el
[fde9de8]853 (use-package org-roam
854 :defer t
855 :bind
856 ("C-c n l" . org-roam-node-insert)
857 ("C-c n b" . org-roam-buffer-toggle)
858 ("C-c n f" . org-roam-node-find)
859 ("C-c n t t" . org-roam-tag-add)
860 ("C-c n t r" . org-roam-tag-remove)
861 ("C-c n i" . org-roam-jump-to-index)
862 ("C-c n g" . org-roam-graph)
863 ("C-c n d" . org-roam-db-build-cache)
864 ("C-c n r" . org-roam-node-random)
865 ("C-c n j" . org-roam-dailies-find-date)
866 :config
867 (setq org-roam-directory (file-truename "~/Zettelkasten")
868 org-roam-v2-ack t
869 org-roam-completion-everywhere t
870 org-roam-index-file (concat org-roam-directory "/20210409054712-жизнь.org")
871 org-roam-dailies-directory (concat org-roam-directory "journals/"))
872
873 (org-roam-db-autosync-mode t))
874
875 (defun org-roam-jump-to-index ()
876 "Stub of recreating the function from V1"
877 (interactive)
878 (let
879 ((org-roam-index org-roam-index-file))
880 (find-file org-roam-index)))
[395b6b5]881
[fde9de8]882 (use-package org
883 :defer t
884 :config
885 (customize-set-variable 'org-link-descriptive t)
[d61c4ab]886
[fde9de8]887 (add-to-list 'org-agenda-files
888 "~/Documents/todo.org")
[3a19ca7]889
[fde9de8]890 (setq org-directory "~/Documents"
891 org-default-notes-file (concat org-directory "/todo.org")))
[cc591cc]892#+end_src
893
[2bb7684]894** YAML
[fde9de8]895#+begin_src emacs-lisp :tangle init.el
896 (use-package yaml-mode
897 :defer t)
[2bb7684]898#+end_src
899
[f61bcc6]900* Коммуникации
[7f6d0e1]901** Gnus
902#+begin_src emacs-lisp :tangle init.el
903
904#+end_src
905
[f61892c]906** Telega
[3ec75a9]907#+BEGIN_SRC emacs-lisp :tangle init.el
[fde9de8]908 (use-package telega
909 :bind (("C-c t" . telega-prefix-map)))
[8658e39]910#+END_SRC
[68658dc]911
[1c49a32]912** Mastodon
[fde9de8]913#+begin_src emacs-lisp :tangle init.el
914 (use-package mastodon
915 :defer t
916 :config
[b968867]917 (setq mastodon-active-user "w96k"
918 mastodon-instance-url "https://fosstodon.org/"))
[1c49a32]919#+end_src
920
[f61bcc6]921* Разное
[fde9de8]922** *Highlight
923#+BEGIN_SRC emacs-lisp :tangle init.el
924 (use-package highlight
925 :defer t)
926#+end_src
[d184fc7]927** Минорные твики дефолтного имакса
[8e15ad4]928*** Короткие ответы на вопросы
[0d11196]929#+begin_src emacs-lisp :tangle init.el
[8e15ad4]930 (if (boundp 'use-short-answers)
931 (setq use-short-answers t)
932 (advice-add 'yes-or-no-p :override #'y-or-n-p))
933#+end_src
934
935*** Не сохранять дубликаты в killring
936
[d80bfc6]937*** Подсвечивать текущую строку
[0d11196]938#+begin_src emacs-lisp :tangle nil
[fde9de8]939 (global-hl-line-mode t)
[395b6b5]940#+end_src
941
[d184fc7]942*** Автодополнение в echo при M-x и других командах
[3ec75a9]943#+begin_src emacs-lisp :tangle init.el
[fde9de8]944 (icomplete-mode t)
[d184fc7]945#+end_src
946*** Проверять орфографию
947#+begin_src emacs-lisp :tangle init.el
[fde9de8]948 (flyspell-mode t)
[ec71c8e]949#+end_src
950
[f61bcc6]951*** Не спрашивать о несуществующих буферах
[128f35c]952#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]953 (setq-default confirm-nonexistent-file-or-buffer t)
954#+END_SRC
[68658dc]955
[373ed2d]956*** Переключение буферов
[0d11196]957#+BEGIN_SRC emacs-lisp :tangle init.el
[373ed2d]958 (global-set-key (kbd "M-o") 'mode-line-other-buffer)
959#+END_SRC
[ef88711]960
[01e632c]961*** Минорные твики
962#+begin_src emacs-lisp :tangle init.el
[0d11196]963 ;; (setq redisplay-dont-pause t)
[3aaa66b]964
965 (setq select-enable-clipboard t
966 select-enable-primary t)
967
[2107e51]968 (setq completions-detailed nil)
[3aaa66b]969
970 (setq kill-buffer-delete-auto-save-files t)
971 (setq next-error-message-highlight t)
972
973 (setq mode-line-compact 'long)
974
[2107e51]975 (setq completions-group t)
976
[01e632c]977 ;;(set-frame-parameter nil 'internal-border-width 0)
978
979 ;; (set-window-buffer nil (current-buffer))
980
[0d11196]981 (setq default-directory "~/"
[01e632c]982 custom-safe-themes t
983 delete-old-versions t
984 enable-local-variables t)
985#+end_src
986
[e93b7a8]987*** Shell
[128f35c]988#+begin_src emacs-lisp :tangle init.el
[8658e39]989 (setq ansi-color-for-comint-mode t)
990 (setq shell-command-prompt-show-cwd t)
991#+end_src
[68658dc]992
[f61bcc6]993*** Переменная PATH в eshell
[0d11196]994#+BEGIN_SRC emacs-lisp :tangle nil
[6eb7430]995 (setq exec-path-from-shell-variables
996 '("PATH" "MANPATH"))
997
[f63641c]998 (when (and (memq window-system '(mac ns x))
999 (not (eq system-type 'berkeley-unix)))
1000 (exec-path-from-shell-initialize))
[8658e39]1001#+END_SRC
[68658dc]1002
[f61bcc6]1003*** Отображение номера колонки
[128f35c]1004#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]1005 (column-number-mode)
1006#+END_SRC
[68658dc]1007
[cc8263e]1008*** nobreak символы
[128f35c]1009#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]1010 (setq nobreak-char-display nil)
1011#+END_SRC
[68658dc]1012
[2a1b24a]1013*** Меню
[3176064]1014*** Сохранять временные файлы не в той же директории
[128f35c]1015#+BEGIN_SRC emacs-lisp :tangle init.el
[3aaa66b]1016 (defvar backup-dir "~/.emacs.d/backups/")
1017
[8658e39]1018 (setq
1019 backup-by-copying t
1020 backup-directory-alist
[0d11196]1021 '(("~/.emacs.d/backups/"))
[e915268]1022 version-control nil)
[8658e39]1023#+END_SRC
[68658dc]1024
[1e93232]1025*** Календарь
[8658e39]1026Делаем начало недели в понедельник.
[128f35c]1027#+BEGIN_SRC emacs-lisp :tangle init.el
[8658e39]1028 (setq calendar-week-start-day 1)
1029#+END_SRC
[68658dc]1030
[30915d2]1031*** Вернуться в предыдущий буфер
[2107e51]1032#+BEGIN_SRC emacs-lisp :tangle nil
[30915d2]1033 (define-key global-map (kbd "C-q C-q") 'previous-buffer)
1034 (define-key global-map (kbd "C-S-q C-S-q") 'next-buffer)
1035#+END_SRC
[bbdcdf6]1036*** Смена раскладки (EN / RU) и поддержка биндов на других языках
1037Работает на C-\
[c39a878]1038#+begin_src elisp :tangle init.el
[bbdcdf6]1039 (set-input-method "russian-computer")
1040 (toggle-input-method)
1041#+end_src
1042
[41a06b7]1043*** Требовать создания последней пустой строки
1044#+begin_src emacs-lisp :tangle init.el
1045 (setq require-final-newline t)
1046#+end_src
1047
[e915268]1048*** Стирать текст на C-h как в Bash
[34558f1]1049И переназначаем старые бинды
[be6d215]1050#+begin_src emacs-lisp :tangle nil
[e915268]1051 (define-key global-map (kbd "C-h") 'delete-backward-char)
1052 (define-key global-map (kbd "C-c h") 'help-command)
1053#+end_src
1054
[499be9d]1055*** Поддержка CamelCase в навигации
1056#+begin_src emacs-lisp :tangle init.el
1057 (global-subword-mode 1)
1058#+end_src
1059
[797073d]1060*** Kills
[0901186]1061#+begin_src emacs-lisp :tangle init.el
[fde9de8]1062 (use-package whole-line-or-region
1063 :bind (("C-k" . kill-region)
1064 ("C-w" . backward-kill-word))
1065 :config
[877bb6c]1066 (whole-line-or-region-global-mode))
[797073d]1067#+end_src
1068
[499be9d]1069
[3d43263]1070** Браузер
[3ec75a9]1071#+begin_src emacs-lisp :tangle nil
[864b0b5]1072 (setq browse-url-browser-function #'eww-browse-url)
1073
[8658e39]1074 (add-hook 'eww-mode-hook
1075 (lambda ()
1076 (set-fill-column 80)
1077 (display-fill-column-indicator-mode)
1078 (visual-fill-column-mode)))
1079#+end_src
[68658dc]1080
[e915268]1081** Tramp
[43feba7]1082#+begin_src emacs-lisp :tangle nil
[0d11196]1083 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
[e915268]1084#+end_src
1085
[b737271]1086** Docker
[b968867]1087#+begin_src emacs-lisp :tangle init.el
[fde9de8]1088 (use-package docker :defer t)
1089 (use-package docker-compose-mode :defer t)
[b968867]1090#+end_src
[4bde91a]1091** Debian
1092Инструменты для работы с пакетным менеджером Debian'а apt'ом и смежными
1093инструментами.
[8c09fc7]1094#+begin_src elisp :tangle nil
[4bde91a]1095 (load "debian-el-autoloads")
1096 (load "dpkg-dev-el-autoloads")
1097#+end_src
1098
[a5e2104]1099** Guix
1100#+begin_src emacs-lisp :tangle init.el
[fde9de8]1101 ;; (use-package geiser-guile :defer t)
[96b30c6]1102
[fde9de8]1103 (use-package guix
1104 :defer t
1105 :config
1106 (setq geiser-guile-binary "guile")
1107 (with-eval-after-load 'geiser-guile
1108 (progn
1109 (add-to-list 'geiser-guile-load-path "~/projects/guix/")))
[96b30c6]1110
[fde9de8]1111 (let ((guix-copyright "~/projects/guix/etc/copyright.el"))
1112 (if (file-exists-p guix-copyright)
1113 (load-file "~/projects/guix/etc/copyright.el")))
[96b30c6]1114
[fde9de8]1115 (setq copyright-names-regexp
1116 (format "%s <%s>" user-full-name user-mail-address)))
[a5e2104]1117#+end_src
1118
[212c521]1119** Nix
[fde9de8]1120#+begin_src emacs-lisp :tangle init.el
1121 (use-package nix)
[212c521]1122#+end_src
[68658dc]1123
[fcd469c]1124** Direnv
[0d11196]1125#+BEGIN_SRC emacs-lisp :tangle nil
[8c09fc7]1126 (when (package-loaded? "direnv")
1127 (direnv-mode))
[8658e39]1128#+END_SRC
[68658dc]1129
[f61bcc6]1130** Баг-трекеры
1131*** Debbugs
1132** PDF
[68658dc]1133
[25269dd]1134** Увеличение/уменьшение шрифта
[8c09fc7]1135#+BEGIN_SRC emacs-lisp :tangle nil
[8658e39]1136 (defun zoom-in ()
1137 (interactive)
1138 (let ((x (+ (face-attribute 'default :height)
1139 10)))
1140 (set-face-attribute 'default nil :height x)
1141 (set-face-attribute 'mode-line nil :height x)
1142 (set-face-attribute 'mode-line-inactive nil :height x)
1143 (set-face-attribute 'mode-line-position-face nil :height x)))
1144
1145 (defun zoom-out ()
1146 (interactive)
1147 (let ((x (- (face-attribute 'default :height)
1148 10)))
1149 (set-face-attribute 'default nil :height x)
1150 (set-face-attribute 'mode-line nil :height x)
1151 (set-face-attribute 'mode-line-inactive nil :height x)
1152 (set-face-attribute 'mode-line-position-face nil :height x)))
1153
1154 (define-key global-map (kbd "C-=") 'zoom-in)
[ec5c135]1155 (define-key global-map (kbd "C-+") 'zoom-out)
[8658e39]1156
1157#+END_SRC
[25b6477]1158
[1e08614]1159** Автокомплит у yes-or-no
[688b524]1160** Полный экран
1161Открывать Emacs на полный экран
[6650241]1162#+begin_src emacs-lisp :tangle nil
[688b524]1163 (add-to-list 'default-frame-alist '(fullscreen . maximized))
1164#+end_src
1165
[c39a878]1166** Фуллскрин
1167Отображать ровно столько строчек, сколько вмещает экран.
1168
1169Не работает с native-comp.
1170
[1e08614]1171#+begin_src elisp :tangle nil
[c39a878]1172 (toggle-frame-fullscreen)
[dbba6d8]1173
1174 (defun fullscreen ()
1175 "Fullscreen."
1176 (interactive)
1177 (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
1178 ;; if first parameter is '1', can't toggle fullscreen status
1179 '(1 "_NET_WM_STATE_FULLSCREEN" 0)))
[c39a878]1180#+end_src
[5acd0cd]1181** Удаление буфера и файла
1182#+begin_src elisp :tangle init.el
1183 (defun delete-file-and-buffer ()
1184 "Kill the current buffer and deletes the file it is visiting."
1185 (interactive)
1186 (let ((filename (buffer-file-name)))
1187 (if filename
1188 (if (y-or-n-p (concat "Do you really want to delete file " filename " ?"))
1189 (progn
1190 (delete-file filename)
1191 (message "Deleted file %s." filename)
1192 (kill-buffer)))
1193 (message "Not a file visiting buffer!"))))
1194#+end_src
[d652ebb]1195
1196** Длинные строки
[3ec75a9]1197#+begin_src emacs-lisp :tangle nil
[d652ebb]1198 ;; Better support for files with long lines
1199 (setq-default bidi-paragraph-direction 'left-to-right)
1200 (setq-default bidi-inhibit-bpa t)
1201 (global-so-long-mode 1)
1202#+end_src
1203
1204** Make shebang (#!) file executable when saved
1205#+begin_src emacs-lisp :tangle init.el
1206 (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
1207#+end_src
1208
1209** Enable savehist-mode for command history
1210#+begin_src emacs-lisp :tangle init.el
1211 (savehist-mode 1)
1212#+end_src
[7f6d0e1]1213
1214** Ignore case sensitive in completions, search and etc
1215#+begin_src emacs-lisp :tangle init.el
[fde9de8]1216 (setq completion-ignore-case t
1217 read-buffer-completion-ignore-case t
1218 read-file-name-completion-ignore-case t)
[7f6d0e1]1219#+end_src
[fde9de8]1220
1221** Make scripts executable automatically
1222#+begin_src emacs-lisp :tangle init.el
1223 (add-hook 'after-save-hook
1224 'executable-make-buffer-file-executable-if-script-p)
1225#+end_src
1226
1227** F1 for M-x shell and F2 for grep
1228#+begin_src emacs-lisp :tangle init.el
1229 (global-set-key (kbd "<f1>") 'shell)
1230 (global-set-key (kbd "<f2>") 'rgrep)
1231#+end_src
1232
1233** Hippie expand
1234#+begin_src emacs-lisp :tangle init.el
1235 (global-set-key [remap dabbrev-expand] 'hippie-expand)
1236#+end_src
1237
[fc6fa17]1238** Window Divider
1239#+begin_src emacs-lisp :tangle init.el
1240 (window-divider-mode t)
1241#+end_src
1242
1243** Use specific font for major modes
1244#+begin_src emacs-lisp :tangle init.el
1245 (buffer-face-mode t)
1246
1247 (defun set-normal-font ()
1248 "Set normal weight font in current buffer"
1249 (interactive)
1250 (buffer-face-mode 1)
1251 (setq buffer-face-mode-face '(:weight normal))
1252 (buffer-face-mode))
1253
1254 ;; Use monospaced font faces in current buffer
1255 (defun set-bold-font ()
1256 "Sets a bold font in current buffer"
1257 (interactive)
1258 (buffer-face-mode 1)
1259 (setq buffer-face-mode-face '(:weight bold))
1260 (buffer-face-mode))
1261
1262 (add-hook 'dired-mode-hook 'set-normal-font)
1263 (add-hook 'org-mode-hook 'set-normal-font)
[5211578]1264 (add-hook 'Info-mode-hook 'set-normal-font)
[fc6fa17]1265#+end_src
Note: See TracBrowser for help on using the repository browser.