From fc72ca6248712a9d82c3c1e13c9f72459bd3effe Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 7 Apr 2021 00:14:08 -0500 Subject: Uh --- init.el | 41 +++++++++++++++++------------- lisp/acdw.el | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 98 insertions(+), 25 deletions(-) diff --git a/init.el b/init.el index 4b0bd8c..0e621bd 100644 --- a/init.el +++ b/init.el @@ -66,7 +66,7 @@ calendar-longitude -91.1) ;; Lines - (:option fill-column 80 + (:option fill-column 79 word-wrap t truncate-lines nil) @@ -115,7 +115,7 @@ ;; Cursor (:option cursor-type 'bar cursor-in-non-selected-windows 'hollow - blink-cursor-blinks 1) + blink-cursor-blinks 1) (blink-cursor-mode +1) ;; Scrolling @@ -306,7 +306,14 @@ (write-region "" nil ispell-personal-dictionary nil 0)) (add-hook 'text-mode-hook #'flyspell-mode) - (add-hook 'prog-mode-hook #'flyepell-prog-mode)) + (add-hook 'prog-mode-hook #'flyspell-prog-mode)) + +(setup scratch + (hook-defun immortal-scratch kill-buffer-query-functions + (if (eq (current-buffer (get-buffer "*scratch*"))) + (progn (bury-buffer) + nil) + t))) ;; Applications @@ -405,17 +412,17 @@ '("\\.\\(gemini\\|gmi\\)\\'" . gemini-mode))) (setup dired - (:setq-default dired-recursive-copies 'always - dired-recursive-deletes 'always - delete-by-moving-to-trash t - dired-listing-switches "-Al" - ls-lisp-dirs-first t - dired-ls-F-marks-symlinks t - dired-no-confirm '(byte-compile - chgrp chmod chown copy - hardlink load move - shell touch symlink) - dired-dwim-target t) + (:option dired-recursive-copies 'always + dired-recursive-deletes 'always + delete-by-moving-to-trash t + dired-listing-switches "-Al" + ls-lisp-dirs-first t + dired-ls-F-marks-symlinks t + dired-no-confirm '(byte-compile + chgrp chmod chown copy + hardlink load move + shell touch symlink) + dired-dwim-target t) (:also-load dired-x) (:hook dired-hide-details-mode hl-line-mode) @@ -435,7 +442,7 @@ (:option trashed-action-confirmer 'y-or-n-p)))) (setup (:straight magit) - (:acdw/leader "g" magit-status) + (:leader "g" magit-status) (:option magit-display-buffer-function (defun magit-display-buffer-same-window (buffer) "Display BUFFER in the selected window like God intended." @@ -736,8 +743,8 @@ if ripgrep is installed, otherwise `consult-grep'." (when (executable-find "fennel") (setup (:straight fennel-mode) (autoload 'fennel-mode "fennel-mode" nil t) - (:option (append auto-mode-alist) '("\\.fnl\\'" . fennel-mode)) - (:bind "C-c C-c" ))) + (autoload 'fennel-repl "fennel-mode" nil t) + (:option (append auto-mode-alist) '("\\.fnl\\'" . fennel-mode)))) (setup (:straight geiser)) diff --git a/lisp/acdw.el b/lisp/acdw.el index 69f9a7f..7b555fd 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -22,9 +22,9 @@ ;; Utility constants (defconst acdw/system (pcase system-type - ('gnu/linux :home) - ((or 'msdos 'windows-nt) :work) - (_ :other)) + ('gnu/linux :home) + ((or 'msdos 'windows-nt) :work) + (_ :other)) "Which computer system is currently being used.") @@ -38,7 +38,7 @@ is unfocused." `(progn (defun ,func-name () "Defined by `when-unfocused'." (when (seq-every-p #'null - (mapcar #'frame-focus-state (frame-list))) + (mapcar #'frame-focus-state (frame-list))) ,@forms)) (add-function :after after-focus-change-function #',func-name)))) @@ -52,7 +52,7 @@ each hook in HOOKS." `(progn (defun ,func-name () "Defined by `hook-defun'." ,@forms) ,@(dolist (hook hook-list hook-defun-add-hook-list) - (push `(add-hook ',hook #',func-name) hook-defun-add-hook-list))))) + (push `(add-hook ',hook #',func-name) hook-defun-add-hook-list))))) (defun refresh-emacs () "Reload Emacs's configuration files." @@ -73,7 +73,7 @@ if MAKE-DIRECTORY is non-nil." user-emacs-directory))) (if file (let ((file-name (expand-file-name (convert-standard-filename file) - dir))) + dir))) (when make-directory (make-directory (file-name-directory file-name) 'parents)) file-name) @@ -82,12 +82,33 @@ if MAKE-DIRECTORY is non-nil." (defun acdw/gc-enable () "Enable the Garbage collector." (setq gc-cons-threshold (* 800 1024 1024) - gc-cons-percentage 0.1)) + gc-cons-percentage 0.1)) (defun acdw/gc-disable () "Functionally disable the Garbage collector." (setq gc-cons-threshold most-positive-fixnum - gc-cons-percentage 0.8)) + gc-cons-percentage 0.8)) + +(defun acdw/sunrise-sunset (sunrise-command sunset-command) + "Run commands at sunrise and sunset." + (let* ((times-regex (rx (* nonl) + (: (any ?s ?S) "unrise") " " + (group (repeat 1 2 digit) ":" + (repeat 1 2 digit) + (: (any ?a ?A ?p ?P) (any ?m ?M))) + (* nonl) + (: (any ?s ?S) "unset") " " + (group (repeat 1 2 digit) ":" + (repeat 1 2 digit) + (: (any ?a ?A ?p ?P) (any ?m ?M))) + (* nonl))) + (ss (sunrise-sunset)) + (_m (string-match times-regex ss)) + (sunrise-time (match-string 1 ss)) + (sunset-time (match-string 2 ss))) + (run-at-time sunrise-time (* 60 60 24) sunrise-command) + (run-at-time sunset-time (* 60 60 24) sunset-command) + (run-at-time "12:00am" (* 60 60 24) sunset-command))) ;; Make `C-z' more useful @@ -98,5 +119,50 @@ if MAKE-DIRECTORY is non-nil." (define-key map "\C-z" c-z) map)) + +;; `acdw/reading-mode' +(define-minor-mode acdw/reading-mode + "A mode for reading." + :init-value nil + :lighter " Read" + (if acdw/reading-mode + (progn ;; turn on + ;; settings + (setq-local mode-line-format + '(:eval + (let* ((fmt " Reading %b") + (len (length (format-mode-line fmt)))) + (concat + (propertize " " + 'display `((space :align-to (- right + ,len))) + 'face '(:inherit italic)) + fmt))) + orig-indicate-empty-lines indicate-empty-lines + indicate-empty-lines nil + orig-indicate-buffer-boundaries indicate-buffer-boundaries + indicate-buffer-boundaries nil) + ;; disable modes + (dolist (mode '(display-fill-column-indicator-mode)) + (when (fboundp mode) + (funcall mode -1))) + ;; enable modes + (dolist (mode '(iscroll-mode olivetti-mode)) + (when (fboundp mode) + (funcall mode +1)))) + ;; turn off + ;; settings + (setq-local indicate-empty-lines orig-indicate-empty-lines + indicate-buffer-boundaries orig-indicate-buffer-boundaries) + (kill-local-variable 'mode-line-format) + ;; enable modes + (dolist (mode '(display-fill-column-indicator-mode)) + (when (fboundp mode) + (funcall mode +1))) + ;; disable modes + (dolist (mode '(olivetti-mode iscroll-mode)) + (when (fboundp mode) + (funcall mode -1))))) + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81