diff options
| -rw-r--r-- | files/emacs/.emacs.d/post-init.el | 81 | ||||
| -rw-r--r-- | home.scm | 15 | ||||
| -rw-r--r-- | system.scm | 7 |
3 files changed, 90 insertions, 13 deletions
diff --git a/files/emacs/.emacs.d/post-init.el b/files/emacs/.emacs.d/post-init.el index ebd061c..edb6dad 100644 --- a/files/emacs/.emacs.d/post-init.el +++ b/files/emacs/.emacs.d/post-init.el @@ -7,6 +7,87 @@ (require 'auth-source-pass) (auth-source-pass-enable) +(use-package abbrev + :ensure nil + :custom + (save-abbrevs nil) + :config + (defun emacs-solo/abbrev--replace-placeholders () + "Replace placeholders ###1###, ###2###, ... with minibuffer input. +If ###@### is found, remove it and place point there at the end." + (let ((cursor-pos nil)) + (save-excursion + (goto-char (point-min)) + (let ((loop 0) + (values (make-hash-table :test 'equal))) + (while (re-search-forward "###\\([0-9]+\\|@\\)###" nil t) + (setq loop (1+ loop)) + (let* ((index (match-string 1)) + (start (match-beginning 0)) + (end (match-end 0))) + (cond + ((string= index "@") + (setq cursor-pos start) + (delete-region start end)) + (t + (let* ((key (format "###%s###" index)) + (val (or (gethash key values) + (let ((input (read-string (format "Value for %s: " key)))) + (puthash key input values) + input)))) + (goto-char start) + (delete-region start end) + (insert val) + (goto-char (+ start (length val)))))))))) + (when cursor-pos + (goto-char cursor-pos)))) + + (define-abbrev-table 'global-abbrev-table + '(;; Arrows + ("ra" "→") + ("la" "←") + ("ua" "↑") + ("da" "↓") + + ;; HTML entities + ("nb" " ") + ("lt" "<") + ("gt" ">") + + ;; Markdown + ("cb" "```@\n\n```" + (lambda () (search-backward "@") (delete-char 1))) + + ;; ORG + ("ocb" "#+BEGIN_SRC @\n\n#+END_SRC" + (lambda () (search-backward "@") (delete-char 1))) + ("oheader" "#+TITLE: ###1###\n#+AUTHOR: ###2###\n#+EMAIL: ###3###\n#+OPTIONS: toc:nil\n" + emacs-solo/abbrev--replace-placeholders) + + ;; JS/TS snippets + ("imp" "import { ###1### } from '###2###';" + emacs-solo/abbrev--replace-placeholders) + ("fn" "function ###1### () {\n ###@### ;\n};" + emacs-solo/abbrev--replace-placeholders) + ("clog" "console.log(\">>> LOG:\", { ###@### })" + emacs-solo/abbrev--replace-placeholders) + ("cwarn" "console.warn(\">>> WARN:\", { ###@### })" + emacs-solo/abbrev--replace-placeholders) + ("cerr" "console.error(\">>> ERR:\", { ###@### })" + emacs-solo/abbrev--replace-placeholders) + ("afn" "async function() {\n \n}" + (lambda () (search-backward "}") (forward-line -1) (end-of-line))) + ("ife" "(function() {\n \n})();" + (lambda () (search-backward ")();") (forward-line -1) (end-of-line))) + ("esdeps" "// eslint-disable-next-line react-hooks/exhaustive-deps" + (lambda () (search-backward ")();") (forward-line -1) (end-of-line))) + ("eshooks" "// eslint-disable-next-line react-hooks/rules-of-hooks" + (lambda () (search-backward ")();") (forward-line -1) (end-of-line))) + + ;; React/JSX + ("rfc" "const ###1### = () => {\n return (\n <div>###2###</div>\n );\n};" + emacs-solo/abbrev--replace-placeholders)))) + (setopt tab-always-indent 'complete read-buffer-completion-ignore-case t read-file-name-completion-ignore-case t @@ -72,6 +72,8 @@ "alsa-utils" "pavucontrol" + "crawl" + "gimp" "zathura" @@ -97,19 +99,18 @@ (services (append (list - ;; Uncomment the shell you wish to use for your user: - ;(service home-fish-service-type) (service home-bash-service-type) (simple-service 'custom-bash-service home-bash-service-type (home-bash-extension - (variables - '(("PS1" . "\\u \\wλ "))) - (aliases - '(("dbus-sway" . "exec dbus-run-session -- sway"))) (bash-profile - `(,(local-file "/home/mitch/.guix-home/profile/etc/profile.d/flatpak.sh"))))) + `(,(local-file "/home/mitch/.guix-home/profile/etc/profile.d/flatpak.sh") + ,(plain-file "bash-sway-login" + (string-append + "if [ -z \"$WAYLAND_DISPLAY\" ] && [ \"$XDG_VTNR\" -eq 1 ]; then\n" + " exec dbus-run-session -- sway\n" + "fi\n")))))) (service home-dotfiles-service-type (home-dotfiles-configuration @@ -65,12 +65,7 @@ (guix-service-type config => (guix-configuration (inherit config) - (extra-options '("--max-jobs=4" "--cores=4")))) - (mingetty-service-type config => - (mingetty-configuration - (inherit config) - ;; Automatically log in as "guest". - (auto-login "mitch")))) + (extra-options '("--max-jobs=4" "--cores=4"))))) (list (service elogind-service-type) |
