diff options
author | Thanos Apollo <[email protected]> | 2025-02-04 16:47:11 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2025-02-04 16:47:11 +0200 |
commit | 70d17697c8527415a0d498520e11d8f7198a6996 (patch) | |
tree | 877069ff6666483ead2b453d883ad96dbc18eafa | |
parent | 25a0ef0b1e1a339fc9dd81e4a26d8838e1387625 (diff) |
emacs: Update theming, keymaps & add new watch var
-rw-r--r-- | .config/emacs/init.el | 231 |
1 files changed, 139 insertions, 92 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 8213892..a2fde66 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -37,16 +37,17 @@ (format "%s <%s>" user-full-name user-mail-address)) (defvar is-constantine (string= (system-name) "constantine")) -(defvar is-hermes (string= (system-name) "hermes")) +(defvar is-alexios (string= (system-name) "alexios")) (defvar is-phone (string= (system-name) "localhost")) -(defvar is-uranus (string= (system-name) "uranus")) +(defvar is-uranus (string= (system-name) "theodora")) ;; Font -(custom-set-faces - (if is-hermes '(default ((t (:inherit nil :height 130 :family "Fira Mono")))) - '(default ((t (:inherit nil :height 160 :family "Fira Mono"))))) - '(org-modern-symbol ((t (:inherit t :family "Iosevka")))) - '(italic ((t (:inherit t :family "Iosevka"))))) +(let ((font-size (if is-alexios 130 160))) + (custom-set-faces + `(default ((t (:inherit nil :height ,font-size :family "Fira Mono")))) + '(org-modern-symbol ((t (:inherit t :family "Iosevka")))) + `(variable-pitch ((t (:inherit t :family "Fira Mono" :height ,font-size)))) + '(italic ((t (:inherit t :family "Iosevka")))))) ;; Autoinsert (auto-insert-mode 1) @@ -61,7 +62,7 @@ ;; Imenu ;; Enable use-package support for imenu -;; NOTE: Load this before use-package! +;;; !Load this before use-package! (setf use-package-enable-imenu-support t) (require 'imenu) @@ -157,14 +158,9 @@ (define-key grep-mode-map (kbd "C-o") 'thanos/compile-goto-error) -(defvar-keymap thanos/search-map - "g" #'grep-find - "l" #'lgrep - "f" #'find-name-dired - "o" #'thanos/occur - "C-o" #'occur) - -(global-set-key (kbd "C-c s") thanos/search-map) +(global-set-key (kbd "M-s g") #'grep-find) +(global-set-key (kbd "M-s M-o") #'thanos/occur) +(global-set-key (kbd "M-s f") #'find-name-dired) (setf browse-url-browser-function 'browse-url-generic browse-url-generic-program "icecat" @@ -175,6 +171,22 @@ disabled-command-function nil ;; Enable all commands url-privacy-level 'high) +(defun thanos/watch-input-method (symbol new-value operation where) + "Watch for changes in `current-input-method' & update `ispell-dictionary'." + (when (eq operation 'set) + (cond + ((string-equal new-value "greek-polytonic") + (setq ispell-dictionary "el_GR") + ;; Refresh flyspell + (flyspell-mode 0) + (flyspell-mode 1)) + (t + (setq ispell-dictionary "en_US") + (flyspell-mode 0) + (flyspell-mode 1))))) + +(add-variable-watcher 'current-input-method 'thanos/watch-input-method) + (setf calendar-date-style 'european) (defun thanos/add-custom-keywords () @@ -197,14 +209,14 @@ :ensure t :config (setf org-directory "~/org/" - org-agenda-files '("~/org/seminars.org" "~/org/lectures.org") + org-agenda-files (directory-files-recursively "~/org" ".*") org-default-notes-file (expand-file-name "notes.org" org-directory) org-ellipsis " ▼" org-log-done 'time org-hide-emphasis-markers nil ;;change to t to hide emphasis markers org-table-convert-region-max-lines 20000 org-log-done 'time - org-todo-keywords '((sequence "TODO(t)" "SEMINAR(s)" "LECTURE(l)" "DONE(d)"))) + org-todo-keywords '((sequence "TODO" "DONE"))) (setf org-imenu-depth 3) @@ -267,7 +279,6 @@ (org-remove-inline-images) (org-present-show-cursor) (org-present-read-write))))) -;; (completion-styles-alist ) ;; Export (defun thanos/org-html-remove-curly-braces (text backend info) @@ -375,7 +386,7 @@ (add-hook 'enable-theme-functions #'theme-invisible-dividers) -;;;; Theming ;;;; +;;; Theming (setf inhibit-startup-message t initial-scratch-message nil) @@ -388,11 +399,8 @@ (column-number-mode) (global-display-line-numbers-mode 1) -;; Transparency (add-to-list 'default-frame-alist '(alpha-background . 85)) -;; Theming - (defun thanos/terminal-theming () "Customize theming when laucning Emacs as TUI." (unless (display-graphic-p (selected-frame)) @@ -415,24 +423,19 @@ (let* ((book-path (read-file-name "Book: " "~/Library/"))) (org-insert-link nil book-path (file-name-base book-path)))) -(use-package org-modern - :ensure t - :config - (setf org-modern-table nil - org-modern-todo nil - org-modern-tag nil - org-modern-timestamp nil - org-modern-star 'replace - org-modern-list '((?+ . "•") - (?- . "•")) - org-modern-replace-stars "☧") - :hook ((org-mode . org-modern-mode))) - -;; Create notes directory for org-roam -(unless (file-exists-p "~/Notes") - (make-directory "~/Notes")) - -(unless (or is-phone is-uranus) +(when (display-graphic-p) + (use-package org-modern + :ensure t + :config + (setf org-modern-table nil + org-modern-todo nil + org-modern-tag nil + org-modern-timestamp nil + org-modern-star 'replace + org-modern-list '((?+ . "•") + (?- . "•")) + org-modern-replace-stars "☧") + :hook ((org-mode . org-modern-mode))) (use-package modus-themes :ensure t :config @@ -448,11 +451,11 @@ ;; Palette overrides (setf modus-vivendi-palette-overrides '((fg-line-number-active cyan-intense) - ;; (bg-main "#1d2021") ;;grubox-hard + ;; (bg-main "#1d2021") ;; grubox-hard ;; (bg-main "#191919") ;; 1337 ;; (bg-main "#1d1f21") ;; tomorrow night ;; (bg-main "#151515") ;; jazz - ;; (bg-main "#0C0C0C") ;; random black + (bg-main "#0C0C0C") ;; random black ;; (bg-main "#1b1d1e") ;; Iosevka ;; (bg-main "#0D0E16") ;; Acario ;; (bg-main "#1c1e1f") ;; molokai @@ -473,6 +476,9 @@ (prose-todo green-intense) (prose-done bg-term-white) (fg-prompt yellow-faint) + (bg-prose-block-contents bg-magenta-nuanced) + (bg-prose-block-delimiter bg-lavender) + (fg-prose-block-delimiter fg-main) ,@modus-themes-preset-overrides-intense)) ;; Headings (setf modus-themes-headings @@ -558,9 +564,28 @@ (let ((branch (thanos/vc-git-branch))) (vc-git-command nil 0 nil "branch" "-D" branch) (message "Branch `%s' deleted." branch))) + + (defun thanos/git-update-all-remotes () + "Update all remotes for current repository" + (interactive) + (let ((input-string (shell-command-to-string "git remote -v")) + (regex + "^\\([^ \t]+\\)[ \t]+\\(?:[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\(?::[0-9]*\\)?\\):\\([^ ]+\\)") + (pos 0) + (remote-names '())) + (cl-loop while (string-match regex input-string pos) + do (setq pos (match-end 0)) + for remote-name = (match-string 1 input-string) + unless (member remote-name remote-names) + do (push remote-name remote-names)) + (cl-loop for remote in remote-names + do (async-shell-command (format "git push -u %s" remote) + (format "Push for: %s" remote))))) :bind (:map vc-prefix-map - ("b d" . 'vc-git-delete-branch))) + ("b d" . 'vc-git-delete-branch) + ("p" . 'thanos/git-update-all-remotes)) + :hook ((vc-git-log-edit-mode . flyspell-mode))) (use-package magit :defer t @@ -612,7 +637,7 @@ (eat-mode . (lambda () (visual-line-mode -1))))) (use-package shell - :ensure t + :defer t :config (defun thanos/shell (n) "Create or switch to a shell buffer." @@ -627,43 +652,14 @@ ("C-l" . 'comint-clear-buffer)) :hook ((shell-mode . (lambda () (display-line-numbers-mode -1))))) -(defvar thanos/aliases - '((ll . "ls -lah") - (clear . clear-scrollback))) - -(defun thanos/set-eshell-aliases (aliases) - "Set ALIASES as eshell aliases." - ;; Remove aliases file - (when (and eshell-aliases-file - (file-exists-p eshell-aliases-file)) - (delete-file eshell-aliases-file)) - (mapc (lambda (alias) - (let ((name (symbol-name (car alias))) - (command (cdr alias))) - (eshell/alias name - (cond - ((stringp command) command) - ((symbolp command) (symbol-name command)) - (t (error "Unsupported alias command type")))))) - aliases)) - -(defun eshell/o (file) - "Open FILE." - (find-file file)) - -(defun thanos/eshell-clear () - "Interactive call for clear-scrollback." - (interactive) - (eshell/clear-scrollback)) - -(defun thanos/eshell-preview-insert () - (interactive) - (completion-preview-insert) - (delete-char -1)) +(use-package term + :defer t + :hook ((term-mode . (lambda () (display-line-numbers-mode 0))))) (use-package esh-mode - :ensure nil + :defer t :config + ;; Prompt (defun eshell-git-info () "Return a string with git info." (when (eq (call-process "git" nil nil nil "rev-parse" "--is-inside-work-tree") 0) @@ -672,14 +668,16 @@ (string-match-p "^error" branch-raw)) "Unknown" (string-trim branch-raw))) - (dirty (not (string= "" (string-trim (shell-command-to-string "git status --porcelain"))))) + (dirty (not + (string= "" (string-trim (shell-command-to-string "git status --porcelain"))))) (dirty-info (if dirty " ✎" " ✔"))) (concat (propertize "⎇ " 'face 'modus-themes-fg-green-warmer) (propertize branch 'face 'modus-themes-fg-magenta-warmer) - (propertize dirty-info 'face (if dirty 'modus-themes-fg-red 'modus-themes-fg-green)))))) + (propertize dirty-info 'face + (if dirty 'modus-themes-fg-red 'modus-themes-fg-green)))))) (defun eshell-prompt-multiline () - "Eshell Git prompt inspired by spaceship-prompt." + "Eshell Multiline Git prompt." (let ((separator (propertize " | " 'face 'font-lock-comment-face)) (hr (propertize (concat "\n" (make-string (/ (window-total-width) 2) ?─) "\n") 'face 'font-lock-comment-face)) (dir (propertize (format "%s" (abbreviate-file-name (eshell/pwd))) 'face 'modus-themes-fg-yellow-warmer)) @@ -688,11 +686,47 @@ (sign (if (= (user-uid) 0) (propertize "\n#" 'face 'modus-themes-fg-blue-intense) (propertize "\nλ" 'face 'modus-themes-fg-red-warmer)))) - ;; Build prompt (concat hr dir separator git-info separator time sign " "))) (setf eshell-prompt-function 'eshell-prompt-multiline eshell-highlight-prompt nil) + ;; Aliases + (defun eshell/o (file) + "Open FILE." + (find-file file)) + + (defvar thanos/aliases + '((ll . "ls -lah") + (clear . clear-scrollback))) + + (defun thanos/set-eshell-aliases (aliases) + "Set ALIASES as eshell aliases." + ;; Remove aliases file + (when (and eshell-aliases-file + (file-exists-p eshell-aliases-file)) + (delete-file eshell-aliases-file)) + (mapc (lambda (alias) + (let ((name (symbol-name (car alias))) + (command (cdr alias))) + (eshell/alias name + (cond + ((stringp command) command) + ((symbolp command) (symbol-name command)) + (t (error "Unsupported alias command type")))))) + aliases)) + + ;; Rebinds + (defun thanos/eshell-clear () + "Interactive call for clear-scrollback." + (interactive) + (eshell/clear-scrollback)) + + (defun thanos/eshell-preview-insert () + (interactive) + (completion-preview-insert) + ;; This funciton just deletes the extra space inserted after + ;; completion. + (delete-char -1)) :bind (("C-c e" . eshell) :map eshell-mode-map ("C-l" . 'thanos/eshell-clear) @@ -731,21 +765,32 @@ (defun thanos/erc-login () "Login to libera.chat" (interactive) - (erc :server "uranus" :port 5555 + (erc :server "theodora" :port 5500 :nick "thanosapollo" :user "thanosapollo" :password (password-store-get "znc/admin"))) - :bind (("C-c E" . 'erc-libera) + :bind (("C-c E" . 'thanos/erc-login) :map erc-mode-map ("C-c RET" . 'erc-cmd-QUERY))) +(use-package telega + :defer t + :config + (global-emojify-mode-line-mode) + :hook ((telega-chat-mode . (lambda () + (display-line-numbers-mode 0) + (emojify-mode 1))) + (telega-root-mode . (lambda () + (display-line-numbers-mode 0) + (emojify-mode 1))))) + (use-package sudo-edit :ensure t :config (setf sudo-edit-local-method "sudo")) ;; My packages -(when (or is-constantine is-hermes) +(when (or is-constantine is-alexios) (use-package yeetube :init (define-prefix-command 'thanos/yeetube-map) :vc t @@ -818,8 +863,8 @@ :config (setf gnosis-vc-auto-push t gnosis-mcq-display-choices nil - gnosis-image-width (and is-hermes 150) - gnosis-image-height (and is-hermes 150)) + gnosis-image-width (and is-alexios 150) + gnosis-image-height (and is-alexios 150)) (gnosis-modeline-mode) (setf gnosis-custom-values '((:deck "Bulgarian" (:amnesia 0.55 :proto (0 1 3))) @@ -841,8 +886,10 @@ :config (setf org-gnosis-dir "~/Notes" org-gnosis-journal-templates - '(("Default" - "* Daily Notes\n\n* Goals\n+ [] Πρωινὴ Προσευχή\n+ [] Ἑσπερινή Προσευχή\n\n* Extras")) + '(("Default" (lambda () + (format "\n* Body stats\nweight:\n\n* Daily Notes\n\n* Goals\n%s" + (org-gnosis-todos)))) + ("Empty" (lambda () ""))) org-gnosis-show-tags t) (defun thanos/org-open-at-point () @@ -1006,7 +1053,7 @@ (setq gptel-backend (gptel-make-ollama "Ollama" :host (if is-constantine "localhost:11434" "constantine:11434") :stream t - :models '("llama3.2:latest" "dolphin-phi" "dolphin-llama3:latest"))) + :models '("deepseek-r1:latest" "llama3.2:latest"))) (gptel-make-anthropic "Claude" :stream t @@ -1294,7 +1341,7 @@ Create a temporary frame to execute BODY, which will then be deleted." (add-variable-watcher 'wallpaper-current #'thanos/wallpaper-watcher) ;; Set wallpaper -(when (or is-constantine is-hermes) +(when (or is-constantine is-alexios) (thanos/wallpaper-startup)) (defvar-keymap thanos/applications-map |