diff options
Diffstat (limited to '.emacs.d')
-rw-r--r-- | .emacs.d/emacs.org | 555 |
1 files changed, 469 insertions, 86 deletions
diff --git a/.emacs.d/emacs.org b/.emacs.d/emacs.org index 74bfe80..dfcbcaa 100644 --- a/.emacs.d/emacs.org +++ b/.emacs.d/emacs.org @@ -1,5 +1,5 @@ #+TITLE: Emacs Configuration -#+PROPERTY: header-args :tangle test.el +#+PROPERTY: header-args :tangle init.el #+auto_tangle: t #+OPTIONS: num:nil toc:nil @@ -29,11 +29,9 @@ - [[#key-bindings][Key-bindings]] - [[#functions][Functions]] - [[#mu4e--email-configuration][mu4e | Email Configuration]] - - [[#macos][MacOS]] - - [[#settings--context-setup][Settings & Context setup]] - - [[#shortcuts][Shortcuts]] - - [[#contexts][Contexts]] - [[#custom-key-bindings][Custom key-bindings]] + - [[#general][General]] + - [[#hydra][Hydra]] - [[#org-mode-configuration][Org-mode Configuration]] - [[#org-make-toc][org-make-toc]] - [[#themes][Themes]] @@ -53,6 +51,8 @@ - [[#json][JSON]] - [[#javascript][Javascript]] - [[#elfeed][Elfeed]] + - [[#feeds][Feeds]] + - [[#settings][Settings]] - [[#pdf][PDF]] - [[#telega][Telega]] - [[#custom][Custom]] @@ -61,7 +61,7 @@ - [[#exwm][EXWM]] :END: -* TODO Setting up Packages +* Setting up Packages ** Setup for GuixSD machines We check the ~$HOSTNAME~, if it's one of my devices running GuixSD. we use ~guix-emacs-autoload-packages~ to load emacs packages installed using guix if ~t~ @@ -154,7 +154,7 @@ Contains the list of packages that need to be installed.") (package-install 'use-package)) #+end_src -* TODO UI Settings +* UI Settings ** Basic UI Fonts and basic appearance settings #+begin_src emacs-lisp @@ -284,7 +284,114 @@ Fonts and basic appearance settings (define-key dired-mode-map "b" 'dired-up-directory) #+end_src ** All-the-icons.el +#+begin_src emacs-lisp +;;; all-the-icons-dired.el --- Shows icons for each file in dired mode -*- lexical-binding: t; -*- + +;;; Code: + +(require 'cl-lib) +(require 'dired) +(require 'all-the-icons) + +(defface all-the-icons-dired-dir-face + '((((background dark)) :foreground "white") + (((background light)) :foreground "black")) + "Face for the directory icon" + :group 'all-the-icons-faces) + +(defcustom all-the-icons-dired-v-adjust 0.01 + "The default vertical adjustment of the icon in the dired buffer." + :group 'all-the-icons + :type 'number) + +(defvar all-the-icons-dired-mode) + +(defun all-the-icons-dired--add-overlay (pos string) + "Add overlay to display STRING at POS." + (let ((ov (make-overlay (1- pos) pos))) + (overlay-put ov 'all-the-icons-dired-overlay t) + (overlay-put ov 'after-string string))) + +(defun all-the-icons-dired--overlays-in (beg end) + "Get all all-the-icons-dired overlays between BEG to END." + (cl-remove-if-not + (lambda (ov) + (overlay-get ov 'all-the-icons-dired-overlay)) + (overlays-in beg end))) + +(defun all-the-icons-dired--overlays-at (pos) + "Get all-the-icons-dired overlays at POS." + (apply #'all-the-icons-dired--overlays-in `(,pos ,pos))) + +(defun all-the-icons-dired--remove-all-overlays () + "Remove all `all-the-icons-dired' overlays." + (save-restriction + (widen) + (mapc #'delete-overlay + (all-the-icons-dired--overlays-in (point-min) (point-max))))) + +(defun all-the-icons-dired--refresh () + "Display the icons of files in a dired buffer." + (all-the-icons-dired--remove-all-overlays) + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (when (dired-move-to-filename nil) + (let ((file (dired-get-filename 'relative 'noerror))) + (when file + (let ((icon (if (file-directory-p file) + (all-the-icons-icon-for-dir file + :face 'all-the-icons-dired-dir-face + :v-adjust all-the-icons-dired-v-adjust) + (all-the-icons-icon-for-file file :v-adjust all-the-icons-dired-v-adjust)))) + (if (member file '("." "..")) + (all-the-icons-dired--add-overlay (point) " \t") + (all-the-icons-dired--add-overlay (point) (concat icon "\t"))))))) + (forward-line 1)))) + +(defun all-the-icons-dired--refresh-advice (fn &rest args) + "Advice function for FN with ARGS." + (apply fn args) + (when all-the-icons-dired-mode + (all-the-icons-dired--refresh))) + +(defun all-the-icons-dired--setup () + "Setup `all-the-icons-dired'." + (when (derived-mode-p 'dired-mode) + (setq-local tab-width 1) + (advice-add 'dired-readin :around #'all-the-icons-dired--refresh-advice) + (advice-add 'dired-revert :around #'all-the-icons-dired--refresh-advice) + (advice-add 'dired-internal-do-deletions :around #'all-the-icons-dired--refresh-advice) + (advice-add 'dired-insert-subdir :around #'all-the-icons-dired--refresh-advice) + (advice-add 'dired-do-kill-lines :around #'all-the-icons-dired--refresh-advice) + (with-eval-after-load 'dired-narrow + (advice-add 'dired-narrow--internal :around #'all-the-icons-dired--refresh-advice)) + (all-the-icons-dired--refresh))) + +(defun all-the-icons-dired--teardown () + "Functions used as advice when redisplaying buffer." + (advice-remove 'dired-readin #'all-the-icons-dired--refresh-advice) + (advice-remove 'dired-revert #'all-the-icons-dired--refresh-advice) + (advice-remove 'dired-internal-do-deletions #'all-the-icons-dired--refresh-advice) + (advice-remove 'dired-narrow--internal #'all-the-icons-dired--refresh-advice) + (advice-remove 'dired-insert-subdir #'all-the-icons-dired--refresh-advice) + (advice-remove 'dired-do-kill-lines #'all-the-icons-dired--refresh-advice) + (all-the-icons-dired--remove-all-overlays)) + +;;;###autoload +(define-minor-mode all-the-icons-dired-mode + "Display all-the-icons icon for each files in a dired buffer." + :lighter " all-the-icons-dired-mode" + (when (and (derived-mode-p 'dired-mode) (display-graphic-p)) + (if all-the-icons-dired-mode + (all-the-icons-dired--setup) + (all-the-icons-dired--teardown)))) +#+end_src +Hook with ~dired-mode~ +#+begin_src emacs-lisp +(add-hook 'dired-mode-hook 'all-the-icons-dired-mode) +#+end_src * Terminals ** Vterm #+begin_src emacs-lisp @@ -334,76 +441,332 @@ Fonts and basic appearance settings (global-set-key (kbd "<escape>") 'keyboard-escape-quit) #+end_src -* TODO Functions +* Functions +#+begin_src emacs-lisp +(defun apollo/html-boostrap-boilerplate () + "Insert html boilerplate with boostrap link." + (interactive) + (insert +"<!DOCTYPE html> +<html lang=\"en\"> + <head> + <meta charset=\"UTF-8\"> + <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"> + <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\"> + <title>My Title</title> + <link rel=\"stylesheet\" href=\"./style.css\"> + <link href=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi\" crossorigin=\"anonymous\"> + </head> + <body> + <main> + <h1>Starting point</h1> + </main> + <script src=\"index.js\"></script> + </body> +</html>" )) + + +(defun apollo/center-buffer () + "Centers/Uncenters selected buffer" + (interactive) + (if visual-fill-column-center-text + (setq visual-fill-column-center-text nil) + (setq visual-fill-column-center-text t)) + (visual-fill-column-mode 1) + (message "General's task completed!")) + + +(defun apollo/rofi-switch-window () + "Navigate X11 buffers using rofi." + (interactive) + (start-process-shell-command + "rofi" nil "rofi -show window")) + +(defun apollo/run-in-background (command) + "Run COMMAND in the background." + (let ((command-parts (split-string command "[ ]+"))) + (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) + +(defun rofi () + "Run Rofi." + (interactive) + (apollo/run-in-background "rofi -show drun")) + +(defun apollo/volume-increase () + "Increase Volume." + (interactive) + (start-process-shell-command + "amixer" nil "amixer sset Master 5%+")) + +(defun apollo/volume-decrease () + "Decrease Volume." + (interactive) + (start-process-shell-command + "amixer" nil "amixer sset Master 5%-")) + +(defun apollo/restore-wallpaper () + "Set NAME as wallpaper." + (interactive) + (start-process-shell-command + "feh" nil "feh --bg-scale ~/dotfiles/wallpaper.png")) + +(defun apollo/emacs-keys () + "Swap caps with ctrl." + (interactive) + (start-process-shell-command + "setxkbmap" nil "setxkbmap us -option ctrl:swapcaps")) + +(defun apollo/greek-keyboard () + "Swap caps with ctrl." + (interactive) + (start-process-shell-command + "setxkbmap" nil "setxkbmap gr")) + +(defun apollo/exwm-init-hook () + "Do this upon start." + (display-battery-mode 0) ;;Change to 1 to display battery + + (setq display-time-day-and-date t) + (display-time-mode 1) + + ;;Launch apps that will run in the background +;; (apollo/run-in-background "blueman-applet") + (apollo/run-in-background "picom") +;; (apollo/run-in-background "nm-applet") + (apollo/emacs-keys) + (apollo/set-wallpaper) + (start-polybar) + ) + +(defun apollo/exwm-update-class () + (exwm-workspace-rename-buffer exwm-class-name)) + +(defun eshell-new() + "Open a new instance of eshell." + (interactive) + (eshell 'N)) + +(defun make-mini-buffer () + (interactive) + (split-window-below 40) + (other-window 1)) + +(defun make-mini-geiser () + (interactive) + (split-window-below 60) + (geiser nil)) + +(defun start-polybar () + "Check which system is running, start polybar accordingly." + (interactive) + (if (string= (system-name) "fsociety") + (start-process-shell-command + "polybar" nil "polybar main & polybar second") + (start-process-shell-command + "polybar" nil "polybar main"))) +#+end_src * mu4e | Email Configuration -** MacOS -If it's a mac, load from homebrew path + +# ** MacOS +# If it's a mac, load from homebrew path + +# #+begin_src emacs-lisp +# (when (equal system-type 'darwin) +# (use-package mu4e +# :load-path "/opt/homebrew/share/emacs/site-lisp/mu/mu4e/")) +# #+end_src + #+begin_src emacs-lisp (when (equal system-type 'darwin) (use-package mu4e :load-path "/opt/homebrew/share/emacs/site-lisp/mu/mu4e/")) -#+end_src -** Settings & Context setup -#+begin_src emacs-lisp - (setq mu4e-update-interval (* 10 60)) - (setq mu4e-get-mail-command "mbsync -a") - (setq mu4e-maildir-list "~/Mail/Inbox") - - (defun set-mu4e-context (context-name full-name mail-address signature server) - "Return a mu4e context named CONTEXT-NAME with :match-func matching - folder name CONTEXT-NAME in Maildir. The context's `user-mail-address', - `user-full-name' and `mu4e-compose-signature'`smtpmail-smpt-server' is set to MAIL-ADDRESS - FULL-NAME SIGNATURE and SERVER respectively. - Special folders are set to context specific folders." - (let ((dir-name (concat "/" context-name))) - (make-mu4e-context - :name context-name - ;; we match based on the maildir of the message - :match-func - `(lambda (msg) - (when msg - (string-match-p - ,(concat "^" dir-name) - (mu4e-message-field msg :maildir)))) - :vars - `((user-mail-address . ,mail-address) - (user-full-name . ,full-name) - (mu4e-sent-folder . ,(concat dir-name "/Sent")) - (mu4e-drafts-folder . ,(concat dir-name "/Drafts")) - (mu4e-trash-folder . ,(concat dir-name "/Trash")) - (mu4e-trash-folder . ,(concat dir-name "/Starred")) - (mu4e-refile-folder . ,(concat dir-name "/Archive")) - (smtpmail-smtp-service . ,465) - (smtpmail-smtp-server . ,server) - (mu4e-compose-signature . ,signature))))) - - ;;Fixing duplicate UID errors when using mbsync and mu4e - (setq mu4e-change-filenames-when-moving t) - ;; Messaging - (setq message-send-mail-function 'smtpmail-send-it - smtpmail-stream-type 'ssl) -#+end_src -** Shortcuts -#+begin_src emacs-lisp + +(require 'mu4e) + +(setq mu4e-update-interval (* 10 60)) +(setq mu4e-get-mail-command "mbsync -a") +(setq mu4e-maildir-list "~/Mail/Inbox") + +(defun set-mu4e-context (context-name full-name mail-address signature server) + "Return a mu4e context named CONTEXT-NAME with :match-func matching + folder name CONTEXT-NAME in Maildir. The context's `user-mail-address', + `user-full-name' and `mu4e-compose-signature'`smtpmail-smpt-server' is set to MAIL-ADDRESS + FULL-NAME SIGNATURE and SERVER respectively. + Special folders are set to context specific folders." + (let ((dir-name (concat "/" context-name))) + (make-mu4e-context + :name context-name + ;; we match based on the maildir of the message + :match-func + `(lambda (msg) + (when msg + (string-match-p + ,(concat "^" dir-name) + (mu4e-message-field msg :maildir)))) + :vars + `((user-mail-address . ,mail-address) + (user-full-name . ,full-name) + (mu4e-sent-folder . ,(concat dir-name "/Sent")) + (mu4e-drafts-folder . ,(concat dir-name "/Drafts")) + (mu4e-trash-folder . ,(concat dir-name "/Trash")) + (mu4e-trash-folder . ,(concat dir-name "/Starred")) + (mu4e-refile-folder . ,(concat dir-name "/Archive")) + (smtpmail-smtp-service . ,465) + (smtpmail-smtp-server . ,server) + (mu4e-compose-signature . ,signature))))) +;;Fixing duplicate UID errors when using mbsync and mu4e +(setq mu4e-change-filenames-when-moving t) + (setq mu4e-maildir-shortcuts '(("/Fastmail/Inbox" . ?i) ("/Fastmail/Sent" . ?s) + ;; ("/Gmail/Trash" . ?t) + ;; ("/Gmail/Drafts" . ?d) + ;; ("/Gmail/[Gmail]/All Mail" . ?a )) -#+end_src -** Contexts -#+begin_src emacs-lisp + (setq mu4e-contexts `(, (set-mu4e-context "Fastmail" "Thanos Apollo" "[email protected]" "Thanos\nhttps://thanosapollo.com/public" "smtp.fastmail.com"))) + +;; (setq smtpmail-smtp-service 465 +;; smtpmail-stream-type 'ssl +;; smtpmail-smtp-server "smtp.fastmail.com") + + + +(setq message-send-mail-function 'smtpmail-send-it + smtpmail-stream-type 'ssl) + +#+end_src + +# ** Settings & Context setup +# #+begin_src emacs-lisp +# (require 'mu4e) +# (setq mu4e-update-interval (* 10 60)) +# (setq mu4e-get-mail-command "mbsync -a") +# (setq mu4e-maildir-list "~/Mail/Inbox") + +# (defun set-mu4e-context (context-name full-name mail-address signature server) +# "Return a mu4e context named CONTEXT-NAME with :match-func matching +# folder name CONTEXT-NAME in Maildir. The context's `user-mail-address', +# `user-full-name' and `mu4e-compose-signature'`smtpmail-smpt-server' is set to MAIL-ADDRESS +# FULL-NAME SIGNATURE and SERVER respectively. +# Special folders are set to context specific folders." +# (let ((dir-name (concat "/" context-name))) +# (make-mu4e-context +# :name context-name +# ;; we match based on the maildir of the message +# :match-func +# `(lambda (msg) +# (when msg +# (string-match-p +# ,(concat "^" dir-name) +# (mu4e-message-field msg :maildir)))) +# :vars +# `((user-mail-address . ,mail-address) +# (user-full-name . ,full-name) +# (mu4e-sent-folder . ,(concat dir-name "/Sent")) +# (mu4e-drafts-folder . ,(concat dir-name "/Drafts")) +# (mu4e-trash-folder . ,(concat dir-name "/Trash")) +# (mu4e-trash-folder . ,(concat dir-name "/Starred")) +# (mu4e-refile-folder . ,(concat dir-name "/Archive")) +# (smtpmail-smtp-service . ,465) +# (smtpmail-smtp-server . ,server) +# (mu4e-compose-signature . ,signature))))) + +# ;;Fixing duplicate UID errors when using mbsync and mu4e +# (setq mu4e-change-filenames-when-moving t) +# ;; Messaging +# (setq message-send-mail-function 'smtpmail-send-it +# smtpmail-stream-type 'ssl) +# #+end_src +# ** Shortcuts +# #+begin_src emacs-lisp +# (setq mu4e-maildir-shortcuts +# '(("/Fastmail/Inbox" . ?i) +# ("/Fastmail/Sent" . ?s) +# )) +# #+end_src +# ** Contexts +# #+begin_src emacs-lisp +# (setq mu4e-contexts +# `(, (set-mu4e-context +# "Fastmail" "Thanos Apollo" +# "[email protected]" "Thanos\nhttps://thanosapollo.com/public" +# "smtp.fastmail.com"))) +# #+end_src +* Custom key-bindings +** General +#+begin_src emacs-lisp + + ;; my general's leader key! + (defconst general-key "C-c g") + + (general-create-definer general-does + :prefix general-key) + + ;; Basic functions + (general-define-key + "C-d" 'kill-region + "C-k" 'copy-region-as-kill + "C-c v" 'multi-vterm-next + "C-x 9" 'make-mini-buffer + "C-c l e" 'apollo/emacs-keys + ;;Change keyboard layouts/language + "C-c l g" 'apollo/greek-keyboard + "C-κ" 'apollo/emacs-keys + "C-x C-b" 'ibuffer) + + + + ;; My Generals does: + (general-does + "t" 'counsel-load-theme + "l" 'display-line-numbers-mode + "v" 'multi-vterm-next + "e" 'eshell + "i" 'circe + "c" 'apollo/center-buffer + "m" 'mu4e + "f" 'elfeed + "C-t" 'telega) + + ;;pdf-tools + (general-define-key + :keymaps 'pdf-view-mode-map + "C-c d" 'pdf-view-midnight-minor-mode + "C-s" 'isearch-forward + "C-o" 'pdf-isearch-occur) + + ;;vterm + (general-does + :keymaps 'vterm-mode-map + "n" 'multi-vterm-next + "o" 'multi-vterm + "p" 'multi-vterm-prev) + + (general-does + :keymaps 'eshell-mode-map + "n" 'eshell-new) + + (general-does + :keymaps 'org-mode-map + "3" 'org-insert-image-size-300) +#+end_src +** Hydra +#+begin_src emacs-lisp +(defhydra hydra-zoom (global-map "s-z") + "zoom" + ("=" text-scale-increase "in") + ("-" text-scale-decrease "out")) #+end_src -* TODO Custom key-bindings * Org-mode Configuration ** org-make-toc #+begin_src emacs-lisp - (use-package org-make-toc - :ensure t) + (add-hook 'org-mode-hook 'org-make-toc-mode) #+end_src ** Themes *** Dracula @@ -484,25 +847,25 @@ If it's a mac, load from homebrew path org-superstar-headline-bullets-list '("◉" "●" "○" "●" "○" "●" "◆") org-superstar-itembullet-alist '((?+ . ?➤) (?- . ?✦))) ;; changes +/- symbols in item lists) - ;; Startup - (defun apollo/org-mode-setup () - (apollo/org-theme-dracula)) ;; Hooks - (add-hook 'org-mode-hook 'apollo/org-mode-setup) + (add-hook 'org-mode-hook 'apollo/org-theme-dracula) (add-hook 'org-mode-hook 'org-superstar-mode) (add-hook 'org-mode-hook 'flyspell-mode) #+end_src ** Babel #+begin_src emacs-lisp -(org-babel-do-load-languages - 'org-babel-load-languages - '((emacs-lisp . t) - (python . t))) - -(add-to-list 'org-structure-template-alist '("sh" . "src shell")) -(add-to-list 'org-structure-template-alist '("b" . "src shell")) -(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) -(add-to-list 'org-structure-template-alist '("py" . "src python")) + (org-babel-do-load-languages + 'org-babel-load-languages + '((emacs-lisp . t) + (python . t))) + + (add-to-list 'org-structure-template-alist '("sh" . "src shell")) + (add-to-list 'org-structure-template-alist '("b" . "src shell")) + (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) + (add-to-list 'org-structure-template-alist '("py" . "src python")) + + ;;Auto tangle + (add-hook 'org-mode-hook 'org-auto-tangle-mode) #+end_src * Markdown ** Theme @@ -618,14 +981,38 @@ If it's a mac, load from homebrew path (delete-char sgml-basic-offset))))) #+end_src * Elfeed - +** Feeds +#+begin_src emacs-lisp +(require 'elfeed) +(require 'elfeed-goodies) + +(setq elfeed-feeds (quote + ( + ("https://hackaday.com/blog/feed/" hackaday linux) + ("https://opensource.com/feed" opensource linux) + ("https://linux.softpedia.com/backend.xml" softpedia linux) + ("https://www.thelancet.com/rssfeed/lancet_current.xml" Lancet lancet) + ("https://www.thelancet.com/rssfeed/lancet_online.xml" LancetOnline lancet) + ("https://www.thelancet.com/rssfeed/lanmic_online.xml" LancetOnline Microbiology) + ("https://www.techrepublic.com/rssfeeds/topic/open-source/" techrepublic linux) + ("https://www.thanosapollo.com/public/feed.xml" Thanos) + ("https://protesilaos.com/news.xml" Protesilaos News) + ("https://protesilaos.com/codelog.xml" Proetesilaos Coding) + ("https://stallman.org/rss/rss.xml" Stallman news) + ))) +#+end_src +** Settings +#+begin_src emacs-lisp +(setq elfeed-goodies/entry-pane-size 0.5) +#+end_src * PDF #+begin_src emacs-lisp -(use-package pdf-tools - :ensure t - :mode ".pdf" - :config - (add-hook 'pdf-view-mode #'pdf-isearch-minor-mode)) + +;;Add pdf-isearch-minor-mode hook, otherwise isearch will be buggy +;;Darkmode hook, cause I don't want color or light in my life, I'm a vampire. +(add-hook 'pdf-view-mode-hook 'pdf-isearch-minor-mode) +(add-hook 'pdf-view-mode-hook 'pdf-view-midnight-minor-mode) +(add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode)) #+end_src * Telega In ~GuixSD~ systems I have telegram installed via guix, and it's loaded via ~guix-emacs-autoload-packages~ @@ -911,10 +1298,11 @@ you have the correctly set the OPENAI_API_KEY variable" (start-process-shell-command "polybar" nil "polybar main"))) #+end_src -* TODO EXWM -TODO: tangle with .exwm.el & organize +* EXWM +EXWM configuration is tangled with ~.exwm~ ++ In GuixSD ~emacs-exwm~ package will look for ~~/.exwm~ -#+begin_src emacs-lisp +#+begin_src emacs-lisp :tangle ../.exwm.el (defun apollo/exwm-init-hook () "Do this upon start." (if (string= (system-name) "fsociety") ;; Check if it's my desktop, otherwise display battery @@ -1053,10 +1441,5 @@ TODO: tangle with .exwm.el & organize (exwm-enable) - -;;Transparency -(set-frame-parameter (selected-frame) 'alpha '(90 90)) -(add-to-list 'default-frame-alist '(alpha 90 90)) - #+end_src |