From fc72ca6248712a9d82c3c1e13c9f72459bd3effe Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 7 Apr 2021 00:14:08 -0500 Subject: Uh --- lisp/acdw.el | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 8 deletions(-) (limited to 'lisp') 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