diff options
Diffstat (limited to '.config/emacs')
-rw-r--r-- | .config/emacs/init.el | 340 |
1 files changed, 147 insertions, 193 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el index ddb2281..35d15c9 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -28,9 +28,7 @@ ;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰╯ ;;; Code: -;; Disable package.el -(setq package-enable-at-startup nil - package-archives nil) +(package-initialize) (setf user-full-name "Thanos Apollo" user-mail-address "[email protected]") @@ -73,32 +71,7 @@ ;; Enable use-package support for imenu (setf use-package-enable-imenu-support t) -;; Install straight.el -(defvar bootstrap-version) - -(let ((bootstrap-file - (expand-file-name - "straight/repos/straight.el/bootstrap.el" - (or (bound-and-true-p straight-base-dir) - user-emacs-directory))) - (bootstrap-version 7)) - (unless (file-exists-p bootstrap-file) - (with-current-buffer - (url-retrieve-synchronously - "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" - 'silent 'inhibit-cookies) - (goto-char (point-max)) - (eval-print-last-sexp))) - (load bootstrap-file nil 'nomessage)) - -(require 'straight) - -(setf straight-use-package-by-default t) - -(setf straight-recipe-overrides - '((transmission :type git :host nil :repo "[email protected]:/var/git/transmission.git"))) - -(setf browse-url-browser-function 'browse-url-generic +(setf browse-url-browser-function 'eww ;; 'browse-url-generic browse-url-generic-program "icecat" backup-directory-alist '((".*" . "~/.Trash")) sentence-end-double-space t @@ -174,7 +147,8 @@ ("\\paragraph{%s}" . "\\paragraph*{%s}"))) :hook ((org-mode . (lambda () (display-line-numbers-mode -1) (flyspell-mode)))) :bind (:map org-mode-map (("C-c l" . org-store-link) - ("C-c M-t" . org-todo)))) + ("C-c M-t" . org-todo) + ("C-c RET" . org-table-hline-and-move)))) ;; Export @@ -219,7 +193,6 @@ (scheme-mode . thanos/add-custom-keywords))) (use-package dired - :straight nil :ensure nil :config (defun dired-watch-video () @@ -341,7 +314,8 @@ (make-directory "~/Notes")) (use-package org-roam - :straight (org-roam :local-repo "~/Dev/emacs-lisp/org-roam") + :vc t + :load-path "~/Dev/emacs-lisp/org-roam" :defer t :init (define-prefix-command 'thanos/notes-map) @@ -352,7 +326,7 @@ (org-roam-db-autosync-enable) (setf org-roam-node-display-template - (concat "${title:50} "(propertize "${tags:30}" 'face 'org-tag))) + (concat "${title:50} "(propertize "${tags:50}" 'face 'org-tag))) (setf org-roam-db-node-include-function (lambda () @@ -378,7 +352,7 @@ "* %?" :target (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n#+filetags: :journal:dailies:\n -* Daily Notes\n\n* Goals\n+ []\n\n* Extras")))) +* Daily Notes\n\n* Goals\n+ [] Πρωινὴ Προσευχή\n+ [] Ἑσπερινή Προσευχή\n\n* Extras")))) (defun org-roam-ref-add-book () "Insert org-link from Library." @@ -418,11 +392,30 @@ ("C-c i" . org-id-get-create))) (use-package org-roam-ui - :defer t) + :vc (:url "https://github.com/org-roam/org-roam-ui") + :after org-roam + :config + (setq org-roam-ui-sync-theme t + org-roam-ui-follow t + org-roam-ui-update-on-save t + org-roam-ui-open-on-start t)) + +(use-package org-present + :vc (:url "https://github.com/rlister/org-present") + :hook ((org-present-mode . (lambda () + (org-present-big) + (org-display-inline-images) + (org-present-hide-cursor) + (org-present-read-only))) + (org-present-mode-quit . (lambda () + (org-present-small) + (org-remove-inline-images) + (org-present-show-cursor) + (org-present-read-write))))) (unless (or is-phone is-uranus) (use-package modus-themes - :straight t + :vc (:url "https://github.com/protesilaos/modus-themes") :config (setf modus-themes-italic-constructs nil modus-themes-bold-constructs nil @@ -491,12 +484,13 @@ :init (define-prefix-command 'thanos/search) :bind (("C-x r d" . 'bookmark-delete) ("C-x r C-r" . 'bookmark-rename) - ("C-x r j" . 'consult-register) + ("C-x r C-j" . 'consult-register) ("C-x r SPC" . 'consult-register-store) ("C-x r b" . 'consult-bookmark) ("C-c m" . 'consult-imenu) ("C-x b" . 'consult-buffer) ("C-x C-b" . 'switch-to-prev-buffer) + ("C-x M-b" . 'ibuffer) ("M-y" . 'consult-yank-from-kill-ring) ("C-M-s" . 'consult-line) ("C-c s" . 'thanos/search) @@ -517,6 +511,7 @@ (use-package elfeed :defer t + :vc (:url "https://github.com/skeeto/elfeed") :config (setf elfeed-search-filter "@1-week-ago +unread -hackernoon" browse-url-browser-function #'browse-url-default-browser @@ -540,7 +535,6 @@ ("http://localhost/?action=display&bridge=CssSelectorBridge&home_page=https%3A%2F%2Fwww.estianews.gr%2Feidiseis-arthra%2F&url_selector=h3.entry-title&url_pattern=&content_selector=div.col-lg-8&content_cleanup=&title_cleanup=&limit=&format=Atom" estia greek news) ("http://localhost/?action=display&bridge=CssSelectorBridge&home_page=https%3A%2F%2Fwww.estianews.gr%2Fkentriko-thema%2F&url_selector=h3.entry-title&url_pattern=&content_selector=div.col-md-8&content_cleanup=&title_cleanup=&limit=&format=Atom" estia greek kyrio) ("http://localhost/?action=display&bridge=CssSelectorBridge&home_page=https%3A%2F%2Fwww.estianews.gr%2Fapopseis%2F&url_selector=h3.entry-title&url_pattern=&content_selector=div.col-lg-8&content_cleanup=&title_cleanup=&limit=&format=Atom" estia greek opinions) - ("http://localhost/?action=display&bridge=CssSelectorBridge&home_page=https%3A%2F%2Fwww.reuters.com%2Fworld%2F&url_selector=a.media-story-card__headline__tFMEu&url_pattern=&content_selector=article.article__container__2MUeZ&content_cleanup=div.info-content__toolbar__3AkHm%2C+div.article-body__row__dFOPA%2C+div.article__read-next__Kjxdw&title_cleanup=&limit=&format=Atom" reuters world news) ("http://localhost/?action=display&bridge=CssSelectorBridge&home_page=https%3A%2F%2Fwww.reuters.com%2Fbusiness%2Fhealthcare-pharmaceuticals%2F&url_selector=a.basic-card__title__37xHl&url_pattern=&content_selector=div.article-body__wrapper__3IxHM&content_cleanup=svg.link__new-tab-symbol__3T19s%2C+div.toolbar__container__3kIkw%2C+div.article-body__row__dFOPA+article-body__element__2p5pI&title_cleanup=&limit=&format=Atom" reuters med news) ("http://localhost/?action=display&bridge=CssSelectorBridge&home_page=https%3A%2F%2Fwww.reuters.com%2Ftechnology%2Fcybersecurity%2F&url_selector=a.media-story-card__headline__tFMEu%2C+a.media-story-card__heading__eqhp9&url_pattern=&content_selector=article.article__container__2MUeZ&content_cleanup=div.info-content__toolbar__3AkHm%2C+svg.link__new-tab-symbol__3T19s%2C+div.article-body__row__dFOPA%2C+div.read-next-tablet-up__container__3MpHN%2C+div.author-bio__multiple-authors__5YGrG%2C+div.article__read-next__Kjxdw&title_cleanup=&limit=&format=Atom" reuters cybersec news) ("https://annas-blog.org/ @@ -554,6 +548,7 @@ rss.xml" anna piracy) ("http://planet.lisp.org/rss20.xml" lisp planetlisp) ("https://guix.gnu.org/feeds/blog.atom" guix) ("https://protesilaos.com/master.xml" prot) + ("https://static.fsf.org/fsforg/rss/news.xml" gnu fsf) ;; YouTube ("https://www.youtube.com/feeds/videos.xml?channel_id=UCVls1GmFKf6WlTraIb_IaJg" distrotube yt linux) @@ -588,22 +583,12 @@ rss.xml" anna piracy) :hook ((elfeed-searchacw-mode . (lambda () (display-line-numbers-mode 0))))) ;; Python -(use-package python-mode - :defer t - :config - (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))) - -(use-package pyenv - :defer t) +(add-to-list 'auto-mode-alist '("\\.py\\'" . python-ts-mode)) -;; Clojure -(use-package cider - :defer t) - -(use-package clojure-mode - :defer t) +;; Lisp (use-package rainbow-delimiters + :vc (:url "https://github.com/Fanael/rainbow-delimiters") :defer t :hook ((emacs-lisp-mode . rainbow-delimiters-mode) (lisp-mode . rainbow-delimiters-mode) @@ -612,48 +597,58 @@ rss.xml" anna piracy) (use-package sly :init (setf inferior-lisp-program "sbcl") - :defer t) + :ensure t) -(use-package helpful - :defer t - :bind (("C-h f" . 'helpful-callable) - ("C-h v" . 'helpful-variable) - ("C-h k" . 'helpful-key) - ("C-h x" . 'helpful-command) - ("C-h ." . 'helpful-at-point) - ("C-h F" . 'helpful-function) - ("C-h C-k" . 'helpful-kill-buffers) - ("C-h a" . 'apropos) - ("C-h C-m" . 'info-apropos))) - -(use-package ox-hugo +(use-package vc :ensure t :config - (setf org-hugo-section "post")) - -(use-package json-mode - :defer t - :config - (add-to-list 'auto-mode-alist '("\\.json'" . json-mode))) - -(defun project-magit () - "Run magit-status in the current project's root." - (interactive) - (magit-status-setup-buffer (project-root (project-current t)))) - -(use-package magit - :defer t - :config - (setf magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1) - :bind (:map project-prefix-map ("g" . 'project-magit))) - -(use-package magit-todos - :after magit - :config - (magit-todos-mode 0) - (setf magit-todos-keywords - '(("TODO" . "#cc9393") - ("FIXME" . "#FF0000")))) + (defun vc-git--commit-hash-at-point () + "Return commit hash at point." + (let ((hash (thing-at-point 'word t))) + (and (stringp hash) + (string-match-p "^[0-9a-f]\\{7,40\\}$" hash) + hash))) + + (defun vc-git-reset-to-commit-at-point (&optional hash) + "Reset the current branch to the commit at point in the vc log buffer." + (let ((commit-hash (or (thing-at-point 'word t) hash))) + (vc-git--reset commit-hash))) + + (defun vc-git--reset (commit-hash) + "Reset to commit HASH." + (if (and commit-hash (string-match-p "^[0-9a-f]\\{7,40\\}$" commit-hash)) + (if (yes-or-no-p (format "Reset current branch to commit %s?" commit-hash)) + (progn + (let ((default-directory (vc-root-dir))) + (vc-git-command nil 0 nil "reset" "--hard" commit-hash) + (message "Reset to commit %s completed." commit-hash))) + (message "Reset cancelled.")) + "Invalid commit hash")) + + (defun vc-git--select-commit () + (let* ((history-add-new-input nil) + (commit-strings (split-string (shell-command-to-string "git log --oneline") "\n" t)) + (selected (completing-read "Select commit: " commit-strings nil t)) + (selected-hash (car (split-string selected)))) + selected-hash)) + + (defun vc-git-reset (&optional hash) + (interactive) + (vc-git--reset (or hash + (vc-git--commit-hash-at-point) + (vc-git--select-commit)))) + + (defun vc-git-format-patches (num) + "Format patches for NUM of last commits" + (interactive (list (read-number "Number of commits: "))) + (vc-git-command nil 0 nil "format-patch" (format "-%d" num)) + (message "Done.")) + + (defun vc-git-reword-commit () + "Edit current commit message" + (interactive) + (vc-checkin nil 'git nil nil nil "") + (vc-git-log-edit-toggle-amend))) (use-package corfu :ensure t @@ -675,6 +670,16 @@ rss.xml" anna piracy) (when (or is-phone is-uranus) (use-package corfu-terminal)) +(use-package cape + ;; Press C-c p ? to for help. + :bind ("M-p" . cape-prefix-map) ;; Alternative keys: M-p, M-+, ... + :config + ;; (add-hook 'completion-at-point-functions #'cape-dabbrev) + (add-hook 'completion-at-point-functions #'cape-file) + ;; (add-hook 'completion-at-point-functions #'cape-elisp-block) + ;; (add-hook 'completion-at-point-functions #'cape-dict) + ) + (defun insert-brackets (&optional arg) "Insert ARG brackets." (interactive "P") @@ -692,7 +697,6 @@ rss.xml" anna piracy) completion-cycle-threshold 2)) (use-package pdf-tools - :straight nil :ensure nil :config (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode)) @@ -703,22 +707,13 @@ rss.xml" anna piracy) ;; minor modes automatically (pdf-tools-enable-minor-modes))))) -(use-package markdown-mode - :straight nil - :defer t - :config - (setq markdown-header-scaling t - markdown-command "multimarkdown") - (add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode)) - :hook ((markdown-mode . flyspell-mode))) - (use-package nov - :straight nil - :defer t + :ensure nil :config (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))) (use-package eshell-syntax-highlighting + :vc (:url "https://github.com/akreisher/eshell-syntax-highlighting") :ensure t :after eshell :config @@ -730,8 +725,8 @@ rss.xml" anna piracy) :commands emojify-mode) (use-package flycheck-package - :straight t - :ensure t + :vc (:url "https://github.com/purcell/flycheck-package") + :ensure nil :after flycheck) (use-package flycheck @@ -742,14 +737,6 @@ rss.xml" anna piracy) :hook ((emacs-lisp-mode . (lambda () (flycheck-mode) (flycheck-package-setup))))) (use-package eat - :straight '(eat :type git - :host codeberg - :repo "akib/emacs-eat" - :files ("*.el" ("term" "term/*.el") "*.texi" - "*.ti" ("terminfo/e" "terminfo/e/*") - ("terminfo/65" "terminfo/65/*") - ("integration" "integration/*") - (:exclude ".dir-locals.el" "*-tests.el"))) :config (setf eshell-visual-commands nil eat-term-name "xterm-256color") @@ -765,10 +752,7 @@ rss.xml" anna piracy) :hook ((shell-mode . (lambda () (display-line-numbers-mode -1))))) (defvar thanos/aliases - '((g . magit) - (gl . magit-log) - (gc . magit-clone) - (d . dired) + '((d . dired) (o . find-file) (oo . find-file-other-window) (ll . (lambda () (eshell/ls '-lha))) @@ -796,7 +780,8 @@ rss.xml" anna piracy) (display-line-numbers-mode -1))))) (use-package eshell-git-prompt - :straight nil + :vc (:url "https://github.com/xuchunyang/eshell-git-prompt") + :ensure t :config (defun eshell-git-prompt-multiline () "Eshell Git prompt inspired by spaceship-prompt." @@ -829,43 +814,21 @@ rss.xml" anna piracy) (eshell-git-prompt-use-theme 'multiline)) -;; Chat -(use-package jabber +;; Password-store +(use-package password-store + :init (define-prefix-command 'thanos/pass) :defer t :config - (defun jabber-buffers-formats (&optional buffer-formats) - "Return jabber BUFFER-FORMATS without the format specifiers. - -By default, returns all jabber related buffers format." - (let ((buffer-formats (or buffer-formats '(jabber-chat-buffer-format - jabber-browse-buffer-format - jabber-roster-buffer - jabber-groupchat-buffer-format - jabber-muc-private-buffer-format)))) - (cl-loop for var in buffer-formats - for str = (symbol-value var) - for formatted-str = (when (stringp str) - ;; Remove format specifier and - ;; the following 2 char, or 1 if - ;; there is not second. - (replace-regexp-in-string "%.?" "" str)) - collect formatted-str))) - - (defun jabber-switch-to-buffer () - "Prompt the user to select a buffer whose name matches a list of strings." - (interactive) - (let* ((string-list (jabber-buffers-formats)) - (buffers-matching-strings - (cl-loop for buf in (buffer-list) - when (cl-loop for str in string-list - thereis (string-match-p str (buffer-name buf))) - collect (buffer-name buf)))) - (if buffers-matching-strings - (switch-to-buffer - (completing-read "Select jabber buffer: " buffers-matching-strings))) - (error "No jabber buffer found"))) - :bind (:map jabber-global-keymap - ("C-b" . 'jabber-switch-to-buffer))) + (setf password-store-password-length (+ 20 (random 20))) + :bind (("C-c p" . 'thanos/pass) + :map thanos/pass + ("i" . 'password-store-insert) + ("e" . 'password-store-edit) + ("g" . 'password-store-generate) + ("c" . 'password-store-copy) + ("s" . 'smtp-get-pass))) + +;; Chat (use-package erc :ensure t @@ -873,27 +836,29 @@ By default, returns all jabber related buffers format." (unless (expand-file-name "erc" user-emacs-directory) (make-directory (expand-file-name "erc" user-emacs-directory))) (setf erc-modules - '(sasl netsplit fill button match track completion readonly - networks ring autojoin noncommands irccontrols move-to-prompt stamp - menu list log notifications) + '(netsplit fill button match track completion readonly + networks ring autojoin noncommands irccontrols move-to-prompt stamp + menu list log notifications) erc-log-channels-directory (expand-file-name "erc" user-emacs-directory)) (defun thanos/erc-login () "Login to libera.chat" (interactive) - (erc-tls :server "irc.libera.chat" :port 6697 - :nick "thanosapollo" - :user "thanosapollo" - :password (password-store-get "liberachat/thanos_apollo"))) + (erc :server "uranus" :port 5555 + :nick "thanosapollo" + :user "thanosapollo" + :password (password-store-get "znc/admin"))) :bind (("C-c E" . 'erc-libera) :map erc-mode-map ("C-c RET" . 'erc-cmd-QUERY))) (use-package transmission + :vc (:url "https://github.com/holomorph/transmission") :defer t) (use-package sudo-edit - :defer t + :vc (:url "https://github.com/nflath/sudo-edit") + :ensure t :config (setf sudo-edit-local-method "sudo")) @@ -912,7 +877,8 @@ By default, returns all jabber related buffers format." (when (or is-zeus is-hermes) (use-package yeetube :init (define-prefix-command 'thanos/yeetube-map) - :straight (yeeutube :local-repo "~/Dev/emacs-lisp/yeetube") + :vc t + :load-path "~/Dev/emacs-lisp/yeetube" :ensure t :config (setf yeetube-results-limit 20 @@ -931,7 +897,8 @@ By default, returns all jabber related buffers format." (while (not (string= url "q")) (setf url (read-string "Enter URL (q to quit): ")) (unless (string= url "q") - (setf name (read-string (format "Custom name (download counter: %d) " download-counter))) + (setf name + (read-string (format "Custom name (download counter: %d) " download-counter))) (push (cons url name) stored-contents) (setf download-counter (1+ download-counter)))) ;; Process the collected links and names @@ -952,7 +919,8 @@ By default, returns all jabber related buffers format." (while (not (string= url "q")) (setf url (read-string "Enter URL (q to quit): ")) (unless (string= url "q") - (setf name (read-string (format "Custom name (download counter: %d) " download-counter))) + (setf name + (read-string (format "Custom name (download counter: %d) " download-counter))) (setf download-counter (1+ download-counter)) (call-process-shell-command (format @@ -973,7 +941,8 @@ By default, returns all jabber related buffers format." ("k" . 'yeetube-remove-saved-video))) (use-package gnosis - :straight (gnosis :local-repo "~/Dev/emacs-lisp/gnosis") + :vc t + :load-path "~/Dev/emacs-lisp/gnosis" :ensure t :init (define-prefix-command 'thanos/gnosis-map) :config @@ -992,7 +961,8 @@ By default, returns all jabber related buffers format." (gnosis-vc-pull) (use-package pcmpl-tailscale - :straight (pcmpl-tailscale :local-repo "~/Dev/emacs-lisp/pcmpl-tailscale") + :vc t + :load-path "~/Dev/emacs-lisp/pcmpl-tailscale" :ensure nil)) ;; Emacs dev @@ -1002,7 +972,7 @@ By default, returns all jabber related buffers format." ;; AI tools (use-package gptel - :defer t + :ensure t :config (setf gptel-api-key (password-store-get-field "openai/[email protected]" "api") gptel-default-mode 'org-mode @@ -1023,22 +993,6 @@ By default, returns all jabber related buffers format." :map gptel-mode-map ("C-c h" . 'gptel-menu))) - -;; Password-store -(use-package password-store - :init (define-prefix-command 'thanos/pass) - :defer t - :config - (setf password-store-password-length (+ 20 (random 20))) - - :bind (("C-c p" . 'thanos/pass) - :map thanos/pass - ("i" . 'password-store-insert) - ("e" . 'password-store-edit) - ("g" . 'password-store-generate) - ("c" . 'password-store-copy) - ("s" . 'smtp-get-pass))) - (use-package package-lint :defer t) @@ -1073,8 +1027,7 @@ By default, returns all jabber related buffers format." (kill-buffer (process-buffer process)))))))) (use-package notmuch - :straight nil - :ensure t + :defer t :bind (("C-x m" . notmuch-hello) :map notmuch-hello-mode-map ("u" . notmuch-hello-update) @@ -1086,7 +1039,9 @@ By default, returns all jabber related buffers format." (setf notmuch-archive-tags '("-inbox" "-unread" "+archived") notmuch-show-all-tags-list t - notmuch-hello-sections '(notmuch-hello-insert-header notmuch-hello-insert-saved-searches notmuch-hello-insert-alltags)) + notmuch-hello-sections + '(notmuch-hello-insert-header notmuch-hello-insert-saved-searches + notmuch-hello-insert-alltags)) (setq notmuch-search-oldest-first nil) @@ -1120,13 +1075,12 @@ By default, returns all jabber related buffers format." ;; autosign messages (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime) -(use-package yasnippet - :ensure nil - :config - (when is-zeus (add-to-list 'yas-snippet-dirs "~/Dev/guile/guix/etc/snippets/yas"))) +;; (use-package yasnippet +;; :ensure nil +;; :config +;; (when is-zeus (add-to-list 'yas-snippet-dirs "~/Dev/guile/guix/etc/snippets/yas"))) (use-package emms - :straight nil :defer t :init (define-prefix-command 'thanos/emms) :config @@ -1200,7 +1154,6 @@ By default, returns all jabber related buffers format." memory cores image (if iso (concat "-cdrom " iso) ""))))) (use-package 0x0 - :straight nil :ensure nil) ;; Misc Functions ;; @@ -1390,10 +1343,11 @@ Create a temporary frame to execute BODY, which will then be deleted." (interactive "nStart: \nnEnd: ") (dotimes (i (1+ (- end str))) (insert (format "%s" (+ i str))) - (org-return))) + (org-table-hline-and-move))) (use-package greek-polytonic - :straight (greek-polytonic :local-repo "~/Dev/emacs-lisp/greek-polytonic")) + :vc t + :load-path "~/Dev/emacs-lisp/greek-polytonic") (require 'server) (unless (server-running-p) |