From de70f18f5fe9adaf78f2fcc59acbb801f5a0506a Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Fri, 1 Oct 2021 18:59:00 +0300 Subject: [PATCH] upd --- content/configs/Console.md | 11 ++ content/configs/Console.md~ | 1 - content/configs/Desktop.md~ | 33 +++- content/configs/Emacs.md | 47 +++++- content/configs/Emacs.md~ | 255 +++++++++++++++++++++-------- content/configs/Guix.md | 43 +---- content/configs/Guix.md~ | 3 + content/configs/Mail.md | 2 + content/configs/README.md~ | 2 +- public/configs/console/index.html | 5 + public/configs/emacs/index.html | 41 +++-- public/configs/guix/index.html | 57 +------ public/configs/index.xml | 2 +- public/configs/mail/index.html | 2 + public/ox-hugo/all.png | Bin 117145 -> 116855 bytes public/ox-hugo/emacs-vim.png | Bin 53298 -> 54105 bytes public/ox-hugo/literate-config.png | Bin 60071 -> 61934 bytes static/ox-hugo/all.png | Bin 117145 -> 116855 bytes static/ox-hugo/emacs-vim.png | Bin 53298 -> 54105 bytes static/ox-hugo/literate-config.png | Bin 60071 -> 61934 bytes 20 files changed, 328 insertions(+), 176 deletions(-) diff --git a/content/configs/Console.md b/content/configs/Console.md index 42884da..e0306c5 100644 --- a/content/configs/Console.md +++ b/content/configs/Console.md @@ -529,6 +529,17 @@ bind -M insert \eb backward-word ``` +### Functions {#functions} + +A small function to open the file with `$EDITOR`. + +```fish +function e + eval $EDITOR $argv +end +``` + + ## Nushell {#nushell} | Guix dependency | diff --git a/content/configs/Console.md~ b/content/configs/Console.md~ index 672c7aa..42884da 100644 --- a/content/configs/Console.md~ +++ b/content/configs/Console.md~ @@ -17,7 +17,6 @@ draft = false # export BROWSER=/usr/bin/firefox export QT_QPA_PLATFORMTHEME="qt5ct" export QT_AUTO_SCREEN_SCALE_FACTOR=0 -export TZ="Asia/Yekaterinburg" # export GTK2_RC_FILES="$HOME/.gtkrc-2.0" ``` diff --git a/content/configs/Desktop.md~ b/content/configs/Desktop.md~ index b062752..166d31d 100644 --- a/content/configs/Desktop.md~ +++ b/content/configs/Desktop.md~ @@ -68,6 +68,7 @@ Parts prefixed with (OFF) are not used, but kept for historic purposes. For some - [Scripts](#scripts) - [Buku bookmarks](#buku-bookmarks) - [Man pages](#man-pages) + - [pass](#pass) - [Flameshot](#flameshot) - [dunst](#dunst) - [keynav](#keynav) @@ -576,7 +577,7 @@ bindsym $mod+Shift+g mode "outer gaps" A more or less standard set of keybindings to move & resize floating windows. -Just be careful to always make a way to return from these new modes, otherwise, you'd end up in a rather precarious position. +Just be careful to always make a way to return from these new modes, otherwise you'd end up in a rather precarious situation. ```vim # resize window (you can also use the mouse for that) @@ -665,6 +666,7 @@ Keybindings to launch [rofi](https://github.com/davatorium/rofi). For more detai ```vim bindsym $mod+d exec "rofi -modi 'drun,run' -show drun" bindsym $mod+b exec --no-startup-id rofi-buku-mine +bindsym $mod+minus exec rofi-pass; mode default bindsym $mod+apostrophe mode "rofi" @@ -672,7 +674,7 @@ mode "rofi" { bindsym d exec "rofi -modi 'drun,run' -show drun" bindsym m exec rofi-man; mode default bindsym b exec rofi-buku-mine; mode default - bindsym k exec rofi-keepassxc -d ~/MEGAsync/Passwords.kdbx; mode default + bindsym k exec rofi-pass; mode default bindsym Escape mode "default" } ``` @@ -936,7 +938,7 @@ declare -A BLOCKS=( ) # Geolocation for some modules -export LOC="TMN" +export LOC="SPB" export IPSTACK_API_KEY=$(pass show My_Online/APIs/ipstack | head -n 1) @@ -1713,6 +1715,23 @@ fi ``` +#### pass {#pass} + +| Guix dependency | +|-----------------| +| rofi-pass | +| xset | + +A nice [pass frontend for Rofi](https://github.com/carnager/rofi-pass), which is even packaged for Guix. + +```bash +USERNAME_field='username' +EDITOR=vim +default_autotype='username :tab pass' +clip=both +``` + + ## Flameshot {#flameshot} | Guix dependency | @@ -1813,7 +1832,7 @@ References: # Show how many messages are currently hidden (because of geometry). indicate_hidden = yes - # Shrink window if it's smaller than the width. Will be ignored if + # Shrink window if its smaller than the width. Will be ignored if # width is 0. shrink = no @@ -2347,6 +2366,10 @@ This section generates manifests for various desktop software that I'm using. | dev | openjdk | | dev | go | | dev | gcc-toolchain | +| dev | lua | +| dev | libfaketime | +| dev | hugo-extended | +| dev | make | ### Manifests {#manifests} @@ -2731,6 +2754,8 @@ Other desktop programs I use are listed below. | fontconfig | | | polkit-gnome | Polkit authentication agent | | anydesk | Remote desktop software | +| gnome-disk-utility | Manage disks | +| gparted | Manage partitions | ```emacs-lisp diff --git a/content/configs/Emacs.md b/content/configs/Emacs.md index b3142cc..ca55e84 100644 --- a/content/configs/Emacs.md +++ b/content/configs/Emacs.md @@ -107,6 +107,7 @@ As with other files in the repo, parts prefixed with (OFF) are not used but kept - [Configuration](#configuration) - [Subterminal](#subterminal) - [Dired integration](#dired-integration) + - [With-editor integration](#with-editor-integration) - [Eshell](#eshell) - [Org Mode](#org-mode) - [Installation & basic settings](#installation-and-basic-settings) @@ -205,8 +206,10 @@ As with other files in the repo, parts prefixed with (OFF) are not used but kept - [Meta Lisp](#meta-lisp) - [Emacs Lisp](#emacs-lisp) - [Package Lint](#package-lint) - - [General](#general) + - [General settings](#general-settings) - [Common lisp](#common-lisp) + - [SLIME](#slime) + - [General settings](#general-settings) - [Clojure](#clojure) - [Hy](#hy) - [Scheme](#scheme) @@ -734,7 +737,8 @@ I don't enable the entire package, just the modes I need. comint git-timemachine magit - prodigy))) + prodigy + slime))) ``` @@ -886,6 +890,7 @@ And winner-mode to keep the history of window states. "h" 'previous-buffer "k" 'kill-buffer "b" 'persp-ivy-switch-buffer + "r" 'revert-buffer "u" 'ibuffer) ``` @@ -1562,7 +1567,9 @@ References: (use-package yasnippet :straight t :config - (setq yas-snippet-dirs `(,(concat (expand-file-name user-emacs-directory) "snippets"))) + (setq yas-snippet-dirs + `(,(concat (expand-file-name user-emacs-directory) "snippets") + yasnippet-snippets-dir)) (setq yas-triggers-in-field t) (yas-global-mode 1)) @@ -2486,6 +2493,21 @@ Keybindings: ``` +#### With-editor integration {#with-editor-integration} + +A package used by Magit to use the current Emacs instance as the `$EDITOR`. + +That is, with the help of [this function]({{< relref "Console" >}}), I can just write `e `, edit the file, and then return to the same vterm buffer. No more running vim inside Emacs. + +```emacs-lisp +(use-package with-editor + :straight t + :after (vterm) + :config + (add-hook 'vterm-mode-hook 'with-editor-export-editor)) +``` + + ### Eshell {#eshell} A shell written in Emacs lisp. I don't use it as of now, but keep the config just in case. @@ -3162,7 +3184,7 @@ So, here is a list of queries results of which I want to see in the review templ (todo "DONE"))) ("Attended meetings" closed scheduled (and - (tags "meeting") + (tags-inherited "meeting") (todo "PASSED"))) ("Done project tasks" closed deadline (and @@ -4319,7 +4341,6 @@ Configs for various web development technologies I'm using. | Type | Note | |------|---------------------------------------------------| -| TODO | Do not enable for every Svelte mode | | TODO | make expand div[disabled] as
| My bit of config here: @@ -5008,7 +5029,7 @@ A package that checks for the metadata in Emacs Lisp packages. ``` -##### General {#general} +##### General settings {#general-settings} ```emacs-lisp (add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode) @@ -5019,6 +5040,20 @@ A package that checks for the metadata in Emacs Lisp packages. #### Common lisp {#common-lisp} + +##### SLIME {#slime} + +```emacs-lisp +(use-package slime + :straight t + :config + (setq inferior-lisp-program "sbcl") + (add-hook 'slime-repl-mode 'smartparens-mode)) +``` + + +##### General settings {#general-settings} + ```emacs-lisp (add-hook 'lisp-mode-hook #'aggressive-indent-mode) ;; (add-hook 'emacs-lisp-mode-hook #'smartparens-strict-mode) diff --git a/content/configs/Emacs.md~ b/content/configs/Emacs.md~ index 62ce64a..b3142cc 100644 --- a/content/configs/Emacs.md~ +++ b/content/configs/Emacs.md~ @@ -19,15 +19,16 @@ As with other files in the repo, parts prefixed with (OFF) are not used but kept - [Measure startup speed](#measure-startup-speed) - [straight.el](#straight-dot-el) - [use-package](#use-package) + - [config variants & environment](#config-variants-and-environment) - [Performance](#performance) - [Garbage collection](#garbage-collection) - [Run garbage collection when Emacs is unfocused](#run-garbage-collection-when-emacs-is-unfocused) - - [Misc](#misc) - [Native compilation](#native-compilation) - - [Anaconda & environment](#anaconda-and-environment) + - [Anaconda](#anaconda) - [Custom file location](#custom-file-location) - [Private config](#private-config) - [No littering](#no-littering) + - [Prevent Emacs from closing](#prevent-emacs-from-closing) - [Global editing configuration](#global-editing-configuration) - [General keybindings stuff](#general-keybindings-stuff) - [general.el](#general-dot-el) @@ -150,7 +151,9 @@ As with other files in the repo, parts prefixed with (OFF) are not used but kept - [Keybindings & stuff](#keybindings-and-stuff) - [Copy a link](#copy-a-link) - [Presentations](#presentations) - - [TOC](#toc) + - [Tools](#tools) + - [TOC](#toc) + - [Screenshots](#screenshots) - [System configuration](#system-configuration) - [Tables for Guix Dependencies](#tables-for-guix-dependencies) - [Noweb evaluations](#noweb-evaluations) @@ -171,7 +174,7 @@ As with other files in the repo, parts prefixed with (OFF) are not used but kept - [OFF (OFF) Code Compass](#off--code-compass) - [Dependencies](#dependencies) - [Plugin](#plugin) - - [CHECK (OFF) Format-all](#off--format-all) + - [Reformatter](#reformatter) - [General additional config](#general-additional-config) - [Web development](#web-development) - [Emmet](#emmet) @@ -225,7 +228,9 @@ As with other files in the repo, parts prefixed with (OFF) are not used but kept - [fish](#fish) - [sh](#sh) - [Haskell](#haskell) + - [Lua](#lua) - [JSON](#json) + - [SQL](#sql) - [YAML](#yaml) - [.env](#dot-env) - [CSV](#csv) @@ -342,6 +347,56 @@ References: ``` +### config variants & environment {#config-variants-and-environment} + +The following variable is true when my machine is not powerful enough for some resource-heavy packages. + +```emacs-lisp +(setq my/lowpower (string= (system-name) "azure")) +``` + +The following is true if Emacs is meant to be used with TRAMP over slow ssh. + +```emacs-lisp +(setq my/slow-ssh + (or + (string= (getenv "IS_TRAMP") "true") + (string= (system-name) "dev-digital"))) +``` + +The following is true is Emacs is ran on a remote server where I don't need stuff like my org workflow + +```emacs-lisp +(setq my/remote-server + (or (string= (getenv "IS_REMOTE") "true") + (string= (system-name) "dev-digital"))) +``` + +And the following is true if Emacs is run from termux on Android. + +```emacs-lisp +(setq my/is-termux (string-match-p (rx (* nonl) "com.termux" (* nonl)) (getenv "HOME"))) +``` + +Also, I sometimes need to know if a program is running inside Emacs (say, inside a terminal emulator). To do that, I set the following environment variable: + +```emacs-lisp +(setenv "IS_EMACS" "true") +``` + +Finally, I want to have a minimal Emacs config for debugging purposes. This has just straight.el, use-packages and evil. + +```emacs-lisp +<> +``` + +To launch Emacs with this config, run + +```bash +emacs -q -l ~/.emacs.d/init-minimal.el +``` + + ### Performance {#performance} @@ -373,27 +428,6 @@ Some time has passed, and I still don't know if there is any quantifiable advant ``` -#### Misc {#misc} - -The following variable is true when my machine is not powerful enough for some resource-heavy packages. - -```emacs-lisp -(setq my/lowpower (string= (system-name) "azure")) -``` - -The following is true if Emacs is meant to be used with TRAMP over slow ssh. - -```emacs-lisp -(setq my/slow-ssh (string= (getenv "IS_TRAMP") "true")) -``` - -And the following is true if Emacs is run from termux on Android. - -```emacs-lisp -(setq my/is-termux (string-match-p (rx (* nonl) "com.termux" (* nonl)) (getenv "HOME"))) -``` - - #### Native compilation {#native-compilation} Set number of jobs to 1 on low-power machines @@ -404,7 +438,7 @@ Set number of jobs to 1 on low-power machines ``` -### Anaconda & environment {#anaconda-and-environment} +### Anaconda {#anaconda} [Anaconda](https://www.anaconda.com/) is a free package and environment manager. I currently use it to manage multiple versions of Python and Node.js @@ -434,12 +468,6 @@ References: (conda-env-activate "general"))) ``` -Also, I sometimes need to know if a program is running inside Emacs (say, inside a terminal emulator). To do that, I set the following environment variable: - -```emacs-lisp -(setenv "IS_EMACS" "true") -``` - ### Custom file location {#custom-file-location} @@ -472,6 +500,15 @@ By default emacs and its packages create a lot files in `.emacs.d` and in other ``` +### Prevent Emacs from closing {#prevent-emacs-from-closing} + +This adds a confirmation to avoid accidental Emacs closing. + +```emacs-lisp +(setq confirm-kill-emacs 'y-or-n-p) +``` + + ## Global editing configuration {#global-editing-configuration} @@ -1437,7 +1474,7 @@ A company frontend with nice icons. ```emacs-lisp (use-package company-box :straight t - :if (not my/lowpower) + :if (and (display-graphic-p) (not my/lowpower)) :after (company) :hook (company-mode . company-box-mode)) ``` @@ -1556,7 +1593,7 @@ Before I figure out how to package this for Guix: ```emacs-lisp (use-package wakatime-mode :straight (:host github :repo "SqrtMinusOne/wakatime-mode") - :if (not my/is-termux) + :if (not (or my/is-termux my/remote-server)) :config (setq wakatime-ignore-exit-codes '(0 1 102)) (advice-add 'wakatime-init :after (lambda () (setq wakatime-cli-path "/home/pavel/bin/wakatime-cli"))) @@ -1573,7 +1610,7 @@ Before I figure out how to package this for Guix: (use-package activity-watch-mode :straight t - :if (not my/is-termux) + :if (not (or my/is-termux my/remote-server)) :config (global-activity-watch-mode)) ``` @@ -1692,7 +1729,9 @@ My colorscheme of choice. :config (setq doom-themes-enable-bold t doom-themes-enable-italic t) - (load-theme 'doom-palenight t) + (if my/remote-server + (load-theme 'doom-gruvbox t) + (load-theme 'doom-palenight t)) (doom-themes-visual-bell-config) (setq doom-themes-treemacs-theme "doom-colors") (doom-themes-treemacs-config)) @@ -1952,7 +1991,7 @@ References: ```emacs-lisp (use-package emojify :straight t - :if (not (or my/lowpower my/is-termux)) + :if (and (display-graphic-p) (not (or my/lowpower my/is-termux))) :hook (after-init . global-emojify-mode)) ``` @@ -1964,7 +2003,7 @@ Ligature setup for the JetBrainsMono font. ```emacs-lisp (use-package ligature :straight (:host github :repo "mickeynp/ligature.el") - :if (not my/is-termux) + :if (display-graphic-p) :config (ligature-set-ligatures '( @@ -1980,7 +2019,8 @@ Ligature setup for the JetBrainsMono font. clojure-mode go-mode sh-mode - haskell-mode) + haskell-mode + web-mode) '("--" "---" "==" "===" "!=" "!==" "=!=" "=:=" "=/=" "<=" ">=" "&&" "&&&" "&=" "++" "+++" "***" ";;" "!!" "??" "?:" "?." "?=" "<:" ":<" ":>" ">:" "<>" "<<<" ">>>" @@ -2003,6 +2043,7 @@ Ligature setup for the JetBrainsMono font. ```emacs-lisp (use-package all-the-icons + :if (display-graphic-p) :straight t) ``` @@ -2023,7 +2064,7 @@ Highlight indent guides. ```emacs-lisp (use-package highlight-indent-guides :straight t - :if (not my/lowpower) + :if (not (or my/lowpower my/remote-server)) :hook ( (prog-mode . highlight-indent-guides-mode) (vue-mode . highlight-indent-guides-mode) @@ -2136,7 +2177,7 @@ Display icons for files. ```emacs-lisp (use-package all-the-icons-dired :straight t - :if (not (or my/lowpower my/slow-ssh)) + :if (not (or my/lowpower my/slow-ssh (not (display-graphic-p)))) :hook (dired-mode . (lambda () (unless (string-match-p "/gnu/store" default-directory) (all-the-icons-dired-mode)))) @@ -2249,6 +2290,13 @@ Some other optimization settings: tramp-file-name-regexp)) ``` +Set the default shell to `bin/bash` for TRAMP or on a remote server. + +```emacs-lisp +(when (or my/remote-server my/slow-ssh) + (setq explicit-shell-file-name "/bin/bash")) +``` + Also, here is a hack to make TRAMP find `ls` on Guix: ```emacs-lisp @@ -2390,6 +2438,7 @@ Open a terminal in the lower third of the frame with the `` ` `` key. (kill-buffer (current-buffer)) (select-window vterm-window)) (vterm-other-window "vterm-subterminal")))) + (unless my/slow-ssh (general-nmap "`" 'my/toggle-vterm-subteminal) (general-nmap "~" 'vterm)) @@ -2509,6 +2558,7 @@ Use the built-in org mode. ```emacs-lisp (use-package org :straight t + :if (not my/remote-server) :defer t :config (setq org-startup-indented t) @@ -2884,7 +2934,7 @@ Used files ```emacs-lisp (setq org-directory (expand-file-name "~/Documents/org-mode")) -(setq org-agenda-files '("inbox.org" "projects.org" "work.org")) +(setq org-agenda-files '("inbox.org" "projects.org" "work.org" "sem-11.org" "life.org")) ;; (setq org-default-notes-file (concat org-directory "/notes.org")) ``` @@ -2903,7 +2953,9 @@ Refile targets ```emacs-lisp (setq org-refile-targets '(("projects.org" :maxlevel . 2) - ("work.org" :maxlevel . 2))) + ("work.org" :maxlevel . 2) + ("sem-11.org" :maxlevel . 3) + ("life.org" :maxlevel . 2))) (setq org-refile-use-outline-path 'file) (setq org-outline-path-complete-in-steps nil) ``` @@ -3235,6 +3287,7 @@ A template looks like this: ```emacs-lisp (use-package org-journal :straight t + :if (not my/remote-server) :after org :config (setq org-journal-dir (concat org-directory "/journal")) @@ -3305,7 +3358,8 @@ References: (use-package org-roam :straight (:host github :repo "org-roam/org-roam" - :files (:defaults "extensions/*.el")) + :files (:defaults "extensions/*.el")) + :if (not my/remote-server) :after org :init (setq org-roam-directory (concat org-directory "/roam")) @@ -3392,6 +3446,7 @@ As of now, this package loads Helm on start. To avoid this, I have to exclude He ```emacs-lisp (use-package org-ref :straight (:files (:defaults (:exclude "*helm*"))) + :if (not my/remote-server) :init (setq org-ref-completion-library 'org-ref-ivy-cite) (setq bibtex-dialect 'biblatex) @@ -3698,6 +3753,7 @@ Doing presentations with [org-present](https://github.com/rlister/org-present). (use-package org-present :straight (:host github :repo "rlister/org-present") + :if (not my/remote-server) :commands (org-present) :config (general-define-key @@ -3716,8 +3772,7 @@ Doing presentations with [org-present](https://github.com/rlister/org-present). (setq-local org-format-latex-options (plist-put org-format-latex-options :scale (* org-present-text-scale my/org-latex-scale 0.5))) - (org-latex-preview '(16)) - (tab-bar-mode 0))) + (org-latex-preview '(16)))) (add-hook 'org-present-mode-quit-hook (lambda () (blink-cursor-mode 1) @@ -3728,12 +3783,16 @@ Doing presentations with [org-present](https://github.com/rlister/org-present). (display-line-numbers-mode 1) (hide-mode-line-mode 0) (setq-local org-format-latex-options (plist-put org-format-latex-options :scale my/org-latex-scale)) - (org-latex-preview '(64)) - (tab-bar-mode 1)))) + (org-latex-preview '(64))))) ``` -### TOC {#toc} +### Tools {#tools} + +Various small packages. + + +#### TOC {#toc} Make a TOC inside the org file. @@ -3746,6 +3805,7 @@ References: ```emacs-lisp (use-package org-make-toc :after (org) + :if (not my/remote-server) :commands (org-make-toc org-make-toc-insert @@ -3755,6 +3815,17 @@ References: ``` +#### Screenshots {#screenshots} + +A nice package to make screenshots and insert them to the Org document. + +```emacs-lisp +(use-package org-attach-screenshot + :commands (org-attach-screenshot) + :straight t) +``` + + ### System configuration {#system-configuration} Functions used across my literate config files. @@ -3947,7 +4018,7 @@ References: ```emacs-lisp (use-package lsp-mode :straight t - :if (not (or my/slow-ssh my/is-termux)) + :if (not (or my/slow-ssh my/is-termux my/remote-server)) :hook ( (typescript-mode . lsp) (vue-mode . lsp) @@ -4000,6 +4071,7 @@ Origami should've leveraged LSP folding, but it was too unstable at the moment I ;; (add-hook 'lsp-after-open-hook #'lsp-origami-try-enable)) (use-package lsp-treemacs + :after (lsp) :straight t :commands lsp-treemacs-errors-list) ``` @@ -4076,6 +4148,7 @@ References: (use-package tree-sitter :straight t + :if (not my/remote-server) :hook ((typescript-mode . my/tree-sitter-if-not-mmm) (js-mode . my/tree-sitter-if-not-mmm) (python-mode . tree-sitter-mode) @@ -4204,10 +4277,12 @@ References: ``` -#### CHECK (OFF) Format-all {#off--format-all} +#### Reformatter {#reformatter} + +A general-purpose package to run formattters on files. While the most popular formatters are already packaged for Emacs, those that aren't can be invoked with this package. ```emacs-lisp -(use-package format-all +(use-package reformatter :straight t) ``` @@ -4870,7 +4945,6 @@ References: - [LanguageTool homepage](https://languagetool.org/) - [LanguageTool http server](https://dev.languagetool.org/http-server) -- [LanguageTool for Emacs repo](https://github.com/mhayashi1120/Emacs-langtool) @@ -4879,7 +4953,7 @@ References: :straight t :commands (langtool-check) :config - (setq langtool-language-tool-server-jar "/home/pavel/Programs/LanguageTool-5.1/languagetool-server.jar") + (setq langtool-language-tool-server-jar "/home/pavel/bin/LanguageTool-5.4/languagetool-server.jar") (setq langtool-mother-tongue "ru") (setq langtool-default-language "en-US")) @@ -5358,6 +5432,18 @@ A function to start up [TensorBoard](https://www.tensorflow.org/tensorboard). ``` +### Lua {#lua} + +```emacs-lisp +(use-package lua-mode + :straight t + :mode "\\.lua\\'" + :hook (lua-mode . smartparens-mode)) + +(my/set-smartparens-indent 'lua-mode) +``` + + ### JSON {#json} ```emacs-lisp @@ -5371,6 +5457,36 @@ A function to start up [TensorBoard](https://www.tensorflow.org/tensorboard). ``` +### SQL {#sql} + +[sql-formatter](https://github.com/zeroturnaround/sql-formatter) is a nice JavaScript package for pretty-printing SQL queries. It is not packaged for Emacs, so the easiest way to use it seems to be to define a custom formatter via [reformatter](https://github.com/purcell/emacs-reformatter). + +Also, I've a simple function to switch dialects because I often alternate between them. + +So far I didn't find a nice SQL client for Emacs, but I occasionally run SQL queries in Org Mode, so this qute package is handy. + +```emacs-lisp +(setq my/sqlformatter-dialect-choice + '("db2" "mariadb" "mysql" "n1ql" "plsql" "postgresql" "redshift" "spark" "sql" "tsql")) + +(setq my/sqlformatter-dialect "postgresql") + +(defun my/sqlformatter-set-dialect () + "Set dialect for sql-formatter" + (interactive) + (setq my/sqlformatter-dialect + (completing-read "Dialect: " my/sqlformatter-dialect-choice))) + +(reformatter-define sqlformat + :program (executable-find "sql-formatter") + :args `("-l" ,my/sqlformatter-dialect)) + +(my-leader-def + :keymaps '(sql-mode-map) + "rr" #'sqlformat-buffer) +``` + + ### YAML {#yaml} ```emacs-lisp @@ -5516,7 +5632,7 @@ Open a file managed by yadm. My notmuch config now resides in [Mail.org]({{< relref "Mail" >}}). ```emacs-lisp -(unless my/is-termux +(unless (or my/is-termux my/remote-server) (load-file (expand-file-name "mail.el" user-emacs-directory))) ``` @@ -5532,12 +5648,13 @@ Using my own fork until the modifications are merged into master. ```emacs-lisp (use-package elfeed :straight (:repo "SqrtMinusOne/elfeed" :host github) + :if (not my/remote-server) :commands (elfeed) :init (my-leader-def "ae" 'elfeed) :config (setq elfeed-db-directory "~/.elfeed") - (setq elfeed-enclosure-default-dir (expand-file-name "~")) + (setq elfeed-enclosure-default-dir (expand-file-name "~/Downloads")) (advice-add #'elfeed-insert-html :around (lambda (fun &rest r) @@ -5655,6 +5772,7 @@ References: ```emacs-lisp (use-package emms :straight t + :if (not my/remote-server) :commands (emms-smart-browse emms-browser emms-add-url @@ -5683,11 +5801,11 @@ References: ;; MPV setup <> ;; evil-lion and evil-commentary shadow some gX bindings - (add-hook 'emms-browser-mode-hook - (lambda () - (evil-lion-mode -1) - ;; (evil-commentary-mode -1) - )) + ;; (add-hook 'emms-browser-mode-hook + ;; (lambda () + ;; (evil-lion-mode -1) + ;; (evil-commentary-mode -1) + ;; )) ;; I have everything I need in polybar (emms-mode-line-mode -1) (emms-playing-time-display-mode -1) @@ -5742,7 +5860,7 @@ After all this is done, run `M-x emms-cache-set-from-mpd-all` to set cache from [mpv](https://mpv.io/) is a decent media player, which has found a place in this configuration because it integrates with youtube-dl. ```emacs-lisp -(add-to-list 'emms-player-list 'emms-player-mpv) +(add-to-list 'emms-player-list 'emms-player-mpv t) ``` Also a custom regex. My demands for MPV include running `youtube-dl`, so there is a regex that matches youtube.com or some of the video formats. @@ -5783,7 +5901,7 @@ Now `emms-add-url` should work on YouTube URLs just fine. Just keep in mind that ##### Cache cleanup {#cache-cleanup} -All added URLs reside in the EMMS cache after being played. I don't want them to stay there for a long time, so here is a handy function to clean it. +All the added URLs reside in the EMMS cache after being played. I don't want them to stay there for a long time, so here is a handy function to clean it. ```emacs-lisp (defun my/emms-cleanup-urls () @@ -6059,7 +6177,7 @@ References: (shell-command-to-string (format "curl -L %s --output %s" tldr-source-zip-url tldr-saved-zip-path)) (when (file-exists-p "/tmp/tldr") (delete-directory "/tmp/tldr" t)) - (shell-command-to-string (format "unzip -d /tmp/tldr/ %s" tldr-saved-zip-path) nil nil) + (shell-command-to-string (format "unzip -d /tmp/tldr/ %s" tldr-saved-zip-path)) (when (file-exists-p tldr-directory-path) (delete-directory tldr-directory-path 'recursive 'no-trash)) (shell-command-to-string (format "mv %s %s" "/tmp/tldr/tldr-main" tldr-directory-path)))) @@ -6110,6 +6228,8 @@ Finally, there is also an Emacs plugin for [devdocs.io](https://devdocs.io). I use [pass](https://www.passwordstore.org/) as my password manager. Expectedly, there is Emacs frontend for it. +Although I use [this rofi frontend](https://github.com/carnager/rofi-pass) for actually inserting passwords. + ```emacs-lisp (use-package pass :straight t @@ -6249,6 +6369,7 @@ Tecosaur's plugin to make beautiful code screenshots. ```emacs-lisp (use-package screenshot :straight (:repo "tecosaur/screenshot" :host github :files ("screenshot.el")) + :if (display-graphic-p) :commands (screenshot) :init (my-leader-def "S" 'screenshot)) @@ -6340,14 +6461,14 @@ In order for this to work in Guix, a service is necessary - [Discord rich presen :if (and (or (string= (system-name) "indigo") (string= (system-name) "eminence")) - (not my/slow-ssh)) + (not my/slow-ssh) + (not my/remote-server)) :config (elcord-mode) (add-to-list 'elcord-boring-buffers-regexp-list (rx bos (+ num) "-" (+ num) "-" (+ num) ".org" eos)) (add-to-list 'elcord-boring-buffers-regexp-list - (rx bos (= 14 num) "-" (* not-newline) ".org" eos)) - ) + (rx bos (= 14 num) "-" (* not-newline) ".org" eos))) ``` diff --git a/content/configs/Guix.md b/content/configs/Guix.md index 0a72480..4e866d0 100644 --- a/content/configs/Guix.md +++ b/content/configs/Guix.md @@ -20,7 +20,6 @@ References:
Table of Contents
-- [Contents](#contents) - [Profiles](#profiles) - [Activate profiles](#activate-profiles) - [Update profiles](#update-profiles) @@ -49,34 +48,6 @@ References: -## Contents {#contents} - -- [Contents](#contents) -- [Profiles](#profiles) - - [Activate profiles](#activate-profiles) - - [Update profiles](#update-profiles) -- [Channels](#channels) -- [Systems](#systems) - - [Base configuration](#base-configuration) - - [indigo](#indigo) - - [eminence](#eminence) - - [azure](#azure) -- [System installation](#system-installation) - - [Preparation](#preparation) - - [Installation](#installation) - - [After installation](#after-installation) -- [Misc software & notes](#misc-software-and-notes) - - [VPN](#vpn) - - [vpn-start](#vpn-start) - - [vpn-stop](#vpn-stop) - - [flatpak](#flatpak) - - [conda](#conda) - - [Slack](#slack) - - [virt-manager](#virt-manager) - - [wakatime-cli](#wakatime-cli) - - [Manifest](#manifest) - - ## Profiles {#profiles} A profile is a way to group Guix packages. Amongst its advantages, profiles can be defined by manifests, which in turn can be stored in VCS. @@ -535,7 +506,7 @@ Fortunately, David Wilson has made [a repository](https://github.com/SystemCraft When an ISO is there, we have to write it on a USB stick. Run `sudo fdisk -l` to get a list of disks. -The approach in the official instruction is to create a bootable USB with `dd`: +The approach given in the official instruction is to create a bootable USB with `dd`: ```text sudo dd of=/dev/sdxX if= status=progress && sync @@ -553,7 +524,7 @@ Going further, the official instructions for installation & SystemCrafters wiki After the installation, the strategy is as follows. -Set a password for the main user (pavel). Login with openbox to get a tolerable interface because the i3 default config is horrible. +Set a password for the main user (pavel). Login with openbox to get a tolerable interface because i3's default config is horrible. [Connect to the internet](https://guix.gnu.org/en/manual/en/html%5Fnode/Keyboard-Layout-and-Networking-and-Partitioning.html#Keyboard-Layout-and-Networking-and-Partitioning). @@ -600,9 +571,9 @@ Don't forget to install `JetBrainsMono Nerd Font`. | system | openvpn-update-resolve-conf | | system | vpnc | -I'm not sure how to properly spin up VPN on Guix, so here is what I'm doing now, after some trial and error. +I'm not sure how to properly spin up VPN on Guix, so here is what ended I'm doing after some trial and error. -I'm currently using CyberGhost VPN. `~/.vpn` folder stores its OpenVPN config (`openvpn.ovpn`), modified as follows: +I'm using CyberGhost VPN. `~/.vpn` folder stores its OpenVPN config (`openvpn.ovpn`), modified as follows: - paths to `ca`, `cert` and `key` are made absolute @@ -707,9 +678,9 @@ It is packaged for GNU Guix, although the definition has its fair share of worka First, it's impossible to perform `conda init` to patch files like `.bashrc`, because the command is hell-bent on modifying `/gnu/store/`. So I do this manually, look for the `init_conda` procedures in [Console.org]({{< relref "Console" >}}). -Second, base environment root is `/gnu/store`, so don't install anything there. +Second, the base environment has `/gnu/store/...` as a root, so don't install anything there (and don't run `conda` with superuser rights!). -Third, by default it tries to create envronments in `/gnu/store`. I think it's enough to create one environment like this to fix it: +Third, by default it tries to create envronments in `/gnu/store`. It's enough to create one environment like this to fix it: ```sh mkdir -p ~/.conda/envs @@ -723,7 +694,7 @@ Finally, I also want to have an ability to use global npm. Some settings for tha So here is a script to set up conda hooks: ```bash -# Get writable conda envs with npm & without +# Get writable conda envs with npm & without it readarray -t CONDA_ENVS_ALL <<< $(conda env list --json | jq '.envs[]') CONDA_ENVS_NPM=() CONDA_ENVS_NO_NPM=() diff --git a/content/configs/Guix.md~ b/content/configs/Guix.md~ index 69a2b7a..0a72480 100644 --- a/content/configs/Guix.md~ +++ b/content/configs/Guix.md~ @@ -598,6 +598,7 @@ Don't forget to install `JetBrainsMono Nerd Font`. |----------|-----------------------------| | system | openvpn | | system | openvpn-update-resolve-conf | +| system | vpnc | I'm not sure how to properly spin up VPN on Guix, so here is what I'm doing now, after some trial and error. @@ -715,6 +716,8 @@ mkdir -p ~/.conda/envs conda create -p ~/.conda/envs/test ``` +Fourth, you may need to unset `$PYTHONPATH` if you have any global packages installed, otherwise Python from anaconda will try to import them instead of the conda versions. + Finally, I also want to have an ability to use global npm. Some settings for that are located in [Console.org](Console). Here we want to unset `NPM_CONFIG_USERCONFIG` if there is npm available in the environment. So here is a script to set up conda hooks: diff --git a/content/configs/Mail.md b/content/configs/Mail.md index aca7abe..c8bbe86 100644 --- a/content/configs/Mail.md +++ b/content/configs/Mail.md @@ -76,6 +76,8 @@ davmail.server=true davmail.mode=Auto davmail.url=https://mail.etu.ru/owa/ +davmail.server.certificate.hash=0C:9E:CF:D3:62:26:DB:FA:F1:EE:36:9D:60:E7:31:71:CF:1F:92:85 + davmail.caldavPort=1080 davmail.imapPort=1143 davmail.ldapPort=1389 diff --git a/content/configs/README.md~ b/content/configs/README.md~ index dd4f10e..89a402e 100644 --- a/content/configs/README.md~ +++ b/content/configs/README.md~ @@ -13,7 +13,7 @@ The majority of the software is configured with [literate configuration](https:/ The files themselves are managed and deployed via [yadm](https://yadm.io/), but I mostly use Org Mode rich noweb whenever I can instead of what yadm offers. -My current GNU/Linux distribution is [GNU Guix](https://guix.gnu.org/). In the context of this repo, Guix allows me to list all the used programs in manifests, which means I have the same set of programs across multiple machines. Look for the tables with "Guix dependency" in the header. +My current GNU/Linux distribution is [GNU Guix](https://guix.gnu.org/). In the context of this repo, Guix allows me to list all the used programs in manifests, which means I have the same set of programs across multiple machines. Look for tables with "Guix dependency" in the header. Literate configuration files: diff --git a/public/configs/console/index.html b/public/configs/console/index.html index 6b8637a..f69926a 100644 --- a/public/configs/console/index.html +++ b/public/configs/console/index.html @@ -400,6 +400,11 @@ alias cii="ex bind -M insert \eh backward-char bind -M insert \ew forward-word bind -M insert \eb backward-word +

Functions

+

A small function to open the file with $EDITOR.

+
function e
+    eval $EDITOR $argv
+end
 

Nushell

diff --git a/public/configs/emacs/index.html b/public/configs/emacs/index.html index 4203e0c..67cac72 100644 --- a/public/configs/emacs/index.html +++ b/public/configs/emacs/index.html @@ -216,6 +216,7 @@
  • Configuration
  • Subterminal
  • Dired integration
  • +
  • With-editor integration
  • Eshell
  • @@ -381,10 +382,15 @@
  • Emacs Lisp +
  • +
  • Common lisp +
  • -
  • Common lisp
  • Clojure
  • Hy
  • Scheme
  • @@ -777,7 +783,8 @@ comint git-timemachine magit - prodigy))) + prodigy + slime)))

    More keybindings

    The main keybindings setup is positioned after evil mode to take the latter into account.

    Escape key

    @@ -877,6 +884,7 @@ "h"'previous-buffer"k"'kill-buffer"b"'persp-ivy-switch-buffer + "r"'revert-buffer"u"'ibuffer)

    xref

    Some keybindings for xref and go to definition.

    @@ -1371,7 +1379,9 @@ (use-package yasnippet :straight t :config - (setq yas-snippet-dirs `(,(concat (expand-file-name user-emacs-directory) "snippets"))) + (setq yas-snippet-dirs + `(,(concat (expand-file-name user-emacs-directory) "snippets") + yasnippet-snippets-dir)) (setq yas-triggers-in-field t) (yas-global-mode 1)) @@ -2061,6 +2071,14 @@ :states '(normal) "gd"#'my/vterm-dired-other-window "gD"#'my/vterm-dired-replace)) +

    With-editor integration

    +

    A package used by Magit to use the current Emacs instance as the $EDITOR.

    +

    That is, with the help of this function, I can just write e <filename>, edit the file, and then return to the same vterm buffer. No more running vim inside Emacs.

    +
    (use-package with-editor
    +  :straight t
    +  :after (vterm)
    +  :config
    +  (add-hook 'vterm-mode-hook 'with-editor-export-editor))
     

    Eshell

    A shell written in Emacs lisp. I don’t use it as of now, but keep the config just in case.

    (defun my/configure-eshell ()
    @@ -2541,7 +2559,7 @@
     	  (todo "DONE")))
     	("Attended meetings" closed scheduled
     	 (and
    -	  (tags "meeting")
    +	  (tags-inherited "meeting")
     	  (todo "PASSED")))
     	("Done project tasks" closed deadline
     	 (and
    @@ -3420,10 +3438,6 @@ MimeType=x-scheme-handler/org-protocol
     
    - - - - @@ -3981,11 +3995,18 @@ MimeType=x-scheme-handler/org-protocol :after flycheck :config (flycheck-package-setup)) -
    General
    +
    General settings
    (add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
     ;; (add-hook 'emacs-lisp-mode-hook #'smartparens-strict-mode)
     (add-hook 'emacs-lisp-mode-hook #'lispy-mode)
     

    Common lisp

    +
    SLIME
    +
    (use-package slime
    +  :straight t
    +  :config
    +  (setq inferior-lisp-program "sbcl")
    +  (add-hook 'slime-repl-mode 'smartparens-mode))
    +
    General settings
    (add-hook 'lisp-mode-hook #'aggressive-indent-mode)
     ;; (add-hook 'emacs-lisp-mode-hook #'smartparens-strict-mode)
     (add-hook 'lisp-mode-hook #'lispy-mode)
    diff --git a/public/configs/guix/index.html b/public/configs/guix/index.html
    index b56a3c0..09ee9d5 100644
    --- a/public/configs/guix/index.html
    +++ b/public/configs/guix/index.html
    @@ -72,7 +72,6 @@
     
    Table of Contents
    -

    Contents

    -

    Profiles

    A profile is a way to group Guix packages. Amongst its advantages, profiles can be defined by manifests, which in turn can be stored in VCS.

    References:

    @@ -518,14 +475,14 @@ profiles=$*

    In my case, the provided ISO doesn’t work because of the Libre kernel.

    Fortunately, David Wilson has made a repository with a toolchain to make an ISO with the full kernel. In case it won’t be an option, the nonguix repo also has instructions on how to do that.

    When an ISO is there, we have to write it on a USB stick. Run sudo fdisk -l to get a list of disks.

    -

    The approach in the official instruction is to create a bootable USB with dd:

    +

    The approach given in the official instruction is to create a bootable USB with dd:

    sudo dd of=/dev/sdxX if=<path-to-iso> status=progress && sync
     

    However, I couldn’t make it work for some strange reason. Fortunately, gnome-disk-utility was able to produce a bootable USB.

    Installation

    Going further, the official instructions for installation & SystemCrafters wiki entry are pretty good, so it’s not necessary to repeat them here.

    After installation

    After the installation, the strategy is as follows.

    -

    Set a password for the main user (pavel). Login with openbox to get a tolerable interface because the i3 default config is horrible.

    +

    Set a password for the main user (pavel). Login with openbox to get a tolerable interface because i3’s default config is horrible.

    Connect to the internet.

    Clone the dotfiles repo:

    mkdir Code
    @@ -584,8 +541,8 @@ guix clone https://github.com/SqrtMinusOne/dotfiles.git
     
     
     
    TODODo not enable for every Svelte mode
    TODO make expand div[disabled] as
    -

    I’m not sure how to properly spin up VPN on Guix, so here is what I’m doing now, after some trial and error.

    -

    I’m currently using CyberGhost VPN. ~/.vpn folder stores its OpenVPN config (openvpn.ovpn), modified as follows:

    +

    I’m not sure how to properly spin up VPN on Guix, so here is what ended I’m doing after some trial and error.

    +

    I’m using CyberGhost VPN. ~/.vpn folder stores its OpenVPN config (openvpn.ovpn), modified as follows: