Nenhuma descrição

zadca123 077a014095 auto formatting with black 2 anos atrás
games 96224f1387 deleting snippets archive... 2 anos atrás
local 94b3ec8b7e many cool things, org mode does not work??? 2 anos atrás
.gitignore 4ee8874628 updating gitignore, adding diary 2 anos atrás
README.org 88c65b02b4 idk if is there something to commit 2 anos atrás
bookmarks 478c06d6f6 updating files 2 anos atrás
config.org 077a014095 auto formatting with black 2 anos atrás
diary a2208a45f0 next update, some new things like tabs, breaking lines 2 anos atrás
init.el 019c4b9146 bringing up emacs, formating like in code 2 anos atrás
learn.png ead651f25c new startup page 2 anos atrás
logos.tar.gz cdb88495bc changing from xz to gzip, heard its a turd vonuerable to bit rot or something 2 anos atrás

README.org

A GNU/Emacs config built with help of yukimacs, Uncle Dave's Emacs, Mike Zamansky and System Crafters. In that order. Check this config creator :: https://emacs.amodernist.com/ Learn Elisp :: https://www.math.utah.edu/docs/info/emacs-lisp-intro_toc.html or http://www.xahlee.info/emacs/emacs/elisp_basics.html

Table of Contents toc

Dependencies

Packages

