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

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

Update configs

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