From 1394b10658f5059aeb5fa45a2985f4cac97f833d Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 17 Jan 2022 13:45:32 -0600 Subject: So! Many! Changes!! --- early-init.el | 37 ++++---- eshell/aliases | 4 + eshell/history | 14 +++ eshell/lastdir | 11 +++ init.el | 50 +++++++---- lisp/+lisp.el | 2 + lisp/+org.el | 3 +- lisp/+vterm.el | 2 +- lisp/acdw.el | 13 ++- lisp/system.el | 240 +++++++++++++++++++++++++++----------------------- systems/bob.el | 10 +++ systems/gnu-linux.el | 5 ++ systems/windows-nt.el | 23 +++++ 13 files changed, 259 insertions(+), 155 deletions(-) create mode 100644 eshell/aliases create mode 100644 eshell/history create mode 100644 eshell/lastdir create mode 100644 systems/bob.el create mode 100644 systems/gnu-linux.el create mode 100644 systems/windows-nt.el diff --git a/early-init.el b/early-init.el index c87f2df..67b4271 100644 --- a/early-init.el +++ b/early-init.el @@ -57,8 +57,7 @@ See `no-littering' for examples.") (progn (require 'system) (setq system-default-font "DejaVu Sans Mono" system-variable-pitch-font "DejaVu Sans") - (setq system-load-directory (sync/ "emacs/systems/" t)) - (system-settings-load nil :nowarn)) + (system-settings-load)) ;;; Default frame settings @@ -75,7 +74,7 @@ See `no-littering' for examples.") (bottom . right))) ;;; Fonts -(progn +(+with-ensure-after-init ;; Set default faces (+with-message "Setting default faces" (let ((font-name system-default-font) @@ -90,23 +89,21 @@ See `no-littering' for examples.") :height variable-font-size))) ;; Emoji fonts - (+ensure-after-init - (lambda () - (+with-message "Adding emoji fonts" - (let ((ffl (font-family-list))) - (dolist (font '("Noto Color Emoji" - "Noto Emoji" - "Segoe UI Emoji" - "Apple Color Emoji" - "FreeSans" - "FreeMono" - "FreeSerif" - "Unifont" - "Symbola")) - (when (member font ffl) - (message "Found font: %s" font) - (set-fontset-font t 'symbol - (font-spec :family font) nil :append)))))))) + (+with-message "Adding emoji fonts" + (let ((ffl (font-family-list))) + (dolist (font '("Noto Color Emoji" + "Noto Emoji" + "Segoe UI Emoji" + "Apple Color Emoji" + "FreeSans" + "FreeMono" + "FreeSerif" + "Unifont" + "Symbola")) + (when (member font ffl) + (message "Found font: %s" font) + (set-fontset-font t 'symbol + (font-spec :family font) nil :append)))))) ;;; Packages diff --git a/eshell/aliases b/eshell/aliases new file mode 100644 index 0000000..201e556 --- /dev/null +++ b/eshell/aliases @@ -0,0 +1,4 @@ +alias edit find-file $1 +alias e find-file $1 +alias ff find-file $1 +alias sudo eshell/sudo $* diff --git a/eshell/history b/eshell/history new file mode 100644 index 0000000..67689e1 --- /dev/null +++ b/eshell/history @@ -0,0 +1,14 @@ +cd .emacs.d/.etc/straight/build/org/ +ls +cd ../ +ls +cd ../repos/org/ +ls +find-file .emacs.d/init.el +exit +apt search font +cd +vterm +cat ~/Sync/fonts-debian.txt | sudo xargs apt install +cat ~/Sync/fonts-debian.txt | sudo xargs apt install -y +alias e='find-file $*' diff --git a/eshell/lastdir b/eshell/lastdir new file mode 100644 index 0000000..1549824 --- /dev/null +++ b/eshell/lastdir @@ -0,0 +1,11 @@ +~ +/home/case/.emacs.d/.etc/straight/build/org +/home/case/.emacs.d/.etc/straight/build +/home/case/.emacs.d/.etc/straight/repos/org +/home/case +/home/case/.emacs.d +~/.emacs.d +/home/case/Sync/Click Here Digital +/home/case/Sync +/home/case +/home/case/.emacs.d diff --git a/init.el b/init.el index a938db0..4eb8cdd 100644 --- a/init.el +++ b/init.el @@ -153,9 +153,11 @@ #'browse-url-default-browser) browse-url-new-window-flag nil browse-url-firefox-arguments '("--new-tab") - browse-url-firefox-new-window-is-tab t - ;; TODO: Add variables for other transformations and what-not. - +invidious-host "invidious.snopyta.org") + browse-url-firefox-new-window-is-tab t) + (defvar +invidious-host + ;; TODO: Add variables for other transformations and what-not. + "invidious.snopyta.org" + "Host for invidious instance.") ;; Set up external browsing URLs. (add-to-list '+custom-variable-allowlist '+browse-url-secondary-browser-regexps) @@ -182,7 +184,7 @@ (t #'eww-browse-url)) args))) (cons (rx (or ;; videos - "youtube.com" "youtu.be" (eval +invidious-host) "invidious" + "youtube.com" "youtu.be" "invidious" "yewtu.be" (seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos) ;; music "soundcloud.com" "bandcamp.com" @@ -281,12 +283,17 @@ (advice-add #'eval-region :around #'+eval-region@pulse)) (setup eshell - (:also-load +eshell - em-smart + (:also-load em-smart em-tramp) - (:option eshell-aliases-file (.etc "eshell/aliases" t) + (:require +eshell) + (+define-dir eshell/ (locate-user-emacs-file "eshell") + "Where to place Eshell-specific files.") + (:option eshell-aliases-file (eshell/ "aliases") + ;; What are these for??? + eshell-rc-script (eshell/ "profile") + eshell-login-script (eshell/ "login") eshell-destroy-buffer-when-process-dies t - eshell-directory-name (.etc "eshell/" t) + eshell-directory-name eshell/ eshell-error-if-no-glob t eshell-hist-ignore-dups t eshell-kill-on-exit nil @@ -298,9 +305,13 @@ eshell-smart-space-goes-to-end t eshell-where-to-jump 'begin eshell-banner-message "") - (setf (alist-get 'eshell-mode mwim-beginning-of-line-function) - #'eshell-bol) + (with-eval-after-load 'mwim + (setf (alist-get 'eshell-mode mwim-beginning-of-line-function) + #'eshell-bol)) (+eshell-eval-after-load + ;; Local modes + (dolist (mode '((hungry-delete-mode . -1))) + (funcall (car mode) (cdr mode))) ;; Set local settings (dolist (setting (list (cons 'outline-regexp eshell-prompt-regexp) (cons 'page-delimiter eshell-prompt-regexp) @@ -523,10 +534,11 @@ org-agenda-file-regexp org-agenda-templates)) (add-to-list '+custom-variable-allowlist var)) - (defvar org-agenda-files nil) - (add-to-list 'org-agenda-files (sync/ "org/" t)) + (with-eval-after-load 'org + (add-to-list 'org-agenda-files (sync/ "org/" t))) (:+leader "a" #'org-agenda "C-a" #'org-agenda) - (:hook #'hl-line-mode)) + (:hook #'hl-line-mode) + (add-hook 'org-agenda-after-show-hook 'org-narrow-to-subtree)) (setup org-capture (:require +org-capture) @@ -609,7 +621,8 @@ (:hook #'turn-on-auto-fill)) (setup time - (:option display-time-format "%H:%M" + ;; TODO: +display-time-mode with MOAR customizations + (:option display-time-format "%H:%M %a %e" display-time-default-load-average nil display-time-mail-file :disable) (display-time-mode +1)) @@ -1086,7 +1099,7 @@ See also `crux-reopen-as-root-mode'." (eshell-vterm-mode +1)) (setup (:straight-when exec-path-from-shell - (eq system-system 'linux)) + (eq system-type 'gnu/linux)) (require 'exec-path-from-shell) (dolist (var '("SSH_AUTH_SOCK" "SSH_AGENT_PID" @@ -1129,7 +1142,7 @@ See also `crux-reopen-as-root-mode'." (setup (:straight-when (forge :host github :repo "magit/forge") - (eq system-system 'linux)) + (eq system-type 'gnu/linux)) (require 'forge) (add-to-list 'forge-alist '("tildegit.org" "tildegit.org/api/v1" "tildegit.org" @@ -1284,6 +1297,7 @@ See also `crux-reopen-as-root-mode'." (minions-mode +1)) (setup (:straight (mode-line-bell + :host github :repo "purcell/mode-line-bell" :fork (:host github :repo "duckwork/mode-line-bell"))) (:option mode-line-bell-flash-time 0.1) (mode-line-bell-mode +1)) @@ -1388,6 +1402,7 @@ See also `crux-reopen-as-root-mode'." (setup (:straight sicp)) (setup (:straight (simple-modeline + :host github :repo "gexplorer/simple-modeline" :fork (:host github :repo "duckwork/simple-modeline"))) (:require +modeline) (:option +modeline-minions-icon ";" @@ -1637,9 +1652,10 @@ See also `crux-reopen-as-root-mode'." (:global "M-z" #'+zzz-to-char)) (setup (:straight (ytdious + :host github :repo "spiderbit/ytdious" :fork (:host github :repo "duckwork/ytdious"))) (:also-load +ytdious) (:option ytdious-invidious-api-url (if +invidious-host - (concat "https://" invidious-host) + (concat "https://" +invidious-host) "https://invidious.snopyta.org")) (:bind "y" #'+ytdious-watch)) diff --git a/lisp/+lisp.el b/lisp/+lisp.el index c45fdf6..a78e40e 100644 --- a/lisp/+lisp.el +++ b/lisp/+lisp.el @@ -157,6 +157,8 @@ With a prefix argument N, (un)comment that many sexps." (+lisp-comment-sexp--raw)))) ;;; Sort `setq' constructs +;;https://emacs.stackexchange.com/questions/33039/ + (defun +lisp-sort-setq () (interactive) (save-excursion diff --git a/lisp/+org.el b/lisp/+org.el index 95a3da2..348ba6e 100644 --- a/lisp/+org.el +++ b/lisp/+org.el @@ -420,8 +420,7 @@ the deletion might narrow the column." "Open thing at point, or if there isn't something, list things." (interactive "P") (save-excursion - (let* ((browse-url-browser-function #'browse-url-default-browser) - (this-char-type (org-element-type (org-element-context))) + (let* ((this-char-type (org-element-type (org-element-context))) (prev-char-type (ignore-errors (save-excursion (backward-char) diff --git a/lisp/+vterm.el b/lisp/+vterm.el index 66e226b..06c0028 100644 --- a/lisp/+vterm.el +++ b/lisp/+vterm.el @@ -4,7 +4,7 @@ ;;; Code: -(require +vterm) +(require 'vterm) (defun +vterm-counsel-yank-pop-action (orig-fun &rest args) (if (equal major-mode 'vterm-mode) diff --git a/lisp/acdw.el b/lisp/acdw.el index 7cad67c..17741ab 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -114,13 +114,19 @@ If Emacs is already started, run FUNCTION. Otherwise, add it to (funcall function) (add-hook 'after-init-hook function))) +(defmacro +with-ensure-after-init (&rest body) + "Ensure BODY forms run after init. +Convenience macro wrapper around `+ensure-after-init'." + (declare (indent 0) (debug (def-body))) + `(+ensure-after-init (lambda () ,@body))) + (defun +remember-prefix-arg (p-arg P-arg) "Display prefix ARG, in \"p\" and \"P\" `interactive' types. I keep forgetting how they differ." (interactive "p\nP") (message "p: %S P: %S" p-arg P-arg)) -(defmacro +defvar (var value &optional _) +(defmacro +defvar (var value &rest _) "Quick way to `setq' a variable from a `defvar' form." (declare (doc-string 3)) `(setq ,var ,value)) @@ -133,7 +139,7 @@ If body executes without errors, MESSAGE...Done will be displayed." `(let ((,msg ,message)) (unwind-protect (progn (message "%s..." ,msg) ,@body) - (message "%s... Done." ,msg))))) + (message "%s...done" ,msg))))) (defun +mapc-some-buffers (func &optional predicate) "Perform FUNC on all buffers satisfied by PREDICATE. @@ -171,7 +177,8 @@ active, or else the entire buffer." (replace-match "\n\n")) ;; Insert a newline at the end. (goto-char (point-max)) - (unless (= (line-beginning-position) (line-end-position)) + (unless (or (buffer-narrowed-p) + (= (line-beginning-position) (line-end-position))) (insert "\n"))))) (defun +open-paragraph () diff --git a/lisp/system.el b/lisp/system.el index 7fe39f1..0c1e457 100644 --- a/lisp/system.el +++ b/lisp/system.el @@ -1,9 +1,9 @@ -;;; system.el --- System-specific configuration -*- lexical-binding: t; -*- +;;; system.el --- Load system-dependendant settings -*- lexical-binding: t; -*- ;;; Commentary: -;; When using Emacs on separate computers, some variables need different -;; settings. This library contains functions and variables to work with +;; When using Emacs on multiple computers, some variables and functions need +;; different definitions. This library is built to assist in working with ;; different system configurations for Emacs. ;;; Code: @@ -15,145 +15,161 @@ :group 'emacs :prefix "system-") -;;; Variables - -(defcustom system-load-alist '((system-microsoft-p . windows) - (system-linux-p . linux)) - "Alist describing which system Emacs is on. -Each cell is of the form (PREDICATE . SYSTEM), where PREDICATE is -a function of no arguments and SYSTEM is a string or symbol that -will be passed to `system-settings-load'. +;;; Settings -This list need not be exhaustive; see `system-settings-load' for -more details on what happens if this alist is exhausted." - :type '(alist :key-type function :value-type (choice string symbol))) - -(defcustom system-load-directory (locate-user-emacs-file "systems") - "The directory from which to load system-specific configurations." +(defcustom system-load-directory (locate-user-emacs-file "systems" + "~/.emacs-systems") + "The directory where system-specific configurations live." :type 'file) -;; `defcustoms' defined here are best-guess defaults. +;; These `defcustom's are best-guess defaults. -(defcustom system-default-font (pcase system-type - ((or 'ms-dos 'windows-nt) - "Consolas") - (_ "monospace")) - "The font used for the `default' face." +(defcustom system-default-font (cond + ((memq system-type '(ms-dos windows-nt)) + "Consolas") + (t "monospace")) + "The font used for the `default' face. +Set this in your system files." :type 'string) (defcustom system-default-height 100 - "The height used for the `default' face." + "The height used for the `default' face. +Set this in your system files." :type 'number) -(defcustom system-variable-pitch-font (pcase system-type - ((or 'ms-dos 'windows-nt) - "Arial") - (_ "sans-serif")) - "The font used for the `variable-pitch' face." +(defcustom system-variable-pitch-font (cond + ((memq system-type '(ms-dos windows-nt)) + "Arial") + (t "sans-serif")) + "The font used for the `variable-pitch' face. +Set this in your system files." :type 'string) (defcustom system-variable-pitch-height 1.0 "The height used for the `variable-pitch' face. A floating-point number is recommended, since that makes it -relative to the `default' face height." +relative to the `default' face height. + +Set this in your system files." :type 'number) +(defcustom system-files-order '(:type :name :user) + "The order to load `system-files' in. +The elements of this list correspond to the keys in +`system-system'." + :type '(list (const :tag "System type" :type) + (const :tag "System name" :name) + (const :tag "Current user" :user))) + +;;; Variables + (defvar system-system nil - "The current system's symbol. -Do not edit this by hand. Instead, call `system-get-system'.") + "Plist of systems that Emacs is in. +The keys are as follows: -(defvar system-file nil - "The current system's file for system-specific configuration. -Do not edit this by hand. Instead, call `system-get-system-file'.") +- :name - `system-name' +- :type - `system-type' +- :user - `user-login-name' -;;; Functions +Each value is made safe to be a file name by passing through +`system--safe'. + +Do not edit this by hand. Instead, call `system-get-systems'.") -;; Convenience functions for systems -(defun system-microsoft-p () - "Return non-nil if running in a Microsoft system." - (memq system-type '(ms-dos windows-nt))) +(defvar system-files nil + "List of files to load for system-specific configuration. +Do not edit this by hand. Instead, call `system-get-system-files'.") -(defun system-linux-p () - "Return non-nil if running on a Linux system." - (memq system-type '(gnu/linux))) + +;;; Functions -(defun system-warn (message &rest args) - "Display a wraning message made from (format-message MESSAGE ARGS...). -This function is like `warn', except it uses the `system' type." +(defun system--warn (message &rest args) + "Display a system-file warning message. +This function is like `warn', except it uses a `system' type." (display-warning 'system (apply #'format-message message args))) -(defun system-get-system () - "Determine the current system." - (cl-loop for (p . s) in system-load-alist - if (with-demoted-errors (format "Problem running function `%s'" p) - (funcall p)) - return (setq system-system s))) - -(defun system-get-system-file (&optional system refresh-cache set-system-file-p) - "Determine the current system's system-specific file. -The current system's file will be returned. The value of -`system-file' is set, /unless/ the parameter SYSTEM was passed to -this function and SET-SYSTEM-FILE-P is nil. If both SYSTEM and -SET-SYSTEM-FILE-P are non-nil, this function will still set -`system-file'. - -If SYSTEM is not passed, and `system-file' is set, simply return -its value /unless/ REFRESH-CACHE is non-nil, in which case -`system-load-alist' will be looped through to find the -appropriate system by testing the car of each cell there. When -one matches, use the cdr of that cell as SYSTEM. If none -matches, return nil. - -This function will only look for system-specific files in -`system-load-directory'." - (let* ((system* (or system - (and system-file (not refresh-cache)) - (system-get-system))) - (file (expand-file-name (format "%s" system*) system-load-directory))) - (when (or (not system) - (and system set-system-file-p)) - (setq system-file file)) - file)) +(defun system--safe (str) + "Make STR safe for a file name." + (let ((bad-char-regexp )) + (downcase (string-trim + (replace-regexp-in-string "[#%&{}\$!'\":@<>*?/ \r\n\t+`|=]+" + "-" str) + "-" "-")))) + +(defun system-get-systems () + "Determine the current system(s). +This system updates `system-system', which see." + ;; Add system-name + (setf (plist-get system-system :name) + (intern (system--safe (system-name)))) + ;; Add system-type + (setf (plist-get system-system :type) + (intern (system--safe (symbol-name system-type)))) + ;; Add current user + (setf (plist-get system-system :user) + ;; Use `user-real-login-name' in case Emacs gets called under su. + (intern (system--safe (user-real-login-name)))) + system-system) + +(defun system-get-files () + "Determine the current systems' load-files. +The system load-files should live in `system-load-directory', and +named using either the raw name given by the values of +`system-system', or that name prepended with the type, e.g., +\"name-bob.el\", for a system named \"bob\". + +The second form of file-name is to work around name collisions, +e.g. if a there's a user named \"bob\" and a system named +\"bob\". + +This function updates `system-files'." + ;; Get systems + (system-get-systems) + ;; Re-set `system-files' + (setq system-files nil) + + (let (ret) + (dolist (key (reverse system-files-order)) + (let* ((val (plist-get system-system key)) + (key-val (intern (system--safe (format "%s-%s" key val))))) + (push (list key-val val) ret))) + + ;; Update `system-files'. + (setq system-files ret))) ;;;###autoload -(defun system-settings-load (&optional system error nomessage) - "Load system settings. -Load settings from `system-file', or the `system-file' as -determined by SYSTEM, if passed. See `system-get-system-file' for -details on how the `system-file' is determined. +(defun system-settings-load (&optional error nomessage) + "Load system settings from `system-files'. +Each list in `system-files' will be considered item-by-item; the +first found file in each will be loaded. ERROR determines how to deal with errors: if nil, warn the user -when `system-file' can't be found or when the system being used -can't be determined. If t, those are elevated to errors. If any -other value, the errors are completely ignored. +when no system-files can be found or when the system being used +cannot be determined. If t, these warnings are elevated to +errors. Any other value ignores the warnings completely. NOMESSAGE is passed directly to `load'." - (let ((file (system-get-system-file system))) - (if file - (condition-case e - (load file nil nomessage) - (t (cond ((eq error t) (signal (car e) (cdr e))) - ((null error) (system-warn "Couldn't find file `%s'." - file))))) - (funcall (cond ((eq error t) #'error) - ((null error) #'system-warn) - (t #'ignore)) - "Could not determine the system being used.")))) - -;;;###autoload -(defun system-find-system-file (&optional system) - "Find the current system's system-file." - (interactive (list (completing-read "System file: " - (mapcar (lambda (a) (format "%s" (cdr a))) - system-load-alist) - nil t nil nil - (format "%s" (system-get-system))))) - (find-file (cl-loop with file = (system-get-system-file system) - for cand in (list file - (concat file ".el")) - if (file-exists-p cand) - return cand - finally return cand))) + (system-get-files) + (if system-files + (let (files-loaded) + (dolist (ss system-files) + (catch :done + (dolist (s ss) + (let ((fn (expand-file-name (format "%s" s) + system-load-directory))) + (when (load fn t nomessage) + (push fn files-loaded) + (throw :done nil)))))) + (unless files-loaded + (cond ((eq error t) (error "Error loading system-files.") + (null error) (system--warn "Couldn't load system-files.")))) + files-loaded) + (funcall (cond ((eq error t) #'error) + ((null error) #'system--warn) + (t #'ignore)) + "Couldn't determine the system being used."))) (provide 'system) ;;; system.el ends here + + diff --git a/systems/bob.el b/systems/bob.el new file mode 100644 index 0000000..427f38a --- /dev/null +++ b/systems/bob.el @@ -0,0 +1,10 @@ +;;; bob.el --- Customizations for "bob" -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + +(setq system-default-font "DejaVu Sans Mono" + system-default-height 105) + +;;; bob.el ends here diff --git a/systems/gnu-linux.el b/systems/gnu-linux.el new file mode 100644 index 0000000..333f15a --- /dev/null +++ b/systems/gnu-linux.el @@ -0,0 +1,5 @@ +;;; linux.el -*- lexical-binding: t; -*- + +(setq system-default-height 105) + +;;; linux.el ends here diff --git a/systems/windows-nt.el b/systems/windows-nt.el new file mode 100644 index 0000000..3a0deee --- /dev/null +++ b/systems/windows-nt.el @@ -0,0 +1,23 @@ +;;; windows.el --- Windows settings! -*- lexical-binding: t; -*- + +;; Annoying gnu-tls bug; I "always" trust the certificate anyway, so let's be +;; insecure. +(setq network-security-level 'low + debug-on-error t) + +;; Fonts + +(setq system-default-font "Cascadia Mono" + system-default-height 90 + system-variable-pitch-font "Carlito" + system-variable-pitch-height 1.2) + +;; Add C:\Program Files\* and C:\Program Files (x86)\* to exec-path +(dolist (path (append (file-expand-wildcards "C:/Program Files/*") + (file-expand-wildcards "c:/Program Files (x86)/*") + ;; Others... + (save-match-data + (split-string (getenv "PATH") ";" t)))) + (add-to-list 'exec-path path :append)) + +;;; windows.el ends here -- cgit 1.4.1-21-gabe81