You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
;; Install use-package support
(elpaca elpaca-use-package
;; Enable :elpaca use-package keyword.
(elpaca-use-package-mode)
;; Assume :elpaca t unless otherwise specified.
(setq elpaca-use-package-by-default t))
;; Block until current queue processed.
(elpaca-wait)
;;When installing a package which modifies a form used at the top-level;;(e.g. a package which adds a use-package key word),;;use `elpaca-wait' to block until that package has been installed/configured.;;For example:;;(use-package general :demand t);;(elpaca-wait)
Evil Mode
;; Expands to: (elpaca evil (use-package evil :demand t))
(use-package evil
:init;; tweak evil's configuration before loading it
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
(setq evil-want-keybinding nil)
(setq evil-vsplit-window-right t)
(setq evil-split-window-below t)
(evil-mode)
(evil-set-undo-system 'undo-redo)
)
(use-package evil-collection
:after evil
:diminish:config
(setq evil-collection-mode-list '(dashboard dired ibuffer))
(evil-collection-init))
(use-package evil-tutor)
;; Company Mode Remap
(with-eval-after-load'evil
(with-eval-after-load'company
(define-key evil-insert-state-map (kbd"C-n") nil)
(define-key evil-insert-state-map (kbd"C-p") nil)
(evil-define-key nil company-active-map (kbd"C-n") #'company-select-next)
(evil-define-key nil company-active-map (kbd"C-p") #'company-select-previous)))
(with-eval-after-load'evil-maps
(define-key evil-motion-state-map (kbd"SPC") nil)
(define-key evil-motion-state-map (kbd"RET") nil)
(define-key evil-motion-state-map (kbd"TAB") nil))
(setq org-return-follows-link t)
General Keybindings
(use-package general
:diminish:config
(general-evil-setup)
;; set up 'SPC' as the global leader key
(general-create-definer dt/leader-keys
:states '(normal insert visual emacs)
:keymaps'override:prefix"SPC";; set leader:global-prefix"M-SPC") ;; access leader in insert mode;; Top Layer Keybindings
(dt/leader-keys
"SPC" '(counsel-M-x :wk"Counsel M-x") ;; Double SPC to replace M-x"g c" '(comment-line:wk"Comment lines")) ;; This will be moved to a usable category once I find something fitting.;; Buffer Keybindings
(dt/leader-keys
"b" '(:ignoret:wk"Buffer")
;; Buffer Navigation"b n" '(my-next-buffer :wk"Next buffer") ;; Purposely not using vim-keybindings here"b b" '(my-previous-buffer :wk"Previous buffer") ;; Easier for Navigation purposes"b r" '(revert-buffer:wk"Reload buffer")
"b j" '(switch-to-buffer:wk"Switch buffer")
"b c" '(kill-this-buffer:wk"Close buffer")) ;; Naming this to Close instead of Kill. Hope it is the same.;; Config Keybindings
(dt/leader-keys
"c" '(:ignoret:wk"Config")
"c e" '((lambda () (interactive) (find-file"~/.config/emacs/config.org")) :wk"Edit Emacs")
"c h" '((lambda () (interactive) (find-file"~/.config/hypr/hyprland.conf")) :wk"Edit Hyprland")
"c n" '((lambda () (interactive) (find-file"~/.config/flake/configuration.nix")) :wk"Edit Nix")
"c r" '(reload-init-file :wk"Reload Config (emacs)"))
;; Treeview Keybindings;; Description: Using 'e' for Explorer
(dt/leader-keys
"e" '(treemacs :wk"Treemacs"))
;; Elisp Keybindings;; Description: Currently not using them.;; (dt/leader-keys;; "e" '(:ignore t :wk "Evaluate");; "e b" '(eval-buffer :wk "Evaluate elisp in buffer");; "e d" '(eval-defun :wk "Evaluate defun containing or after point");; "e e" '(eval-expression :wk "Evaluate and elisp expression");; "e l" '(eval-last-sexp :wk "Evaluate elisp expression before point");; "e r" '(eval-region :wk "Evaluate elisp in region"));; File Keybindings
(dt/leader-keys
"f" '(:ignoret:wk"File / Feed")
"f f" '(find-file:wk"Find File")
"f e" '(elfeed :wk"Elfeed")
"f r" '(counsel-recentf :wk"Recent Files"))
;; Elfeed Keybindings
(dt/leader-keys elfeed-show-mode-map
"f p" '(elfeed-tube-mpv :wk"Elfeed Play"))
;; Google Calendar Keybindings;; Description: Should only show in org files.
(dt/leader-keys org-mode-map
"g" '(:ignoret:wk"Google Calendar")
"g p" '(org-gcal-post-at-point :wk"Post at Point")
"g d" '(org-gcal-delete-at-point :wk"Post at Point")
"g s" '(org-gcal-sync :wk"Sync")
"g b" '(org-gcal-sync-buffer :wk"Sync Buffer")
"g f" '(org-gcal-fetch :wk"Fetch"))
;; Help Keybindings;; Description: General help or docs
(dt/leader-keys
"h" '(:ignoret:wk"Help")
"h f" '(describe-function:wk"Describe function")
"h v" '(describe-variable:wk"Describe variable"))
;; Ivy;; Description: Honestly no clue if I actually should just remove it... never used.
(dt/leader-keys
"i" '(:ignoret:wk"Ivy")
"i r" '(ivy-resume :wk"Ivy Resume")
"i b" '(ivy-switch-buffer-other-window :wk"Switch Buffer Other Window"))
;; Jump Keybindings;; Description: Theoretically everything one can jump to. I use this, when I know I want to change to something, but need a second to know where exactly.
(dt/leader-keys
"j" '(:ignoret:wk"Jump")
"j b" '(switch-to-buffer:wk"Jump to Buffer")
"j t" '(consult-outline :wk"Jump To Outline"))
(general-define-key
:states '(normal, motion)
:keymaps'org-mode-map"g d"'org-open-at-point)
;; LSP Keybindings;; Description: Default Keybindings for all languages.
(dt/leader-keys
"l" '(:ignoret:wk"LSP")
"l i" '(lsp-describe-thing-at-point :wk"Describe Entity")
"l r" '(lsp-rename :wk"Rename Entity")
"l a" '(lsp-execute-code-action :wk"Code Action")
"l u" '(lsp-ui-imenu :wk"UI Menu")
"l d" '(lsp-ui-peek-find-definitions :wk"Find Definitions")
"l r" '(lsp-ui-peek-find-references :wk"Find References")
"l q" '(lsp-workspace-restart :wk"Restart Workspace")
"l e" '(flycheck-list-errors :wk"List Errors") ;; FlyCheck, but keeping it under LSP, since it feels correct here."l c" '(lsp-command-map :wk"LSP Command Map")) ;; Does not work... need to find something else.;; Rust Keybindings;; Description: Should only show in rust files.
(dt/leader-keys rustic-mode-map
"l s" '(lsp-rust-analyzer-status :wk"LSP Rust Analyzer Status"))
;; Org Keybindings;; Description: Not yet that fluent with org-mode to change anything from the defaults I used in vim.
(dt/leader-keys
"m" '(:ignoret:wk"Org")
"m a" '(org-agenda:wk"Org agenda")
"m e" '(org-export-dispatch:wk"Org export dispatch")
"m i" '(org-toggle-item:wk"Org toggle item")
"m t" '(org-todo:wk"Org todo")
"m B" '(org-babel-tangle:wk"Org babel tangle")
"m T" '(org-todo-list:wk"Org todo list")
;; Org Tables"m b" '(:ignoret:wk"Tables")
"m b -" '(org-table-insert-hline:wk"Insert hline in table")
;; Org Dates & Deadlines"m d" '(:ignoret:wk"Date/deadline")
"m d t" '(org-time-stamp:wk"Org time stamp"))
;; Org-Roam Keybindings;; Description: Not yet that fluent with org-mode to change anything from the defaults I used in vim.
(dt/leader-keys
"r" '(:ignoret:wk"Roam")
"r f" '(org-roam-node-find :wk"Node find")
"r d" '(:ignoret:wk"Roam Dailies")
"r d y" '(org-roam-dailies-goto-yesterday :wk"Go To Yesterday")
"r d d" '(org-roam-dailies-goto-today :wk"Go To Today")
"r d t" '(org-roam-dailies-goto-tomorrow :wk"Go To Tomorrow")
"r d x" '(org-roam-dailies-goto-date :wk"Go To Date")
"r i" '(org-roam-node-insert :wk"Node insert")
"r c" '(completion-at-point:wk"Completion"))
;; Projectile Keybindings
(dt/leader-keys
"p" '(projectile-command-map :wk"Projectile"))
;; Sudo Keybindings
(dt/leader-keys
"s" '(:ignoret:wk"Sudo")
"sf" '(sudo-edit-find-file :wk"Sudo find file")
"su" '(sudo-edit :wk"Sudo edit file"))
;; Terminal Keybindings
(dt/leader-keys
"t" '(:ignoret:wk"Terminal")
;; Terminal: EShell"t e" '(:ignoret:wk"EShell")
"t e n" '(eshell:wk"Launch EShell")
"t e h" '(counsel-esh-history :wk"Show EShell History")
;; Terminal: Terminal"t t" '(vterm-toggle :wk"Toggle Terminal"))
(dt/leader-keys
"v" '(:ignoret:wk"View")
"v l" '(display-line-numbers-mode:wk"Toggle line numbers")
"v t" '(visual-line-mode:wk"Toggle truncated lines"))
;; Window Keybindings
(dt/leader-keys
"w" '(:ignoret:wk"Window")
"w n" '(evil-window-new :wk"New Window")
"w c" '(evil-window-delete :wk"Close Window")
;; Window splits"w s" '(evil-window-split :wk"Horizontal Window Split")
"w v" '(evil-window-vsplit :wk"Vertical Window Split")
;; Window Motions"w h" '(evil-window-left :wk"Move Window left")
"w j" '(evil-window-down :wk"Move Window down")
"w k" '(evil-window-up :wk"Move Window up")
"w l" '(evil-window-right :wk"Move Window right")
"w w" '(evil-window-next :wk"GoTo Next Window")
;; Window Buffer Movements"w b" '(:ignoret:wk"Window Buffer")
"w b h" '(buf-move-left :wk"Move Buffer left")
"w b j" '(buf-move-down :wk"Move Buffer down")
"w b k" '(buf-move-up :wk"Move Buffer up")
"w b l" '(buf-move-right :wk"Move Buffer right"))
)
(modify-all-frames-parameters
'((right-divider-width .0) ;; Changing this value will do border changes.
(internal-border-width .0))) ;; Changing this value will do border changes.
(dolist (face '(window-dividerwindow-divider-first-pixelwindow-divider-last-pixel))
(face-spec-reset-face face)
(set-face-foreground face (face-attribute'default:background)))
(set-face-background'fringe (face-attribute'default:background))
(use-package eshell-syntax-highlighting
:after esh-mode
:diminish:config
(eshell-syntax-highlighting-global-mode +1))
;; eshell-syntax-highlighting -- adds fish/zsh-like syntax highlighting.;; eshell-rc-script -- your profile for eshell; like a bashrc for eshell.;; eshell-aliases-file -- sets an aliases file for the eshell.
(setq eshell-rc-script (concat user-emacs-directory "eshell/profile")
eshell-aliases-file (concat user-emacs-directory "eshell/aliases")
eshell-history-size 5000
eshell-buffer-maximum-lines 5000
eshell-hist-ignoredups t
eshell-scroll-to-bottom-on-input t
eshell-destroy-buffer-when-process-dies t
eshell-visual-commands'("bash""fish""htop""ssh""top""zsh"))
(use-package dashboard
:ensuret:init
(setq initial-buffer-choice 'dashboard-open)
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
(setq dashboard-icon-type 'all-the-icons) ;; use `all-the-icons' package
(setq dashboard-banner-logo-title "Aliyss' new Operating System (UwU)")
;; (setq dashboard-startup-banner 'logo) ;; use standard emacs logo as banner
(setq dashboard-startup-banner "~/.config/emacs/images/alice-love.webp") ;; use custom image as banner
(setq dashboard-center-content t) ;; set to 't' for centered content
(setq dashboard-items '((recents .5)
(agenda .5 )
(bookmarks .3)
(projects .3)
(registers .3)))
;; (dashboard-modify-heading-icons '((recents . "file-text");; (bookmarks . "book")))
(setq dashboard-footer-messages '("I am not a human, dear reader, but a yeti. A human requires to be, I can only hope not to be another figment of imagination."))
(setq dashboard-footer-icon nil)
:config
(dashboard-setup-startup-hook))
LAUNCHERS
App Launcher
(use-package app-launcher
:elpaca '(app-launcher :host github :repo"SebastienWae/app-launcher"))
(defunemacs-run-launcher ()
"Create and select a frame called emacs-run-launcher which consists only of a minibuffer and has specific dimensions. Runs app-launcher-run-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited"
(interactive)
(with-selected-frame
(make-frame '((name ."emacs-run-launcher")
(minibuffer . only)
(fullscreen .0) ; no fullscreen
(undecorated .nil) ; remove title bar;;(auto-raise . t) ; focus on this frame;;(tool-bar-lines . 0);;(menu-bar-lines . 0)
(internal-border-width .10)
(width .100)
(height .11)))
(unwind-protect
(app-launcher-run-app)
(delete-frame))))
(use-package tree-sitter
:ensuret:config;; activate tree-sitter on any buffer containing code for which it has a parser available
(global-tree-sitter-mode)
;; you can easily see the difference tree-sitter-hl-mode makes for python, ts or tsx;; by switching on and off
(add-hook'typescript-mode-hook#'tree-sitter-hl-mode)
(add-hook'typescript-mode-hook#'lsp-mode)
)
(use-package tree-sitter-langs
:ensuret:after tree-sitter)
GLSL
(provide'glsl-mode)
(eval-when-compile; required and optional libraries
(require'cc-mode)
(require'find-file))
(defconstglsls-version"1.0""OpenGLSL major mode version number.")
(defvarglsl-mode-hooknil)
(defvarglsl-mode-map
(let ((glsl-mode-map (make-sparse-keymap)))
(define-key glsl-mode-map [S-iso-lefttab] 'ff-find-other-file)
glsl-mode-map)
"Keymap for GLSL major mode")
(add-to-list'auto-mode-alist '("\\.vert\\'". glsl-mode))
(add-to-list'auto-mode-alist '("\\.frag\\'". glsl-mode))
(defconstglsl-font-lock-keywords-1
(list
'("\\<\\(b\\(?:ool\\|vec[1-4]\\)\\|float\\|i\\(?:nt\\|vec[1-4]\\)\\|mat[234]\\|sampler\\(?:1D\\(?:Shadow\\)?\\|2D\\(?:Shadow\\)?\\|3D\\|Cube\\)\\|v\\(?:ec[1-4]\\|oid\\)\\)\\>".font-lock-type-face)
'("\\<\\(attribute\\|break\\|con\\(?:st\\|tinue\\)\\|d\\(?:iscard\\|o\\)\\|else\\|for\\|i\\(?:nout\\|[fn]\\)\\|out\\|return\\|struct\\|uniform\\|varying\\|while\\)\\>".font-lock-keyword-face)
'("\\<\\(a\\(?:bs\\|cos\\|ll\\|ny\\|\\(?:si\\|ta\\)n\\)\\|c\\(?:eil\\|lamp\\|\\(?:o\\|ros\\)s\\)\\|d\\(?:Fd[xy]\\|istance\\|ot\\)\\|e\\(?:qual\\|xp2?\\)\\|f\\(?:aceforward\\|loor\\|ract\\|transform\\|width\\)\\|greaterThan\\(?:Equal\\)?\\|inversesqrt\\|l\\(?:e\\(?:ngth\\|ssThan\\(?:Equal\\)?\\)\\|og2?\\)\\|m\\(?:a\\(?:trixCompMult\\|x\\)\\|in\\|ode\\)\\|no\\(?:ise[1-4]\\|rmalize\\|t\\(?:Equal\\)?\\)\\|pow\\|r\\(?:adians\\|ef\\(?:\\(?:le\\|ra\\)ct\\)\\)\\|s\\(?:hadow\\(?:1D\\(?:Lod\\|Proj\\(?:Lod\\)?\\)?\\|2D\\(?:Lod\\|Proj\\(?:Lod\\)?\\)?\\)\\|i\\(?:g?n\\)\\|moothstep\\|qrt\\|tep\\)\\|t\\(?:an\\|exture\\(?:1D\\(?:Lod\\|Proj\\(?:Lod\\)?\\)?\\|2D\\(?:Lod\\|Proj\\(?:Lod\\)?\\)?\\|3D\\(?:Lod\\|Proj\\(?:Lod\\)?\\)?\\|Cube\\(?:Lod\\)?\\)\\)\\)\\>".font-lock-builtin-face)
'("\\<\\(gl_\\(?:Back\\(?:Color\\|Light\\(?:\\(?:Model\\)?Product\\)\\|Material\\|SecondaryColor\\)\\|C\\(?:lipVertex\\|olor\\(?:\\)?\\)\\|DepthRange\\(?:\\)?\\|EyePlane[Q-T]\\|F\\(?:og\\(?:Coord\\)?\\|r\\(?:ag\\(?:Co\\(?:lor\\|ord\\)\\|D\\(?:ata\\|epth\\)\\)\\|ont\\(?:Color\\|Facing\\|Light\\(?:\\(?:Model\\)?Product\\)\\|Material\\|SecondaryColor\\)\\)\\)\\|LightSource\\|M\\(?:ax\\(?:\\(?:C\\(?:lipPlane\\|ombinedTextureImageUnit\\)\\|DrawBuffer\\|FragmentUniformComponent\\|Light\\|Texture\\(?:Coord\\|\\(?:Image\\)?Unit\\)\\|V\\(?:aryingFloat\\|ertex\\(?:Attrib\\|\\(?:TextureImageUni\\|UniformComponen\\)t\\)\\)\\)s\\)\\|odelView\\(?:Matrix\\(?:\\(?:Inver\\(?:seTranspo\\)?\\|Transpo\\)se\\)?\\|ProjectionMatrix\\(?:\\(?:Inver\\(?:seTranspo\\)?\\|Transpo\\)se\\)?\\)\\|ultiTexCoord[0-7]\\)\\|Normal\\(?:Matrix\\|Scale\\)?\\|ObjectPlane[Q-T]\\|P\\(?:o\\(?:int\\(?:Size\\)??\\|sition\\)\\|rojectionMatrix\\(?:\\(?:Inver\\(?:seTranspo\\)?\\|Transpo\\)se\\)?\\)\\|SecondaryColor\\(?:\\)?\\|Tex\\(?:Coord\\|ture\\(?:EnvColor\\|Matrix\\(?:\\(?:Inver\\(?:seTranspo\\)?\\|Transpo\\)se\\)?\\)\\)\\|Vertex\\)\\)\\>" . font-lock-variable-name-face)
)
"Minimal highlighting expressions for GLSL mode")
(defvarglsl-font-lock-keywords glsl-font-lock-keywords-1
"Default highlighting expressions for GLSL mode")
(defvarglsl-mode-syntax-table
(let ((glsl-mode-syntax-table (make-syntax-table)))
(modify-syntax-entry?/". 124b" glsl-mode-syntax-table)
(modify-syntax-entry?*". 23" glsl-mode-syntax-table)
(modify-syntax-entry?\n"> b" glsl-mode-syntax-table)
glsl-mode-syntax-table)
"Syntax table for glsl-mode")
(defvarglsl-other-file-alist
'(("\\.frag$"
(".vert"))
("\\.vert$"
(".frag")))
"Alist of extensions to find given the current file's extension")
(define-derived-mode glsl-mode c-mode "GLSL""Major mode for editing OpenGLSL shader files."
(set (make-local-variable'font-lock-defaults) '(glsl-font-lock-keywords))
(set (make-local-variable'ff-other-file-alist) 'glsl-other-file-alist)
)
(use-package rustic
:ensuret:config;; uncomment for less flashiness;; (setq lsp-eldoc-hook nil);; (setq lsp-enable-symbol-highlighting nil);; (setq lsp-signature-auto-activate nil);; comment to disable rustfmt on save
(setq rustic-format-on-save t))
Javascript / Typescript
(use-package add-node-modules-path
:ensuret:hook ((typescript-mode. add-node-modules-path)))
(use-package typescript-mode
:after tree-sitter
:config;; we choose this instead of tsx-mode so that eglot can automatically figure out language for server;; see https://github.com/joaotavora/eglot/issues/624 and https://github.com/joaotavora/eglot#handling-quirky-servers
(define-derived-mode typescriptreact-mode typescript-mode
"TypeScript TSX")
;; use our derived mode for tsx files
(setq auto-mode-alist (append '((".*\\.tsx?". typescriptreact-mode)) auto-mode-alist))
;; by default, typescript-mode is mapped to the treesitter typescript parser;; use our derived mode to map both .tsx AND .ts -> typescriptreact-mode -> treesitter tsx
(add-to-list'tree-sitter-major-mode-language-alist '(typescriptreact-mode . tsx))
(add-hook'typescript-mode-after-on-hook#'lsp-mode)
)
;; https://github.com/orzechowskid/tsi.el/;; great tree-sitter-based indentation for typescript/tsx, css, json
(use-package tsi
:after tree-sitter
:elpaca '(tsi :host github :repo"orzechowskid/tsi.el")
;; define autoload definitions which when actually invoked will cause package to be loaded:commands (tsi-typescript-mode tsi-json-mode tsi-css-mode lsp-mode)
:init
(add-hook'typescript-mode-hook (lambda () (tsi-typescript-mode 1)))
(add-hook'json-mode-hook (lambda () (tsi-json-mode 1)))
(add-hook'css-mode-hook (lambda () (tsi-css-mode 1)))
(add-hook'scss-mode-hook (lambda () (tsi-scss-mode 1))))
Eglot
(use-package eglot
:ensuret:config;; Ensure `nil` is in your PATH.
(add-to-list'eglot-server-programs '(nix-mode . ("nil")))
;;(add-to-list 'eglot-server-programs '(typescript-mode . ("typescript-language-server" "--stdio"))):hook
(nix-mode . eglot-ensure)
;;(typescript-mode . eglot-ensure)
)
(defcustommy-skippable-buffers '("*Messages*""*scratch*""*Help*""*Async-native-compile-log*""*lsp-log*""*ts-ls*""*ts-ls::stderr*""*eslint*""*eslint::stderr*""*tailwindcss*""*tailwindcss::stderr*")
"Buffer names ignored by `my-next-buffer' and `my-previous-buffer'.":type '(repeat string))
(defunmy-change-buffer (change-buffer)
"Call CHANGE-BUFFER until current buffer is not in `my-skippable-buffers'."
(let ((initial (current-buffer)))
(funcall change-buffer)
(let ((first-change (current-buffer)))
(catch'loop
(while (member (buffer-name) my-skippable-buffers)
(funcall change-buffer)
(when (eq (current-buffer) first-change)
(switch-to-buffer initial)
(throw'loopt)))))))
(defunmy-next-buffer ()
"Variant of `next-buffer' that skips `my-skippable-buffers'."
(interactive)
(my-change-buffer 'next-buffer))
(defunmy-previous-buffer ()
"Variant of `previous-buffer' that skips `my-skippable-buffers'."
(interactive)
(my-change-buffer 'previous-buffer))
Buffer Movement
(require'windmove)
Buffer Move Up
;;;###autoload
(defunbuf-move-up ()
"Swap the current buffer and the buffer above the split. If there is no split, ie now window above the current one, an error is signaled.";; "Switches between the current buffer, and the buffer above the;; split, if possible."
(interactive)
(let* ((other-win (windmove-find-other-window'up))
(buf-this-buf (window-buffer (selected-window))))
(if (null other-win)
(error"No window above this one")
;; swap top with this one
(set-window-buffer (selected-window) (window-buffer other-win))
;; move this one to top
(set-window-buffer other-win buf-this-buf)
(select-window other-win))))
Buffer Move Down
;;;###autoload
(defunbuf-move-down ()
"Swap the current buffer and the buffer under the split. If there is no split, ie now window under the current one, an error is signaled."
(interactive)
(let* ((other-win (windmove-find-other-window'down))
(buf-this-buf (window-buffer (selected-window))))
(if (or (null other-win)
(string-match"^ \\*Minibuf" (buffer-name (window-buffer other-win))))
(error"No window under this one")
;; swap top with this one
(set-window-buffer (selected-window) (window-buffer other-win))
;; move this one to top
(set-window-buffer other-win buf-this-buf)
(select-window other-win))))
Buffer Move Left
;;;###autoload
(defunbuf-move-left ()
"Swap the current buffer and the buffer on the left of the split. If there is no split, ie now window on the left of the current one, an error is signaled."
(interactive)
(let* ((other-win (windmove-find-other-window'left))
(buf-this-buf (window-buffer (selected-window))))
(if (null other-win)
(error"No left split")
;; swap top with this one
(set-window-buffer (selected-window) (window-buffer other-win))
;; move this one to top
(set-window-buffer other-win buf-this-buf)
(select-window other-win))))
Buffer Move Right
(defunbuf-move-right ()
"Swap the current buffer and the buffer on the right of the split. If there is no split, ie now window on the right of the current one, an error is signaled."
(interactive)
(let* ((other-win (windmove-find-other-window'right))
(buf-this-buf (window-buffer (selected-window))))
(if (null other-win)
(error"No right split")
;; swap top with this one
(set-window-buffer (selected-window) (window-buffer other-win))
;; move this one to top
(set-window-buffer other-win buf-this-buf)
(select-window other-win))))
Buffer Backups
(setq backup-directory-alist '(("."."~/.local/share/Trash/files")))
(setq make-backup-files t; backup of a file the first time it is saved.
backup-by-copying t; don't clobber symlinks
version-control t; version numbers for backup files
delete-old-versions t; delete excess backup files silently
delete-by-moving-to-trash t
kept-old-versions 6; oldest versions to keep when a new numbered backup is made (default: 2)
kept-new-versions 9; newest versions to keep when a new numbered backup is made (default: 2)
auto-save-default t; auto-save every buffer that visits a file
auto-save-timeout 20; number of seconds idle time before auto-save (default: 30)
auto-save-interval 200; number of keystrokes between auto-saves (default: 300)
)
Automatically update buffers when contents change on disk
(global-auto-revert-mode1)
FONTS
Setting the Font-Face
(set-face-attribute'defaultnil:font"JetBrainsMonoNLNerdFont":height160:weight'regular)
(set-face-attribute'variable-pitchnil:font"JetBrainsMonoNLNerdFont":height180:weight'regular)
(set-face-attribute'fixed-pitchnil:font"JetBrainsMonoNLNerdFont":height160:weight'regular)
;; Makes commented text and keywords italics.;; This is working in emacsclient but not emacs.;; Your font must have an italic face available.
(set-face-attribute'font-lock-comment-facenil:weight'light:slant'italic)
(set-face-attribute'font-lock-keyword-facenil:slant'italic)
;; This sets the default font on all graphical frames created after restarting Emacs.;; Does the same thing as 'set-face-attribute default' above, but emacsclient fonts;; are not right unless I also add this method of setting the default font.
(add-to-list'default-frame-alist '(font ."JetBrainsMonoNLNerdFont-16"))
;; Uncomment the following line if line spacing needs adjusting.;; (setq-default line-spacing 0.12)
(electric-indent-mode-1)
(add-hook'org-mode-hook (lambda ()
(setq-local electric-pair-inhibit-predicate
`(lambda (c)
(if (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))))
Format emacs-lisp src blocks in Org Files
(defunedit-src-block (srcfnlanguage)
"Replace SRC org-element's value property with the result of FN. FN is a function that operates on org-element's value and returns a string. LANGUAGE is a string referring to one of orb-babel's supported languages. (https://orgmode.org/manual/Languages.html#Languages)"
(let ((src-language (org-element-property :language src))
(value (org-element-property :value src)))
(when (string= src-language language)
(let ((copy (org-element-copy src)))
(org-element-put-property copy :value
(funcall fn value))
(org-element-set-element src copy)))))
(defunformat-elisp-string (string)
"Indents elisp buffer string and reformats dangling parens."
(with-temp-buffer
(let ((inhibit-message t))
(emacs-lisp-mode)
(insert
(replace-regexp-in-string"[[:space:]]* [[:space:]]*)"")" string))
(indent-region (point-min) (point-max))
(buffer-substring (point-min) (point-max)))))
(defunformat-elisp-src-blocks ()
"Format Elisp src blocks in the current org buffer"
(interactive)
(save-mark-and-excursion
(let ((AST (org-element-parse-buffer)))
(org-element-map AST 'src-block
(lambda (element)
(edit-src-block element #'format-elisp-string"emacs-lisp")))
(delete-region (point-min) (point-max))
(insert (org-element-interpret-data AST)))))