M-x package-refresh-contents

  • latex stuff
  • Iosevka fonts

    apt install texlive-latex-extra texlive
    
  • fonts
  • apt install fonts-{firacode,hack,monofur,mononoki,terminus,inconsolata}
  • for mu4e (email client)
  • apt install libgmime-3.0-dev libxapian-dev guile-2.2-dev html2text xdg-utils isync

    Pip

    Minimal configuration

    Reduce startup time

      Are a pain to install but they are compact and beutiful
    • Instructions
    • Download fonts from here
    • Unarchive :: tar -xavf iosevka-fonts.tar.gz --one-top-level
    • Move unarchived folder (you may need to use sudo) :: mv iosevka-fonts /usr/share/fonts
    • Change permissions :: chmod +rx -R /usr/share/fonts/iosevka-fonts
    • Install pip :: apt install python3-pip
    • Install with pip :: pip3 install Pygments pyright lsp black
    • Increases Garbage Collection During Startup

    (setq startup/gc-cons-threshold gc-cons-threshold) (setq gc-cons-threshold most-positive-fixnum) (defun startup/reset-gc () (setq gc-cons-threshold startup/gc-cons-threshold)) (add-hook 'emacs-startup-hook 'startup/reset-gc)

    Enviorments

    (setenv "GPG_AGENT_INFO" nil) (setenv "EDITOR" "emacsclient") (setenv "VISUAL" "emacsclient")

    ;; https://www.emacswiki.org/emacs/TrampMode#h5o-9 (eval-after-load 'tramp '(setenv "SHELL" "/bin/bash"))

    Remapping some keys

    ;; kill current buffer without asking (global-set-key [remap kill-buffer] 'kill-current-buffer)

    ;; maybe i will use it someday (global-set-key (kbd "C-_") 'undo-only)

    ;; Save and kill emacs or daemon by this keybinding (global-set-key [remap save-buffers-kill-terminal] 'save-buffers-kill-emacs)

    ;; setting stuff for easier regex keybindings (global-set-key [remap isearch-forward] 'isearch-forward-regexp) (global-set-key [remap isearch-backward] 'isearch-backward-regexp) (global-set-key [remap query-replace] 'query-replace-regexp)

    (global-unset-key (kbd "C-z"))

    Misc settings

    (setq scroll-conservatively 100) (setq ring-bell-function 'ignore) (when window-system (global-hl-line-mode t)) (when window-system (global-prettify-symbols-mode t)) (global-subword-mode 1) (setq sentence-end-double-space nil)

    ;; (global-highlight-changes-mode t) (setq-default indent-tabs-mode nil) (display-battery-mode t)

    ;; enable blinking cursor everywhere and blink forever (blink-cursor-mode 1) (setq blink-cursor-blinks 0)

    ;; clock (setq display-time-24hr-format t) (display-time-mode 1)

    ;; set backup directory (setq backup-directory-alist '((".*" . "~/.emacs.d/auto-save-list/")))

    ;; replace 'yes' and 'no' with 'y' and 'n' (defalias 'yes-or-no-p 'y-or-n-p)

    ;; always ":ensure t" for use-package (setq use-package-always-ensure t)

    ;; get rid of gui bars (tool-bar-mode -1) (menu-bar-mode -1) (scroll-bar-mode -1)

    (recentf-mode 1)

    ;; always follow symlins (setq vc-follow-symlinks nil)

    ;; Save what you enter into minibuffer prompts (setq history-length 25) (savehist-mode 1)

    ;; Remember and restore the last cursor location of opened file (save-place-mode 1)

    ;; Don't pop up UI dialogs when prompting (setq use-dialog-box nil)

    ;; fixes displaying emacs windows/frames in some wms (setq frame-resize-pixelwise t) (windmove-default-keybindings) (winner-mode) (setq isearch-lazy-count t) (setq isearch-lazy-highlight t) (setq x-gtk-use-system-tooltips nil) (setq x-gtk-file-dialog-help-text nil) (setq x-stretch-cursor t)

    ;; ;; focus follows mouse ;; (setq mouse-autoselect-window t)

    ;; ;; no lockfiles ;; (setq create-lockfiles nil)

    ;; normal regex, no more double escape slashes (setq reb-re-syntax 'string)

    ;; moves along with incremental output (setq compilation-scroll-output t)

    ;; install aspell-pl (setq ispell-dictionary "polish")

    ;; wrap long lines in all buffers by default (setq-default truncate-lines nil)

    ;; view image rather than open them to edit (auto-image-file-mode t) (setq image-animate-loop t) (setq image-dired-external-viewer "/usr/bin/sxiv -a") ;; (add-hook 'image-mode-hook 'image-toggle-animation) (setq epg-gpg-program "gpg2") (delete-selection-mode 1)

    ;; Prefer horizontal split (set-variable 'split-height-threshold nil t) (set-variable 'split-width-threshold 40 t)

    ;; (desktop-save-mode 1) ;; (add-to-list 'desktop-locals-to-save 'buffer-undo-list) ;; ;; (add-to-list 'session-locals-include 'buffer-undo-list) ;; (desktop-read)

    On save

    ;; Make files with shebang executable (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)

    ;; (defun user/collapse-blank-lines (start end) ;; (interactive "r") ;; (replace-regexp "^\n\\{2,\\}" "\n" nil start end)) ;; (add-hook 'before-save-hook 'user/collapse-blank-lines)

    ;; big files like org indent loong so this is overkill ;;(add-hook 'before-save-hook (lambda () (indent-region (point-min) (point-max) nil)))

    ;; ;; or ;; (add-hook 'before-save-hook (lambda () ;; (when ;; ;; (or prog-mode-map) ;; (derived-mode-p major-mode 'prog-mode) ;; (indent-region (point-min) (point-max) nil))))

    ;; ;; make above function indent every buffer with editable text (not viev only) when shorter that 1000 lines of code or something

    Lines

    C-x x prefix

    ;; line numbers (not everywhere) (add-hook 'prog-mode-hook 'display-line-numbers-mode) (add-hook 'text-mode-hook 'display-line-numbers-mode) (setq-default display-line-numbers-type 'relative)

    (global-set-key (kbd "C-x x n") 'display-line-numbers-mode) (global-set-key (kbd "C-x x t") 'toggle-truncate-lines)

    ;; automatically break long lines (global-set-key (kbd "C-x x b") #'auto-fill-mode)

    Autofill opened brackets (electric)

    (setq electric-pair-pairs '((?\{ . ?\}) (?\[ . ?\]) (?\' . ?\'))) (electric-pair-mode t)

    Set UTF-8 encoding everywhere

    (setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8)

    Set font and size

    Using Iosevka font because its thin

    (custom-set-faces '(default ((t (:inherit nil :height 150 :family "Iosevka")))))

    ;; ;; Setting fall-back fonts ;; (set-fontset-font t nil "Courier New" nil 'append)

    ;; (set-face-attribute 'default nil :font "Iosevka" :height 150) ;; (set-face-attribute 'fixed-pitch nil :font "ProggyTinyTT" :height 200) ;; (set-face-attribute 'variable-pitch nil :font "Fira Code Retina" :height 150 :weight 'regular)

    eww

    Stolen from here

    ;; ;; setting search engine ;; (setq eww-search-prefix "https://search.brave.com/search?q=")

    (with-eval-after-load 'eww

    (setq-local endless/display-images t)

    (defun endless/toggle-image-display () "Toggle images display on current buffer." (interactive) (setq endless/display-images (null endless/display-images)) (endless/backup-display-property endless/display-images))

    (defun endless/backup-display-property (invert &optional object) "Move the 'display property at POS to 'display-backup. Only applies if display property is an image. If INVERT is non-nil, move from 'display-backup to 'display instead. Optional OBJECT specifies the string or buffer. Nil means current buffer." (let* ((inhibit-read-only t) (from (if invert 'display-backup 'display)) (to (if invert 'display 'display-backup)) (pos (point-min)) left prop) (while (and pos (/= pos (point-max))) (if (get-text-property pos from object) (setq left pos) (setq left (next-single-property-change pos from object))) (if (or (null left) (= left (point-max))) (setq pos nil) (setq prop (get-text-property left from object)) (setq pos (or (next-single-property-change left from object) (point-max))) (when (eq (car prop) 'image) (add-text-properties left pos (list from nil to prop) object))))))

    (defun user/eww-toggle-images () "Toggle whether images are loaded and reload the current page fro cache." (interactive) (setq-local shr-inhibit-images (not shr-inhibit-images)) (eww-reload t) (message "Images are now %s" (if shr-inhibit-images "off" "on")))

    (define-key eww-mode-map (kbd "I") #'user/eww-toggle-images) (define-key eww-link-keymap (kbd "I") #'user/eww-toggle-images)

    ;; minimal rendering by default (setq-default shr-inhibit-images t) ; toggle with `I` (setq-default shr-use-fonts nil) ; toggle with `F`

    );end with eveal after load eww

    calendar and diary

    (add-hook 'calendar-mode-hook #'calendar-mark-holidays) (add-hook 'calendar-mode-hook #'diary-mark-entries) (add-hook 'calendar-load-hook (lambda () (calendar-set-date-style 'european))) (setq european-calendar-style 't) (setq calendar-week-start-day 1 calendar-day-name-array ["Niedziela" "Poniedziałek" "Wtorek" "Środa" "Czwartek" "Piątek" "Sobota"] calendar-month-name-array ["Styczeń" "Luty" "Marzec" "Kwiecień" "Maj" "Czerwiec" "Lipiec" "Sierpień" "Wrzesień" "Październik" "Listopad" "Grudzień"]) (setq calendar-holidays `( ;; State holidays (holiday-fixed 1 1 "New Year") (holiday-fixed 1 7 "Orthodox Christmas") (holiday-fixed 2 23 "Defender of the Fatherland and Armed Forces day") (holiday-fixed 3 8 "International Women's Day") (holiday-fixed 5 1 "International Labor Day") (holiday-fixed 5 9 "Victory Day") (holiday-fixed 7 3 "Independence Day") (holiday-fixed 11 7 "October Revolution Day") (holiday-fixed 12 25 "Catholic Christmas")))

    ;; https://www.emacswiki.org/emacs/CalendarLocalization#h5o-47 ;; 1 Jan New Year's Day National holiday ;; 6 Jan Epiphany National holiday ;; 14 Feb Valentine's Day Observance ;; 20 Mar March Equinox Season ;; 15 Apr Good Friday Observance ;; 16 Apr Holy Saturday Observance ;; 17 Apr Easter Sunday National holiday ;; 18 Apr Easter Monday National holiday ;; 1 May Labor Day / May Day National holiday ;; 2 May Day of the Flag Observance ;; 3 May Constitution Day National holiday ;; 26 May Mother's Day Observance ;; 1 Jun Children’s Day Observance ;; 5 Jun Whit Sunday National holiday ;; 16 Jun Corpus Christi National holiday ;; 21 Jun June Solstice Season ;; 23 Jun Father's Day Observance ;; 15 Aug Assumption of Mary National holiday ;; 23 Sep September Equinox Season ;; 1 Nov All Saints' Day National holiday ;; 11 Nov Independence Day National holiday ;; 21 12 December Solstice Season ;; 24 12 Christmas Eve Observance ;; 25 12 Christmas Day National holiday ;; 26 12 Second Day of Christmas National holiday ;; 27 12 National Day of the Victorious Greater Poland Uprising Observance ;; 31 12 New Year's Eve Observance

    COMMENT cmus

    (if (require 'cmus "~/path/to/cmus.el" t) (setq cmus-command "/usr/bin/cmus-remote"))

    COMMENT Eshell

    Prompt

    (setq eshell-prompt-regexp "^[^αλ\n]*[αλ] ") (setq eshell-prompt-function (lambda nil (concat (if (string= (eshell/pwd) (getenv "HOME")) (propertize "~" 'face `(:foreground "#99CCFF")) (replace-regexp-in-string (getenv "HOME") (propertize "~" 'face `(:foreground "#99CCFF")) (propertize (eshell/pwd) 'face `(:foreground "#99CCFF")))) (if (= (user-uid) 0) (propertize " α " 'face `(:foreground "#FF6666")) (propertize " λ " 'face `(:foreground "#A6E22E"))))))

    (setq eshell-highlight-prompt nil)

    Aliases

    (defalias 'open 'find-file-other-window) (defalias 'clean 'eshell/clear-scrollback)

    Open files as root

    (defun eshell/sudo-open (filename) "Open a file as root in Eshell." (let ((qual-filename (if (string-match "^/" filename) filename (concat (expand-file-name (eshell/pwd)) "/" filename)))) (switch-to-buffer (find-file-noselect (concat "/sudo::" qual-filename)))))

    E-mail Client

    mu4e

    Installation

    Install mu (git repository way)

    I used this: https://www.djcbsoftware.nl/code/mu/mu4e/Getting-started.html This may be helpful: http://cachestocaches.com/2017/3/complete-guide-email-emacs-using-mu-and-/ You can evaluate all of the source blocks or copy and execute them yourself Update :: now im using mbsync rather than offlineimap

    # but first... lets remove old one if there is installed, it may create issues like incompatible versions (arch probably dont have this issue) apt purge -y mu4e # and now we can install mu, if you're using arch mu is in AUR git clone git://github.com/djcb/mu.git /tmp/mu cd /tmp/mu ./autogen.sh && make sudo make install

    Setting mbsync

    Put this in ~/.mbsyncrc (only text inside parentheses), change username and password for your own It's config for 2 accounts

    echo 'IMAPAccount gmail Host imap.gmail.com User zadca12@gmail.com PassCmd "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.password-store/mbsync/gmail.gpg" SSLType IMAPS CertificateFile /etc/ssl/certs/ca-certificates.crt

    IMAPStore gmail-remote Account gmail

    MaildirStore gmail-local Subfolders Verbatim Path ~/.mail/gmail/ Inbox ~/.mail/gmail/Inbox

    Channel gmail Master :gmail-remote: Slave :gmail-local: Patterns * ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail" Create Both SyncState *

    IMAPAccount outlook Host outlook.office365.com User 150998@student.uwm.edu.pl PassCmd "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.password-store/mbsync/outlook.gpg" SSLType IMAPS CertificateFile /etc/ssl/certs/ca-certificates.crt

    IMAPStore outlook-remote Account outlook

    MaildirStore outlook-local Subfolders Verbatim Path ~/.mail/outlook/ Inbox ~/.mail/outlook/Inbox

    Channel outlook Master :outlook-remote: Slave :outlook-local: Create Both SyncState *' > ~/.mbsyncrc

    Let's download our email and initialize mu in specified directory in config above.

    # mbsync -a & mu init --maildir=~/.mail --my-address=zadca12@gmail.com --my-address=150998@student.uwm.edu.pl mu info mu index

    Configuration

    Just make sure the path is correct

    find / -mount -type d -name mu4e 2>/dev/null
    

    (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e") (global-set-key (kbd "C-c o m") 'mu4e) (load-file "~/.emacs.d/local/mu4e-config.el")

    TODO COMMENT gnus

    Configuration

    Check this :: https://github.com/redguardtoo/mastering-emacs-in-one-year-guide/blob/master/gnus-guide-en.org#why-optional mail client and rss reader in one

    (setq user-mail-address "zadca12@gmail.com" user-full-name "Adam Salwowski")

    ;; (setq mail-sources '((pop :server "pop.provider.org" ;; :user "you" ;; :password "secret")))

    ;; machine foo.bar.com login your_username1 password your_pass1 ;; machine localhost login your_username2 password your_pass2 (setq send-mail-function 'smtpmail-send-it message-send-mail-function 'smtpmail-send-it smtpmail-smtp-server "your.smtp-server.com")

    Dired

    dired

    http://xahlee.info/emacs/emacs/emacs_diredplus_mode.html https://writequit.org/denver-emacs/presentations/2016-05-24-elpy-and-dired.html https://p.sicp.me/mijxs.emacs

    (use-package dired :ensure nil :hook (dired-mode . dired-hide-details-mode) (dired-mode . hl-line-mode) (dired-mode . (lambda () (setq truncate-lines t))) :config (setq dired-listing-switches "-AFgGh --group-directories-first") (setq ls-lisp-dirs-first t) (setq dired-recursive-copies 'always) (setq dired-recursive-deletes 'always) (setq dired-ls-F-marks-symlinks t) (setq delete-by-moving-to-trash t)

    ;; Revert buffers when the underlying file has changed (global-auto-revert-mode 1) (setq auto-revert-verbose nil) (setq dired-auto-revert-buffer t) (setq dired-auto-revert-buffer (lambda (_dir) (null (cdr dired-subdir-alist)))) (setq auto-revert-use-notify nil) (setq global-auto-revert-non-file-buffers t))

    ;; compress ;; (add-to-list 'dired-compress-files-alist ;; '("\\.7z\\'" . "7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on %o %i"))

    ;; (use-package dired-async ;; :ensure nil ;; :diminish ;; :hook (dired-mode . dired-async-mode))

    dired-x

    (use-package dired-x :ensure nil :init (setq-default dired-omit-files-p t) :hook (dired-mode . dired-omit-mode) :config

    (dolist (x '(".DS_Store" ".git" ".lot" ".tce" ".aux" ".log" ".toc" ".*")) (add-to-list 'dired-omit-extensions x))

    (dolist (x '("^_minted-.*$" "^__pycache__$" "^\\.git$" "^\\.log$")) (setq dired-omit-files (concat dired-omit-files "\\|" x)))

    ;; ;; delete buffer after deleting a file (not works like expected) ;; (advice-add 'dired-do-delete :after (lambda (&rest arg) (kill-buffer))) ;; (setq dired-clean-up-buffers-too t) (setq dired-clean-confirm-killing-deleted-buffers nil)

    (defvar audio-regex (rx ?. (or "mp3" "aac" "m4a" "wav" "flac" "ogg") eol)) (defvar image-regex (rx ?. (or (seq "jp" (? "e") "g") "png" "gif" "webp" "bmp") eol)) (defvar video-regex (rx ?. (or "mp4" "webm" "mkv" "mov" "flv" "wmv" "avi" "ogv") eol)) (defvar office-regex (rx ?. (or (seq "doc" (? "x")) "xlsx" "odt" "rtf" "ppt") eol)) (defvar windows-regex (rx ?. (or "exe" "msi") eol)) (defvar pdf-regex (rx ?. (or "pdf" "djvu" "cbz" "cbr") eol)) (defvar tar-regex (rx ?. (or "tar.gz" "tar.bz" "tar.bzip2" "tar.zst" "tar.zstd") eol)) (defvar arc-regex (rx ?. (or "zip" "rar" "7z") eol)) ;; case insensitive extensions (setq dired-guess-shell-case-fold-search t) (setq dired-guess-shell-alist-user `((,image-regex "sxiv -a ") (,video-regex "mpv *") (,audio-regex "mpv --volume=50 *") (,windows-regex "wine *") (,pdf-regex "zathura *") (,tar-regex "tar -xavf --one-file-system --one-top-level") (,arc-regex "aunpack -D *") (,office-regex "libreoffice --nologo --norestore --view *"))))

    ;; (defun user/dired-dotfiles-toggle () ;; "Show/hide dot-files" ;; (interactive) ;; (when (equal major-mode 'dired-mode) ;; (if (or (not (boundp 'dired-dotfiles-show-p)) dired-dotfiles-show-p) ; if currently showing ;; (progn ;; (set (make-local-variable 'dired-dotfiles-show-p) nil) ;; (message "h") ;; (dired-mark-files-regexp "^\\\.") ;; (dired-do-kill-lines)) ;; (progn (revert-buffer) ; otherwise just revert to re-show ;; (set (make-local-variable 'dired-dotfiles-show-p) t))))) ;; (bind-key "C-c ." 'user/dired-dotfiles-toggle dired-mode-map)

    Functions used

    (defun user/dired-open-random () (interactive) (let ((num-of-lines (count-lines (point-min) (point-max)))) (beginning-of-buffer) (dired-next-line 2) (dired-next-line (random (- num-of-lines 2))) (when (string= "directory\n" (shell-command-to-string (format "file -b %s" (dired-get-filename)))) (dired-view-file)))) (define-key dired-mode-map (kbd "r") #'user/dired-open-random)

    COMMENT Functions commented

    (put 'dired-find-alternate-file 'disabled nil) (defun user/open-files-in-program (program rx &optional num-arg-p pos-offset) "Run shell command and pass all files matching regex in current Dired buffer as an argument" (let ((file-list (progn (dired-toggle-marks) (cl-remove-if-not (lambda (s) (string-match rx s)) (dired-get-marked-files)))) (file-position nil)) (dired-toggle-marks) (when num-arg-p (setq file-position (cl-position (dired-get-filename) file-list :test 'equal))) (unless pos-offset (setq pos-offset 0)) (call-process-shell-command (format "%s%s %s&" program (if num-arg-p (if (string-suffix-p "=" program) (+ file-position pos-offset) (concat " " (number-to-string (+ file-position pos-offset)))) "") (string-join (mapcar (lambda (s) (concat "\"" s "\"")) file-list) " ")) nil 0)))

    (define-key dired-mode-map (kbd "P") (lambda () (interactive) (find-alternate-file "..")))

    (define-key dired-mode-map (kbd "f") (lambda () (interactive) (let ((file (dired-get-filename))) (cond ((file-directory-p file) (dired-find-file)) ((string-match image-regex file) (user/open-files-in-program "sxiv -ab -n" image-regex t 1)) ((string-match video-regex file) (user/open-files-in-program "mpv --playlist-start=" video-regex t)) ((string-match audio-regex file) (user/open-files-in-program "mpv --playlist-start=" audio-regex t)) (t (dired-find-file))))))

    (defun anon/dired-open-file () "Open a dired file by mime type. The `nohup' shell command means that these external processes will persist if Emacs is killed. See the man page `nohup (1)' for details." (interactive) (let* ((filename (dired-get-filename nil t)) (filequote (shell-quote-argument filename)) (mimetype (shell-command-to-string (concat "file --mime-type " filequote " -b")))) (cl-flet ((view-document () (call-process-shell-command (concat "nohup zathura " filequote " >/dev/null 2>&1 &") nil nil nil)) (play-video () (call-process-shell-command (concat "nohup mpv --loop-file " filequote " >/dev/null 2>&1 &") nil nil nil)) (display-in-browser () (call-process-shell-command (concat "nohup $BROWSER " filequote " >/dev/null 2>&1 &") nil nil nil)) (play-audio () (progn (vterm); We don't want a headless mpv to persist, so no nohup here. (vterm-send-string (concat "mpv --no-audio-display " filequote)) (vterm-send-return) (delete-other-windows))) (add-torrent () (progn (transmission-add filename) (transmission) (delete-other-windows)))) (cond ((or (string-match "djvu" mimetype) (string-match "epub" mimetype) (string-match "pdf" mimetype)) (view-document)) ((string-match "audio" mimetype) (play-audio)) ((or (string-match "video" mimetype) (string-match "gif" mimetype)) (play-video)) ((or (string-match "svg" mimetype) (string-match "html" mimetype)) (display-in-browser)) ((string-match "text" mimetype); Needs to be below HTML (view-file filename)) ((string-match "image" mimetype); Needs to be below DJVU, SVG, etc (find-file filename)); Emacs as an image viewer? ((string-match "bittorrent" mimetype) (add-torrent))))))

    dired-narrow

    (use-package dired-narrow :bind (:map dired-mode-map ("/" . dired-narrow)))

    all-the-icons

    ;; Run M-x all-the-icons-install-fonts (use-package all-the-icons :if (display-graphic-p))

    (use-package all-the-icons-dired :diminish ;; :after all-the-icons :hook (dired-mode . all-the-icons-dired-mode) :config (setq all-the-icons-dired-monochrome nil))

    dired-rsync

    (use-package dired-rsync :config (bind-key "C-c C-r" 'dired-rsync dired-mode-map))

    Org mode

    TODO Tips

    TODO COMMENT ox-publish

    MAKE elecrtic brackets not work in org-mode | TAB complete | Expands to … | |--------------+-----------------------------------------| | #+begin_src shell :results silent :dir /sudo::
    lets you run code with sudo privileges without output
    #+begin_src shell :results output code :wrap src text
    wraps output and regard and simple text
  • <C-c C-c> on a header results to specify :toc: and many more
  • (use-package ox-publish :ensure nil)

    org

    Setting to easier source block expansions

    ;; (use-package org-tempo ;; :ensure nil ;; :config ;; ;; source block expansion ;; (add-to-list 'org-structure-template-alist '(("el" . "src emacs-lisp") ;; ("py" . "src python")))) (use-package org :ensure nil :hook (org-mode . org-indent-mode) :config (set-default 'org-descriptive-links nil) ;; https://stackoverflow.com/questions/11670654/how-to-resize-images-in-org-mode (setq org-image-actual-width (list 300)) ;; (setq org-html-inline-images t) )

    ;; automatic indent on save in source blocks, sometimes may fuck up RESULTS formatting (setq org-src-tab-acts-natively t)

    ;; open edit config in current window (setq org-src-window-setup 'current-window)

    (setq org-directory "~/.dotfiles/.local/org") ;; (setq org-agenda-files (file-expand-wildcards "~/.dotfiles/.local/org/*.org")) (setq org-agenda-files (file-expand-wildcards (concat org-directory "/*.org"))) ;; (setq org-log-done 'note) (setq org-log-done 'time)

    (setq org-confirm-babel-evaluate nil) (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (shell . t) (scheme . t) (python . t) (ledger . t) (sed . t) (awk . t) (sql . t) (latex . t) (R . t) (clojure . t)))

    (setq org-todo-keywords '((sequence "TODO(t)" "WORKING(w)" "|" ; Separates "active" and "inactive" states. "DONE(d)" "CANCELLED(c)" )))

    (setq org-export-allow-bind-keywords t) (setq org-startup-truncated t)

    org-bullets

    (use-package org-bullets :hook (org-mode . org-bullets-mode) :config (setq org-bullets-bullet-list '("◉" "○" "■" "◆" "▲" "▶")))

    ox-latex

    ;; Org latex exporter (use-package ox-latex :ensure nil ;; its part of org-mode :defer t :config ;; default image width (setq org-latex-image-default-width "0.8\\linewidth")

    ;; Define how minted (highlighted src code) is added to src code blocks (setq org-latex-listings 'minted) ;; for \FloatBarrier (add-to-list 'org-latex-packages-alist '("" "placeins")) ;; wrap text in tables (add-to-list 'org-latex-packages-alist '("" "tabularx")) ;; Add minted package to every LaTeX header (add-to-list 'org-latex-packages-alist '("" "minted")) (setq org-latex-minted-options '( ("frame" "lines") ("linenos=true") ;; Prevent src block line too long, truncates them ("breaklines" "true") ("breakanywhere" "true") )) ;; Append -shell-escape so pdflatex exports minted correctly (add-to-list 'org-latex-pdf-process (replace-regexp-in-string "%latex " "%latex -shell-escape " (car org-latex-pdf-process)))

    (setq org-latex-pdf-process '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))

    (setq org-src-fontify-natively t))

    COMMENT toc-org

    Table of contents in org-mode

    (use-package toc-org :hook (org-mode . toc-org-mode) (markdown-mode . toc-org-mode) :bind ("C-c C-o" . toc-org-markdown-follow-thing-at-point))

    ;; (if (require 'toc-org nil t) ;; (progn ;; (add-hook 'org-mode-hook 'toc-org-mode)

    ;; ;; enable in markdown, too ;; (add-hook 'markdown-mode-hook 'toc-org-mode) ;; (define-key markdown-mode-map (kbd "\C-c\C-o") 'toc-org-markdown-follow-thing-at-point)) ;; (warn "toc-org not found"))

    COMMENT pdf-tools

    Install dependencies by M-x pdf-tools-install

    (use-package pdf-tools)

    COMMENT gnuplot

    For creating graphs from org-mode tables

    (use-package gnuplot) (use-package gnuplot-mode :after gnuplot)

    ;; You can automatically enable gnuplot-mode using the snippet below: (autoload 'gnuplot-mode "gnuplot" "Gnuplot major mode" t) (autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot-mode" t) (setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode)) auto-mode-alist))

    COMMENT ox-extra

    Structuring the Org Document

    For building CV https://www.aidanscannell.com/post/org-mode-resume/

    (after! org (use-package! ox-extra :config (ox-extras-activate '(latex-header-blocks ignore-headlines))))

    Global Configuration for Org-Mode's LaTeX Exporter

    (after! org ;; Import ox-latex to get org-latex-classes and other funcitonality ;; for exporting to LaTeX from org (use-package! ox-latex :init ;; code here will run immediately :config ;; code here will run after the package is loaded (setq org-latex-pdf-process '("pdflatex -interaction nonstopmode -output-directory %o %f" "bibtex %b" "pdflatex -interaction nonstopmode -output-directory %o %f" "pdflatex -interaction nonstopmode -output-directory %o %f")) (setq org-latex-with-hyperref nil) ;; stop org adding hypersetup{author..} to latex export ;; (setq org-latex-prefer-user-labels t)

    ;; deleted unwanted file extensions after latexMK (setq org-latex-logfiles-extensions (quote ("lof" "lot" "tex~" "aux" "idx" "log" "out" "toc" "nav" "snm" "vrb" "dvi" "fdb_latexmk" "blg" "brf" "fls" "entoc" "ps" "spl" "bbl" "xmpi" "run.xml" "bcf" "acn" "acr" "alg" "glg" "gls" "ist")))

    (unless (boundp 'org-latex-classes) (setq org-latex-classes nil)))

    Local Configuration for Org-Mode CV File

    
      (add-to-list 'org-latex-classes
                   '("altacv" "\\documentclass[10pt,a4paper,ragged2e,withhyper]{altacv}
    
      % Change the page layout if you need to
      \\geometry{left=1.25cm,right=1.25cm,top=1.5cm,bottom=1.5cm,columnsep=1.2cm}
    
      % Use roboto and lato for fonts
      \\renewcommand{\\familydefault}{\\sfdefault}
    
      % Change the colours if you want to
      \\definecolor{SlateGrey}{HTML}{2E2E2E}
      \\definecolor{LightGrey}{HTML}{666666}
      \\definecolor{DarkPastelRed}{HTML}{450808}
      \\definecolor{PastelRed}{HTML}{8F0D0D}
      \\definecolor{GoldenEarth}{HTML}{E7D192}
      \\colorlet{name}{black}
      \\colorlet{tagline}{PastelRed}
      \\colorlet{heading}{DarkPastelRed}
      \\colorlet{headingrule}{GoldenEarth}
      \\colorlet{subheading}{PastelRed}
      \\colorlet{accent}{PastelRed}
      \\colorlet{emphasis}{SlateGrey}
      \\colorlet{body}{LightGrey}
    
      % Change some fonts, if necessary
      \\renewcommand{\\namefont}{\\Huge\\rmfamily\\bfseries}
      \\renewcommand{\\personalinfofont}{\\footnotesize}
      \\renewcommand{\\cvsectionfont}{\\LARGE\\rmfamily\\bfseries}
      \\renewcommand{\\cvsubsectionfont}{\\large\\bfseries}
    
      % Change the bullets for itemize and rating marker
      % for \cvskill if you want to
      \\renewcommand{\\itemmarker}{{\\small\\textbullet}}
      \\renewcommand{\\ratingmarker}{\\faCircle}
      "
    
                     ("\\cvsection{%s}" . "\\cvsection*{%s}")))
    

    COMMENT org-roam

    (use-package org-roam :custom (org-roam-directory (file-truename "~/.dotfiles/.local/org/")) :bind (("C-c n l" . org-roam-buffer-toggle) ("C-c n f" . org-roam-node-find) ("C-c n g" . org-roam-graph) ("C-c n i" . org-roam-node-insert) ("C-c n c" . org-roam-capture) ;; Dailies ("C-c n j" . org-roam-dailies-capture-today)) :config ;; If you're using a vertical completion framework, you might want a more informative completion interface (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) (org-roam-db-autosync-mode) ;; If using org-roam-protocol (require 'org-roam-protocol))

    Programming Languages

    Compiling

    Taken from here.

    (use-package compile :ensure nil :hook (c-mode-common . (lambda () (setq-local compile-command (concat "gcc -xc++ -lstdc++ -shared-libgcc " (shell-quote-argument buffer-file-name) " && ./a.out")))) ;; (python-mode . (lambda () ;; (setq-local compile-command ;; (concat py-python-command " " ;; (shell-quote-argument buffer-file-name))))) ;; (sh-mode . (lambda () ;; (setq-local compile-command ;; (shell-quote-argument buffer-file-name)))) :config (defun notify-compilation-result(buffer msg) "Notify that the compilation is finished, close the compilation buffer if the compilation is successful, and set the focus back to Emacs frame" (if (string-match "^finished" msg) (progn ;; (delete-windows-on buffer) (tooltip-show "\n Compilation Successful :-) \n ")) (tooltip-show "\n Compilation Failed :-( \n ")) (setq current-frame (car (car (cdr (current-frame-configuration))))) (select-frame-set-input-focus current-frame))

    (add-to-list 'compilation-finish-functions 'notify-compilation-result))

    COMMENT Shell & Bash

    COMMENT C & C++

    (use-package ccls :config (setq ccls-executable "ccls") (setq-default flycheck-disabled-checkers '(c/c++-clang c/c++-cppcheck c/c++-gcc)) (setq ccls-sem-highlight-method 'overlay) :hook ((c-mode c++-mode) . (lambda () (require 'ccls) (lsp))))

    (setq-default c-basic-offset 4)

    Python

    python

    (use-package python :ensure nil :config (setq py-python-command "python3") (setq python-shell-interpreter "python3"))

    ;; autoformating on save (use-package blacken :after python :hook (python-mode . blacken-mode))

    (use-package lsp-pyright :after lsp-mode :hook (python-mode . (lambda () (require 'lsp-pyright) (lsp))) :config (setq lsp-pyright-python-executable-cmd py-python-command))

    jinja2-mode

    (use-package jinja2-mode :config (setq jinja2-enable-indent-on-save t))

    Markdown

    (use-package markdown-mode :mode (("README\\.md\\'" . gfm-mode) ("\\.md\\'" . markdown-mode) ("\\.markdown\\'" . markdown-mode)) :init (setq markdown-command "multimarkdown"))

    LaTeX

    (use-package auctex :hook (TeX-mode . TeX-PDF-mode) ;; (TeX-mode . company-mode) :init (setq reftex-plug-into-AUCTeX t) (setq TeX-parse-self t) (setq-default TeX-master nil)

    (setq TeX-open-quote "<<") (setq TeX-close-quote ">>") (setq TeX-electric-sub-and-superscript t) (setq font-latex-fontify-script nil) (setq TeX-show-compilation nil)

    (setq preview-scale-function 1.5) (setq preview-gs-options '("-q" "-dNOSAFER" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4"))

    ;; (setq TeX-view-program-select-evince '("i3" "zathura")) (setq reftex-label-alist '(AMSTeX)))

    (use-package company-auctex :init (company-auctex-init))

    ;; (use-package company-math ;; :init ;; (add-to-list 'company-backends 'company-math))

    (use-package company-reftex :init (add-to-list 'company-backends 'company-reftex-citations) (add-to-list 'company-backends 'company-reftex-labels))

    Docker

    (use-package dockerfile-mode :custom (setq dockerfile-mode-command "docker") (put 'dockerfile-image-name 'safe-local-variable #'stringp))

    (use-package yaml-mode :bind (:map yaml-mode-map ("C-m" . newline-and-indent)) :config (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode)))

    COMMENT SQL

    (use-package sql :ensure nil :config (add-to-list 'sql-product-alist '(sqlite :name "SQLite" :free-software t :font-lock sql-mode-sqlite-font-lock-keywords :sqli-program sql-sqlite-program :sqli-options sql-sqlite-options :sqli-login sql-sqlite-login-params :sqli-comint-func sql-comint-sqlite :list-all ".tables" :list-table ".schema %s" :completion-object sql-sqlite-completion-object :prompt-regexp "^sqlite> " :prompt-length 8 :prompt-cont-regexp "^ \\.\\.\\.> " :input-filter sql-placeholders-filter)))

    HTML / CSS / JavaScript

    js2-mode

    (use-package js2-mode :config (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)) (add-hook 'js-mode-hook 'js2-minor-mode) (add-to-list 'interpreter-mode-alist '("node" . js2-mode)))

    skewer-mode

    (use-package skewer-mode :config (add-hook 'js2-mode-hook 'skewer-mode) (add-hook 'css-mode-hook 'skewer-css-mode) (add-hook 'html-mode-hook 'skewer-html-mode))

    Essential Packages

    COMMENT swiper

    Replacement for isearch

    (use-package swiper :bind ([remap isearch-forward] . swiper) ([remap isearch-backward] . swiper-backward))

    try

    Try package from melpa without adding it to config

    (use-package try)

    diminish

    Let's you to hide modes that would display in mode-line and waste space

    (use-package diminish :config (diminish 'subword-mode) (diminish 'highlight-changes-mode) (diminish 'org-indent-mode) (diminish 'visual-line-mode))

    t
    

    which-key

    (use-package which-key :diminish :config (which-key-mode))

    vectico

    ;; Enable vertico (use-package vertico :init (vertico-mode)

    ;; Different scroll margin ;; (setq vertico-scroll-margin 0)

    ;; Show more candidates ;; (setq vertico-count 20)

    ;; Grow and shrink the Vertico minibuffer ;; (setq vertico-resize t)

    ;; Optionally enable cycling for `vertico-next' and `vertico-previous'. ;; (setq vertico-cycle t) )

    ;; A few more useful configurations... (use-package emacs :ensure nil :init ;; Add prompt indicator to `completing-read-multiple'. ;; Alternatively try `consult-completing-read-multiple'. (defun crm-indicator (args) (cons (concat "[CRM] " (car args)) (cdr args))) (advice-add #'completing-read-multiple :filter-args #'crm-indicator)

    ;; Do not allow the cursor in the minibuffer prompt (setq minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt)) (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

    ;; Emacs 28: Hide commands in M-x which do not work in the current mode. ;; Vertico commands are hidden in normal buffers. ;; (setq read-extended-command-predicate ;; #'command-completion-default-include-p)

    ;; Enable recursive minibuffers (setq enable-recursive-minibuffers t))

    ;; Optionally use the `orderless' completion style. (use-package orderless :init ;; Configure a custom style dispatcher (see the Consult wiki) ;; (setq orderless-style-dispatchers '(+orderless-dispatch) ;; orderless-component-separator #'orderless-escapable-split-on-space) (setq completion-styles '(partial-completion orderless basic) completion-category-defaults nil completion-category-overrides '((file (styles . (partial-completion))))))

    COMMENT corfu

    (use-package corfu ;; Optional customizations :custom (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' (corfu-auto t) ;; Enable auto completion ;; (corfu-separator ?\s) ;; Orderless field separator ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match ;; (corfu-preview-current nil) ;; Disable current candidate preview ;; (corfu-preselect-first nil) ;; Disable candidate preselection ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches ;; (corfu-echo-documentation nil) ;; Disable documentation in the echo area ;; (corfu-scroll-margin 5) ;; Use scroll margin

    ;; You may want to enable Corfu only for certain modes. ;; :hook ((prog-mode . corfu-mode) ;; (shell-mode . corfu-mode) ;; (eshell-mode . corfu-mode))

    ;; Recommended: Enable Corfu globally. ;; This is recommended since dabbrev can be used globally (M-/). :init (global-corfu-mode))

    ;; Use dabbrev with Corfu! (use-package dabbrev ;; Swap M-/ and C-M-/ :bind (("M-/" . dabbrev-completion) ("C-M-/" . dabbrev-expand)))

    ;; A few more useful configurations... (use-package emacs :init ;; TAB cycle if there are only few candidates (setq completion-cycle-threshold 3)

    ;; Emacs 28: Hide commands in M-x which do not apply to the current mode. ;; Corfu commands are hidden, since they are not supposed to be used via M-x. ;; (setq read-extended-command-predicate ;; #'command-completion-default-include-p)

    ;; Enable indentation+completion using the TAB key. ;; `completion-at-point' is often bound to M-TAB. (setq tab-always-indent 'complete))

    marginalia

    (use-package marginalia :init (marginalia-mode))

    consult

    This is fucking awesome!!!

    ;; Example configuration for Consult (use-package consult ;; Replace bindings. Lazily loaded due by `use-package'. :bind (;; C-c bindings (mode-specific-map) ("C-c h" . consult-history) ("C-c m" . consult-mode-command) ("C-c k" . consult-kmacro) ;; C-x bindings (ctl-x-map) ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command ("C-x b" . consult-buffer) ;; orig. switch-to-buffer ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer ;; Custom M-# bindings for fast register access ("M-#" . consult-register-load) ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) ("C-M-#" . consult-register) ;; Other custom bindings ("M-y" . consult-yank-pop) ;; orig. yank-pop (" a" . consult-apropos) ;; orig. apropos-command ;; M-g bindings (goto-map) ("M-g e" . consult-compile-error) ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck ("M-g g" . consult-goto-line) ;; orig. goto-line ("M-g M-g" . consult-goto-line) ;; orig. goto-line ("M-g o" . consult-outline) ;; Alternative: consult-org-heading ("M-g m" . consult-mark) ("M-g k" . consult-global-mark) ("M-g i" . consult-imenu) ("M-g I" . consult-imenu-multi) ;; M-s bindings (search-map) ("M-s d" . consult-find) ("M-s D" . consult-locate) ("M-s g" . consult-grep) ("M-s G" . consult-git-grep) ("M-s r" . consult-ripgrep) ("M-s l" . consult-line) ("M-s L" . consult-line-multi) ("M-s m" . consult-multi-occur) ("M-s k" . consult-keep-lines) ("M-s u" . consult-focus-lines) ;; Isearch integration ("M-s e" . consult-isearch-history) :map isearch-mode-map ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string ("M-s l" . consult-line) ;; needed by consult-line to detect isearch ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch ;; Minibuffer history :map minibuffer-local-map ("M-s" . consult-history) ;; orig. next-matching-history-element ("M-r" . consult-history)) ;; orig. previous-matching-history-element

    ;; Enable automatic preview at point in the Completions buffer. This is ;; relevant when you use the default completion UI. :hook (completion-list-mode . consult-preview-at-point-mode)

    ;; The :init configuration is always executed (Not lazy) :init

    ;; Optionally configure the register formatting. This improves the register ;; preview for `consult-register', `consult-register-load', ;; `consult-register-store' and the Emacs built-ins. (setq register-preview-delay 0.5 register-preview-function #'consult-register-format)

    ;; Optionally tweak the register preview window. ;; This adds thin lines, sorting and hides the mode line of the window. (advice-add #'register-preview :override #'consult-register-window)

    ;; Optionally replace `completing-read-multiple' with an enhanced version. (advice-add #'completing-read-multiple :override #'consult-completing-read-multiple)

    ;; Use Consult to select xref locations with preview (setq xref-show-xrefs-function #'consult-xref xref-show-definitions-function #'consult-xref)

    ;; Configure other variables and modes in the :config section, ;; after lazily loading the package. :config

    ;; Optionally configure preview. The default value ;; is 'any, such that any key triggers the preview. ;; (setq consult-preview-key 'any) ;; (setq consult-preview-key (kbd "M-.")) ;; (setq consult-preview-key (list (kbd "") (kbd ""))) ;; For some commands and buffer sources it is useful to configure the ;; :preview-key on a per-command basis using the `consult-customize' macro. (consult-customize consult-theme :preview-key '(:debounce 0.2 any) consult-ripgrep consult-git-grep consult-grep consult-bookmark consult-recent-file consult-xref consult--source-bookmark consult--source-recent-file consult--source-project-recent-file :preview-key (kbd "M-."))

    ;; Optionally configure the narrowing key. ;; Both < and C-+ work reasonably well. (setq consult-narrow-key "<") ;; (kbd "C-+")

    ;; Optionally make narrowing help available in the minibuffer. ;; You may want to use `embark-prefix-help-command' or which-key instead. ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)

    ;; By default `consult-project-function' uses `project-root' from project.el. ;; Optionally configure a different project root function. ;; There are multiple reasonable alternatives to chose from. ;;;; 1. project.el (the default) ;; (setq consult-project-function #'consult--default-project--function) ;;;; 2. projectile.el (projectile-project-root) ;; (autoload 'projectile-project-root "projectile") ;; (setq consult-project-function (lambda (_) (projectile-project-root))) ;;;; 3. vc.el (vc-root-dir) ;; (setq consult-project-function (lambda (_) (vc-root-dir))) ;;;; 4. locate-dominating-file ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git"))) )

    ace-window

    Better switching between multiple windows

    (use-package ace-window :bind (([remap other-window] . ace-window) ("C-x O" . ace-swap-window)))

    company

    Provides autocompletion.

    (use-package company :diminish :init (global-company-mode t) :custom (company-dabbrev-other-buffers t) (company-dabbrev-code-other-buffers t) (company-dabbrev-downcase nil) (company-dabbrev-ignore-case t) (company-show-quick-access t))

    flycheck

    Syntax checking on the fly

    (use-package flycheck :init (global-flycheck-mode t))

    aggressive-indent

    (use-package aggressive-indent :config (global-aggressive-indent-mode 1))

    eldoc

    (use-package eldoc :diminish :hook (after-init . global-eldoc-mode))

    rainbow

    Colorful hex decimals

    (use-package rainbow-mode :diminish :hook (prog-mode . rainbow-mode))

    rainbow-delimiters

    Colorful parentheses

    (use-package rainbow-delimiters :diminish :hook (prog-mode . rainbow-delimiters-mode)) ;; :init ;; (add-hook 'fundamental-mode-hook #'rainbow-delimiters-mode))

    magit

    Interface to the version control system Git

    (use-package transient)

    ;; `diff-hl-mode' highlights uncommitted changes on the side of the ;; window (using the fringe, by default), allows you to jump between ;; the hunks and revert them selectively. (use-package diff-hl :config ;; Add either of the following to your init file. ;; To use it in all buffers: (global-diff-hl-mode)) ;; ;; Only in `prog-mode' buffers, with `vc-dir' integration: ;; (add-hook 'prog-mode-hook 'turn-on-diff-hl-mode) ;; (add-hook 'vc-dir-mode-hook 'turn-on-diff-hl-mode))

    (use-package magit :after (diff-hl transient) :hook (git-commit-setup . git-commit-turn-on-auto-fill) (git-commit-setup . git-commit-turn-on-flyspell) (magit-pre-refresh . diff-hl-magit-pre-refresh) (magit-post-refresh . diff-hl-magit-post-refresh) :config (setq git-commit-fill-column 72) (setq git-commit-summary-max-length 70) ;; (setq magit-completing-read-function #'selectrum-completing-read) (setq magit-diff-paint-whitespace-lines 'both) (setq magit-repository-directories '((("~/.dotfiles" "~/Studia/semestr_6/" "~/.local/bin" "~/.emacs.d") . 0)))

    (put 'magit-log-select-pick :advertised-binding [?\M-c]) (put 'magit-log-select-quit :advertised-binding [?\M-k]))

    COMMENT selectrum

    (use-package selectrum :hook (after-init . selectrum-mode))

    ;; ;; "Your candidates are sorted by frecency. Your most recent choices are saved, ;; ;; and those are sorted first. After that, your most frequent choices are saved, ;; ;; and those are sorted next. The rest of the candidates are sorted by length. ;; ;; This algorithm turns out to do very well in practice while being fast and ;; ;; not very magical." (use-package prescient :after selectrum :config (prescient-persist-mode 1))

    (use-package selectrum-prescient :after (selectrum prescient) :config (selectrum-prescient-mode 1))

    ;; Search without order. ;; (e.g. try M-x emacs time) (use-package orderless :after selectrum :custom (completion-styles (list 'orderless)) (selectrum-refine-candidates-function #'orderless-filter) (selectrum-highlight-candidates-function #'orderless-highlight-matches))

    google-translate

    Im not joking... Its useful but i have to sell the soul to a devil...

    (use-package popup) (use-package google-translate :after popup :bind (("C-c g t" . google-translate-at-point) ("C-c g T" . google-translate-query-translate)) :custom (google-translate-backend-method 'curl) :config (defun google-translate--search-tkk () "Search TKK." (list 430675 2721866130)) (setq google-translate-translation-directions-alist '(("en" . "pl") ("pl" . "en") )))

    drag-stuff

    (use-package drag-stuff :diminish :init (drag-stuff-global-mode 1) :config (drag-stuff-define-keys) (setq drag-stuff-except-modes '(org-mode)))

    projectile

    (use-package projectile :diminish :config (projectile-mode t) (define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map) ;; (setq projectile-track-known-projects-automatically nil) (setq projectile-enable-caching t) (setq projectile-require-project-root t) (setq projectile-dynamic-mode-line nil))

    treemacs

    (use-package treemacs :hook(projectile-mode . treemacs) :config (setq treemacs-width 30) :bind (:map global-map ("C-x t t" . treemacs) ("C-x t 1" . treemacs-select-window)))

    (use-package treemacs-projectile :after (treemacs projectile))

    (use-package treemacs-magit :after treemacs magit)

    Packages that i like

    COMMENT beacon

    commented cuz it breaks formating...

    (use-package beacon :init (beacon-mode 1) :custom (beacon-blink-delay 0.5) (beacon-blink-duration 1) (beacon-size 80))

    yasnippet

    You can always download snippets with command M-x try yasnippet-snippets

    (use-package yasnippet :init (yas-global-mode 1) :custom (yas-snippet-dirs '("~/.emacs.d/snippets")) (yas-reload-all 1)) (use-package yasnippet-snippets :after yasnippet)

    lsp

    Language server. Will provide us with IDE-like features.

    (use-package lsp-mode :init (setq lsp-keymap-prefix "C-c l") ;; if you don't supply a function to the hook keyword, it uses the containing mode :hook (python-mode c-mode-common js2-mode ;; vue-mode yaml-mode) :commands lsp :config (lsp-enable-which-key-integration t) (setq lsp-auto-guess-root t))

    ;; optionally (use-package lsp-ui :after lsp :commands lsp-ui-mode)

    (use-package lsp-treemacs :after (lsp-mode) :commands lsp-treemacs :config (lsp-treemacs-sync-mode 1))

    COMMENT avy

    Comfy character seaching/moving

    (use-package avy :bind ("C-S-s" . avy-goto-char))

    COMMENT sudo-edit

    Edit files as root user by emacs

    (use-package sudo-edit :bind ("C-c s e" . sudo-edit))

    transmission

    https://github.com/holomorph/transmission Very nice transmission client for transmission-daemon, smilar to stig, which I like

    (use-package transmission ;; :custom ;; (transmission-refresh-modes '(transmission-mode ;; transmission-files-mode ;; transmission-info-mode ;; transmission-peers-mode)) ;; :hook (transmission-mode . delete-other-windows) ;; :config ;; (advice-add 'transmission-files-unwant :after 'revert-buffer) ;; (advice-add 'transmission-files-want :after 'revert-buffer) ;; (advice-add 'transmission-toggle :after 'revert-buffer) :bind (("C-c o d" . transmission) (:map transmission-mode-map (("g" . revert-buffer) ("R" . transmission-move))) (:map transmission-files-mode-map (([remap transmission-files-want] . transmission-copy-filename-as-kill)) (([remap transmission-files-unwant] . nil))))) (defun user/full-transmission () (interactive) (transmission) (select-window (get-buffer-window "*transmission*")) (delete-other-windows))

    pass

    Idk... its just werks

    (use-package pass)

    nov

    Ebook (epub) reader in Emacs

    (use-package nov :config (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode)))

    COMMENT dashboard

    (use-package dashboard :config (dashboard-refresh-buffer) (dashboard-setup-startup-hook) (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) (setq dashboard-banner-logo-title "O U R macs") (setq dashboard-startup-banner "~/.emacs.d/logos/logo02.png") (setq dashboard-footer-messages '("\"Tovarich!\"")) ;; (setq dashboard-banner-logo-title "Reichmacs") ;; (setq dashboard-startup-banner "~/.emacs.d/logos/logo04.png") ;; (setq dashboard-footer-messages '("\"Guix rice... Master rice!\"")) (setq dashboard-image-banner-max-height '400) (setq dashboard-image-banner-max-width '400) (setq dashboard-center-content t) (setq dashboard-footer-icon "") (setq dashboard-set-navigator t) (setq dashboard-set-heading-icons t) (setq dashboard-set-file-icons t))

    theme

    (use-package modus-themes)

    (use-package solar :ensure modus-themes :custom (calendar-latitude [52 00 north]) ;; setup for Poland (calendar-longitude [20 00 east]) ;; setup for Poland (calendar-time-display-form '(24-hours ":" minutes (if time-zone " (") time-zone (if time-zone ")"))) :config (let* ((time-pieces (split-string (sunrise-sunset))) (sunrise (nth 1 time-pieces)) (sunset (nth 4 time-pieces)) (current-tic (format-time-string "%H:%M")) (seconds-in-a-day (* 60 60 24))) (if (and (string-greaterp current-tic sunrise) (string-lessp current-tic sunset)) (modus-themes-load-operandi) (modus-themes-load-vivendi)) (run-at-time sunrise seconds-in-a-day (lambda () (modus-themes-load-operandi))) (run-at-time sunset seconds-in-a-day (lambda () (modus-themes-load-vivendi)))))

    pretty-mode

    Change some text to symbols, like "or" to "v"

    (when window-system (use-package pretty-mode :config (global-pretty-mode t)))

    Custom functions

    Reload config

    (defun config-reload () "Reloads ~/.emacs.d/config.org at runtine" (interactive) (org-babel-load-file (expand-file-name "~/.emacs.d/config.org"))) (global-set-key (kbd "C-c r") 'config-reload)

    Edit config

    (defun config-visit () "Reloads ~/.emacs.d/config.org at runtine" (interactive) (find-file "~/.emacs.d/config.org")) (global-set-key (kbd "C-c e") 'config-visit)

    Follow split

    (defun split-and-follow-horizontally () (interactive) (split-window-below) (balance-windows) (other-window 1) (next-buffer)) (global-set-key (kbd "C-x 2") 'split-and-follow-horizontally)

    (defun split-and-follow-vertically () (interactive) (split-window-right) (balance-windows) (other-window 1) (next-buffer)) (global-set-key (kbd "C-x 3") 'split-and-follow-vertically)

    Kill other buffers

    Deletes all non focused buffers and windows

    (defun delete-other-buffers () (interactive) (mapc 'kill-buffer (cdr (buffer-list (current-buffer)))) (delete-other-windows)) (global-set-key (kbd "C-x K") 'delete-other-buffers)

    COMMENT Dired

    COMMENT Launch

    Im using dired-x so i don't need that (but thanks 4chan anon)

    (defun dired-read-shell-command (prompt arg files) ;; "Read a dired shell command. ;; PROMPT should be a format string with one \"%s\" format sequence, ;; which is replaced by the value returned by `dired-mark-prompt', ;; with ARG and FILES as its arguments. FILES should be a list of ;; file names. The result is used as the prompt.

    ;; This normally reads using `read-shell-command', but if the ;; `dired-x' package is loaded, use `dired-guess-shell-command' to ;; offer a smarter default choice of shell command." (minibuffer-with-setup-hook (lambda () (setq-local dired-aux-files files) (setq-local minibuffer-default-add-function #'minibuffer-default-add-dired-shell-commands)) (setq prompt (format prompt (dired-mark-prompt arg files))) (if (functionp 'dired-guess-shell-command) (dired-mark-pop-up nil 'shell files 'dired-guess-shell-command prompt files) (dired-mark-pop-up nil 'shell files 'read-shell-command prompt "xdg-open.sh" nil))))

    ;; (evil-define-key 'normal dired-mode-map ;; (kbd "\C-c n") 'dired-read-shell-command)

    COMMENT File picker

    Sort of file picker (in this case program "rox -s")

    (define-key dired-mode-map (kbd "C-c b") (lambda () (interactive) (let ((files (mapcar (lambda (string) (concat "\"" string "\"")) (dired-get-marked-files)))) (call-process-shell-command (concat "rox -s " (string-join files " ") "&") nil 0))))

    Run on multiple files

    (defun mrc-dired-do-command (command) ;; "Run COMMAND on marked files. Any files not already open will be opened. ;; After this command has been run, any buffers it's modified will remain ;; open and unsaved." (interactive "CRun on marked files M-x ") (save-window-excursion (mapc (lambda (filename) (find-file filename) (call-interactively command)) (dired-get-marked-files)))) ;; (evil-define-key 'normal dired-mode-map ;; (kbd "C-c n") 'mrc-dired-do-command) (global-set-key (kbd "C-c n") 'mrc-dired-do-command)

    COMMENT Org mode

    COMMENT bold something idk

    (defun xa-bold (&optional char) (interactive) (unless (region-active-p) (backward-word) (mark-word)) (if (region-active-p) (insert-pair 1 ?* ?*) (insert "//") (backward-char)) (forward-word) (right-char))

    (define-key org-mode-map (kbd "M-&") 'xa-bold)

    COMMENT 4chan post log

    (setq org-capture-templates '( ;; Add the following to your org-capture-templates. ("4" "Protocol 4chan Link" entry (file+headline "~/.dotfiles/.local/org/4chan.org" "Inbox") "* %:description \nCaptured On: %U \n%i" :immediate-finish t) ))

    Works pretty well now

    (defun quak-term () (interactive) (if (get-buffer-window "*eshell*") (select-window (get-buffer-window "*eshell*")) (let ((pop-up-windows nil)) (split-window-below) (other-window 1) (eshell) ;; (shell) ;; (term "/usr/bin/bash") (window-resize (selected-window) (- (* (/ (window-height nil) 10) 7)))))) (global-set-key (kbd "C-c o t") 'quak-term)

    Save bookmarks after setting one

    (defun bookmark-set-and-save () (interactive) (bookmark-set) (bookmark-save)) (global-set-key [remap bookmark-set] 'bookmark-set-and-save)

    Transparent frame

    https://www.emacswiki.org/emacs/TransparentEmacs

    (defun user/toggle-transparency () (interactive) (let ((alpha (frame-parameter nil 'alpha))) (set-frame-parameter nil 'alpha (if (eql (cond ((numberp alpha) alpha) ((numberp (cdr alpha)) (cdr alpha)) ;; Also handle undocumented ( ) form. ((numberp (cadr alpha)) (cadr alpha))) 100) '(85 . 50) '(100 . 100))))) (global-set-key (kbd "C-c o o") 'user/toggle-transparency)

    COMMENT Use org-mode to take notes on videos with help from mpv.

    This is awesome. https://github.com/kljohann/mpv.el https://github.com/kljohann/mpv.el/wiki

    (org-link-set-parameters "mpv" :follow #'mpv-play) (defun org-mpv-complete-link (&optional arg) (replace-regexp-in-string "file:" "mpv:" (org-link-complete-file arg) t t))

    (defun my:mpv/org-metareturn-insert-playback-position () (when-let ((item-beg (org-in-item-p))) (when (and (not org-timer-start-time) (mpv-live-p) (save-excursion (goto-char item-beg) (and (not (org-invisible-p)) (org-at-item-timer-p)))) (mpv-insert-playback-position t)))) (add-hook 'org-metareturn-hook #'my:mpv/org-metareturn-insert-playback-position)

    Indent buffer

    (defun user/indent-buffer() (interactive) (save-excursion (indent-region (point-min) (point-max)))) (global-set-key (kbd "C-M-") 'user/indent-buffer)

    Launch external terminal

    (defun launch-external-terminal () (interactive) (shell-command "detach.sh $TERMINAL")) (global-set-key (kbd "C-c o e") #'launch-external-terminal)

    COMMENT My own dashboard

    (defun user/own-dashboard () (interactive) (calendar) (org-todo-list) ;; (setq initial-buffer-choice (lambda () (get-buffer "*Calendar*"))) )

    ;; ;; set startup buffer ;; ;; https://hristos.co/blog/org-agenda-list-initial-buffer-choice-daemon-mode/ ;; ;; emacsclient -c -n -a "" --eval '(org-agenda-list)' ;; (setq initial-major-mode 'org-agenda-list) ;; ;; (org-agenda-list) ;; ;; (split-window-below) ;; ;; (other-window 1) ;; ;; (org-agenda-goto-calendar) ;; (setq inhibit-startup-screen t)

    Yank

    Whole line

    (defun kill-ring-save-whole-line (beg end &optional reg) (interactive (list (mark) (point) (prefix-numeric-value current-prefix-arg))) (if (region-active-p) (kill-ring-save beg end reg) (let ((x (point-at-bol)) (y (point-at-eol))) (kill-ring-save x y)))) (global-set-key [remap kill-ring-save] 'kill-ring-save-whole-line)

    Whole buffer

    (defun kill-ring-save-whole-buffer () (interactive) (kill-ring-save (point-min) (point-max)) (message "Copied buffer contents to clipboard")) (global-set-key (kbd "C-x y") 'kill-ring-save-whole-buffer)

    COMMENT Swap lines

    (defun move-line (n) "Move the current line up or down by N lines." (interactive "p") (setq col (current-column)) (beginning-of-line) (setq start (point)) (end-of-line) (forward-char) (setq end (point)) (let ((line-text (delete-and-extract-region start end))) (forward-line n) (insert line-text) ;; restore point to original column in moved line (forward-line -1) (forward-char col)))

    (defun move-line-up (n) "Move the current line up by N lines." (interactive "p") (move-line (if (null n) -1 (- n))))

    (defun move-line-down (n) "Move the current line down by N lines." (interactive "p") (move-line (if (null n) 1 n)))

    (defun move-region (start end n) "Move the current region up or down by N lines." (interactive "r\np") (let ((line-text (delete-and-extract-region start end))) (forward-line n) (let ((start (point))) (insert line-text) (setq deactivate-mark nil) (set-mark start))))

    (defun move-region-up (start end n) "Move the current line up by N lines." (interactive "r\np") (move-region start end (if (null n) -1 (- n))))

    (defun move-region-down (start end n) "Move the current line down by N lines." (interactive "r\np") (move-region start end (if (null n) 1 n)))

    (defun move-line-region-up (&optional start end n) (interactive "r\np") (if (use-region-p) (move-region-up start end n) (move-line-up n)))

    (defun move-line-region-down (&optional start end n) (interactive "r\np") (if (use-region-p) (move-region-down start end n) (move-line-down n)))

    (global-set-key (kbd "M-") 'move-line-region-up) (global-set-key (kbd "M-") 'move-line-region-down)

    COMMENT Multiple functions one hook

    (dolist (fn '(calendar-mark-holidays diary-mark-entries)) (add-hook 'calendar-mode-hook fn))

    COMMENT Multiple hooks one function

    (defun user/add-hooks (modes fn) "Adds hooks to a list of modes" (--each modes (add-hook it fn)))

    (user/add-hooks '(c-mode-hook c++-mode-hook) (lambda () (set (make-local-variable 'compile-command) (concat "gcc -xc++ -lstdc++ -shared-libgcc " buffer-file-name " && ./a.out"))))

    ;; or (dolist (hook '(c-mode-hook c++-mode-hook)) (add-hook hook (lambda () (setq-local compile-command (concat "gcc -xc++ -lstdc++ -shared-libgcc " (shell-quote-argument buffer-file-name) " && ./a.out")))))

    ;; make it work with regions!@!@!@!@!@@!@!@ (defun user/delete-thing-at-point (thing) "Delete the `thing-at-point' for the specified kind of THING." (let ((bounds (bounds-of-thing-at-point thing))) (if bounds (delete-region (car bounds) (cdr bounds)) (error "No %s at point" thing))))

    (defun user/org-insert-link-clipboard () (interactive) (let ((link (gui-get-selection 'CLIPBOARD)) (desc (thing-at-point 'word 'no-properties))) (user/delete-thing-at-point 'word) (org-insert-link nil link desc)))

    (global-set-key (kbd "C-x x l") 'user/org-insert-link-clipboard)

    Kill shell command buffer is process is no longer active

    https://stackoverflow.com/questions/13901955/how-to-avoid-pop-up-of-async-shell-command-buffer-in-emacs

    (add-to-list 'display-buffer-alist (list "\\*Async Shell Command\\*.*" #'display-buffer-no-window)) ;; (cons "\\*Async Shell Command\\*.*" (cons #'display-buffer-no-window nil)))

    Layouts

    Spiral window

    (defun user/spiral-windows () (interactive) (let ((w (window-pixel-width)) (h (window-pixel-height))) (if (> w h) (set-frame-selected-window nil (split-window-horizontally)) (set-frame-selected-window nil (split-window-vertically))))) (global-set-key (kbd "M-3") #'user/spiral-windows)

    Full

    proced

    (use-package proced :ensure nil :config (setq proced-auto-update-flag t) :hook (proced-post-display . delete-other-windows))

    COMMENT waifu

    (defun waifu () (interactive) (when (= (count-windows) 1) (split-window-right) (windmove-right) (find-file "~/Documents/neofetch/fetch1.png") (shrink-window 15 t) (windmove-left)))

    (add-hook 'after-init-hook #'waifu)