diff options
author | bd <bdunahu@gmail.com> | 2023-12-25 22:22:24 -0700 |
---|---|---|
committer | bd <bdunahu@gmail.com> | 2023-12-25 22:22:24 -0700 |
commit | a7af6aa11b3980eae5ddfcc46c74347534c343dd (patch) | |
tree | 11331fc6c19261e74bdf4196a63238316b941f1d /.config/emacs/init.el |
Initial dotfiles commit.
Diffstat (limited to '.config/emacs/init.el')
-rw-r--r-- | .config/emacs/init.el | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el new file mode 100644 index 0000000..71d6cdf --- /dev/null +++ b/.config/emacs/init.el @@ -0,0 +1,170 @@ +;; -*- lexical-binding: t; -*- + +;; reduce the frequency of garbage collection by making it happen on +;; each 50MB of allocated data (the default is on every 0.76MB) +(setq gc-cons-threshold 50000000) + +(setenv "PATH" (format "%s:%s" "/home/bdunahu/Personal/scripts/" (getenv "PATH"))) + +;;; do not store customized setting (automatic) here +(setq custom-file "/home/bdunahu/.config/emacs/custom.el") +(load custom-file t) + +(defun bd/display-startup-time () + (message "Emacs loaded in %s with %d garbage collections." + (format "%.2f seconds" + (float-time + (time-subtract after-init-time before-init-time))) + gcs-done)) + +(add-hook 'emacs-startup-hook #'bd/display-startup-time) + +(defun request-sudo () + "Uses TRAMP to edit currently opened file as root." + (interactive) + (when buffer-file-name + (find-alternate-file + (concat "/sudo:root@localhost:" + buffer-file-name)))) + +(defun match-buffer-name (name) + "Returns non-nil if NAME matches the name of an existing buffer" + (try-completion name (mapcar #'buffer-name (buffer-list)))) + +(defun toggle-current-window-dedication () + "Adds or revokes dedicated window status from a buffer. A +dedicated buffer will never be automatically orphaned." + (interactive) + (let* ((window (selected-window)) + (dedicated (window-dedicated-p window))) + (set-window-dedicated-p window (not dedicated)) + (message "Window %sdedicated to %s" + (if dedicated "no longer " "") + (buffer-name)))) + +(defun rip-video () + "If region, open SEARCH with mpv in --full-screen. Else, +open URL at point." + (interactive) + (let ((URL-OR-SEARCH + (if (use-region-p) + (buffer-substring (mark) (point)) + (shr-url-at-point nil)))) + (message "Ludu %s" URL-OR-SEARCH) + (start-process-shell-command "rip-video" nil (concat "rip-video " URL-OR-SEARCH)))) + +(defun clamp (lower-bound upper-bound value) + (max lower-bound (min value upper-bound))) + +(defun insert-into-list (list el n) + "Insert into list LIST an element EL at index N. + +If N is 0, EL is inserted before the first element. + +The resulting list is returned. As the list contents is mutated +in-place, the old list reference does not remain valid." + (let* ((padded-list (cons nil list)) + (c (nthcdr n padded-list))) + (setcdr c (cons el (cdr c))) + (cdr padded-list))) + +(defun remote-shell () + (interactive) + (let ((default-directory "/ssh:bdunahu@perch.cs.colostate.edu:")) + (shell))) + +(global-unset-key (kbd "C-z")) + +(require 'package) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) +(package-initialize) +(package-refresh-contents) +;; (setq use-package-verbose t) ; for debugging + +(require 'use-package-ensure) +(setq use-package-always-ensure t) + +(load "/home/bdunahu/.config/emacs/bd-org.el") +(load "/home/bdunahu/.config/emacs/bd-emms.el") +(load "/home/bdunahu/.config/emacs/bd-development.el") + +(use-package newsticker + :demand t + :bind (("C-z C-g" . newsticker-show-news) + :map newsticker-treeview-item-mode-map + ("C-j" . rip-video)) + :custom + (newsticker-url-list-defaults nil) + (newsticker-automatically-mark-items-as-old nil) + (newsticker-url-list '(("Ambrose and Elsewhere" "https://jamesenge.com/engeblog/feed" nil nil nil) + ("James Enge Mastodon" "https://mastodon.sdf.org/@jamesenge.rss" nil nil nil) + ("Book Reviews | Tales From the Magician's Skull" "https://goodman-games.com/tftms/category/book-reviews/feed" nil nil nil) + ("Arch Linux: Recent news updates" "https://archlinux.org/feeds/news/" nil nil nil) + ("Parabola GNU/Linux-libre: Recent news updates" "https://www.parabola.nu/feeds/news/" nil nil nil) + ("suckless.org news" "https://suckless.org/atom.xml" nil nil nil) + ("Richard Stallman's Political News" "https://stallman.org/rss/rss.xml" nil nil nil) + ("Mental Outlaw" "https://vid.puffyan.us/feed/channel/UC7YOGHUfC1Tb6E4pudI9STA" nil nil nil) + ("Luke Smith" "https://vid.puffyan.us/feed/channel/UC2eYFnH61tmytImy1mTYvhA" nil nil nil) + ("Brent Westbrook" "https://yewtu.be/feed/channel/UC0PBefyEK7qQ7HN325nUamQ" nil nil nil) + ("Bugswriter" "https://yewtu.be/feed/channel/UCngn7SVujlvskHRvRKc1cTw" nil nil nil) + ("Protesilaos Stravrou" "https://yewtu.be/feed/playlist/PL8Bwba5vnQK14z96Gil86pLMDO2GnOhQ6" nil nil nil))) + ;; may require ./newsticker/groups to be cleared + (newsticker-groups '("Feeds" + ("READING" "Ambrose and Elsewhere" "James Enge Mastodon" "Book Reviews | Tales From the Magician's Skull") + ("TECH" ("GNU/Linux" "Arch Linux: Recent news updates" "Parabola GNU/Linux-libre: Recent news updates") "suckless.org news") + ("POLITICAL" "Richard Stallman's Political News") + ("VIDEO" "Mental Outlaw" "Luke Smith" "Brent Westbrook" "Bugswriter" "Protesilaos Stravrou")))) + +(setq erc-server "irc.libera.chat" + erc-nick "Isaz" + erc-user-full-name "bd" + erc-kill-buffer-on-part t + erc-autojoin-channels-alist '(("irc.libera.char" "#parabola" "#emacs"))) +(defalias 'erc 'erc-tls) + +;; dired +(setq dired-listing-switches "-alh") + +(setq inhibit-startup-message t) +(menu-bar-mode -1) +(tool-bar-mode -1) +(scroll-bar-mode -1) + +;; move backups to tmp folder +(setq backup-directory-alist `(("." . ,(expand-file-name "tmp/backups/" user-emacs-directory)))) +(make-directory (expand-file-name "tmp/auto_saves/" user-emacs-directory) t) +;; move auto-saves to tmp folder +(setq auto-save-list-file-prefix (expand-file-name "tmp/auto_saves/sessions/" user-emacs-directory) + auto-save-file-transforms `((".*" ,(expand-file-name "tmp/auto_saves/" user-emacs-directory) t))) + +(setq scroll-up-aggressively '0.0 + scroll-down-aggressively '0.0) + +(global-auto-revert-mode 1) + +(setq fit-window-to-buffer-horizontally t) + +(ido-mode 1) +;; allow same buffer on multiple frames +(setq ido-default-buffer-method 'selected-window) + +;; allow one side window per side of frame +(setq window-sides-slots '(1 1 1 1)) + +(global-unset-key (kbd "C-x C-z")) ; unbind suspend-frame--terrible spot for binding + +;; dired +(global-set-key (kbd "C-z d") 'dired-jump) + +;; text-scale +(global-set-key (kbd "C-z =") 'text-scale-increase) +(global-set-key (kbd "C-z -") 'text-scale-decrease) + +(load "/home/bdunahu/.config/emacs/bd-wm.el") +(load "/home/bdunahu/.config/emacs/bd-mode-and-themes.el") + +(setq gc-cons-threshold 800000) + +;; packages to consider: +;;; pydocs +;;; yasnippit |