From 9e46efac61fc4246b810c8b19127248ed7b3080e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 5 Jan 2022 17:12:32 -0600 Subject: Lots of changes, maybe breaking something I have to do a big debugging tonight. Keybinds aren't getting picked up, idk what's going on. --- lisp/+casing.el | 47 ++++++++++++++++++++++----------------- lisp/+emacs.el | 69 +++++++++++++++++++++++++++------------------------------ lisp/+lookup.el | 16 ++++++++----- lisp/acdw.el | 8 ++++++- 4 files changed, 78 insertions(+), 62 deletions(-) (limited to 'lisp') diff --git a/lisp/+casing.el b/lisp/+casing.el index fe97310..a21e710 100644 --- a/lisp/+casing.el +++ b/lisp/+casing.el @@ -3,17 +3,7 @@ ;;; Code: (require 'thingatpt) - -(defvar +casing-map (make-sparse-keymap) - "Keymap for word-casing.") - -(let ((map +casing-map)) - (define-key map "u" #'+upcase-dwim) - (define-key map (kbd "M-u") #'+upcase-dwim) - (define-key map "l" #'+downcase-dwim) - (define-key map (kbd "M-l") #'+downcase-dwim) - (define-key map "c" #'+capitalize-dwim) - (define-key map (kbd "M-c") #'+capitalize-dwim)) +(require '+key) ;;;###autoload (defun +upcase-dwim (arg) @@ -28,9 +18,10 @@ Otherwise, it calls `upcase-word' on the word at point (using (word-bound (save-excursion (skip-chars-forward "^[:word:]") (bounds-of-thing-at-point 'word)))) - (upcase-region (car word-bound) (cdr word-bound)) - (goto-char (cdr word-bound)) - (upcase-word following)))) + (when (and (car word-bound) (cdr word-bound)) + (upcase-region (car word-bound) (cdr word-bound)) + (goto-char (cdr word-bound)) + (upcase-word following))))) ;;;###autoload (defun +downcase-dwim (arg) @@ -45,9 +36,10 @@ Otherwise, it calls `downcase-word' on the word at point (using (word-bound (save-excursion (skip-chars-forward "^[:word:]") (bounds-of-thing-at-point 'word)))) - (downcase-region (car word-bound) (cdr word-bound)) - (goto-char (cdr word-bound)) - (downcase-word following)))) + (when (and (car word-bound) (cdr word-bound)) + (downcase-region (car word-bound) (cdr word-bound)) + (goto-char (cdr word-bound)) + (downcase-word following))))) ;;;###autoload (defun +capitalize-dwim (arg) @@ -62,11 +54,26 @@ Otherwise, it calls `capitalize-word' on the word at point (using (word-bound (save-excursion (skip-chars-forward "^[:word:]") (bounds-of-thing-at-point 'word)))) - (capitalize-region (car word-bound) (cdr word-bound)) - (goto-char (cdr word-bound)) - (capitalize-word following)))) + (when (and (car word-bound) (cdr word-bound)) + (capitalize-region (car word-bound) (cdr word-bound)) + (goto-char (cdr word-bound)) + (capitalize-word following))))) ;; Later on, I'll add repeat maps and stuff in here... +(define-minor-mode +casing-mode + "Enable easy case-twiddling commands." + :lighter " cC" + :keymap (let ((map (make-sparse-keymap))) + (define-key map "u" #'+upcase-dwim) + (define-key map (kbd "M-u") #'+upcase-dwim) + (define-key map "l" #'+downcase-dwim) + (define-key map (kbd "M-l") #'+downcase-dwim) + (define-key map "c" #'+capitalize-dwim) + (define-key map (kbd "M-c") #'+capitalize-dwim) + map) + (define-key +key-mode-map (kbd "M-c") (when +casing-mode + +casing-mode-map))) + (provide '+casing) ;;; +casing.el ends here diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 2e3d257..7453913 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el @@ -80,8 +80,8 @@ Do this only if the buffer is not visiting a file." mark-ring-max 50 minibuffer-eldef-shorten-default t minibuffer-prompt-properties (list 'read-only t - 'cursor-intangible t - 'face 'minibuffer-prompt) + 'cursor-intangible t + 'face 'minibuffer-prompt) mode-require-final-newline 'visit-save mouse-drag-copy-region t mouse-wheel-progressive-speed nil @@ -90,8 +90,8 @@ Do this only if the buffer is not visiting a file." read-answer-short t read-buffer-completion-ignore-case t read-extended-command-predicate (when (fboundp - 'command-completion-default-include-p) - 'command-completion-default-include-p) + 'command-completion-default-include-p) + 'command-completion-default-include-p) recenter-positions '(top middle bottom) regexp-search-ring-max 100 regexp-search-ring-max 200 @@ -169,23 +169,23 @@ Do this only if the buffer is not visiting a file." ;;; Modes (dolist (enable-mode '(global-auto-revert-mode - blink-cursor-mode - electric-pair-mode - show-paren-mode - global-so-long-mode - minibuffer-depth-indicate-mode - file-name-shadow-mode - minibuffer-electric-default-mode - delete-selection-mode - column-number-mode)) + blink-cursor-mode + electric-pair-mode + show-paren-mode + global-so-long-mode + minibuffer-depth-indicate-mode + file-name-shadow-mode + minibuffer-electric-default-mode + delete-selection-mode + column-number-mode)) (when (fboundp enable-mode) (funcall enable-mode +1))) (dolist (disable-mode '(tooltip-mode tool-bar-mode - menu-bar-mode - scroll-bar-mode - horizontal-scroll-bar-mode)) + menu-bar-mode + scroll-bar-mode + horizontal-scroll-bar-mode)) (when (fboundp disable-mode) (funcall disable-mode -1))) @@ -243,19 +243,16 @@ kill without asking." ("C-s" . isearch-forward-regexp) ("C-r" . isearch-backward-regexp) ("C-M-s" . isearch-forward) - ("C-M-r" . isearch-backward) - ("M-u" . upcase-dwim) - ("M-l" . downcase-dwim) - ("M-c" . capitalize-dwim))) + ("C-M-r" . isearch-backward))) (define-key +key-mode-map (kbd (car binding)) (cdr binding))) ;;; Required libraries (when (require 'uniquify nil :noerror) (setq-default uniquify-buffer-name-style 'forward - uniquify-separator path-separator - uniquify-after-kill-buffer-p t - uniquify-ignore-buffers-re "^\\*")) + uniquify-separator path-separator + uniquify-after-kill-buffer-p t + uniquify-ignore-buffers-re "^\\*")) (when (require 'goto-addr) (if (fboundp 'global-goto-address-mode) @@ -264,36 +261,36 @@ kill without asking." (when (require 'recentf nil :noerror) (setq-default recentf-save-file (.etc "recentf.el") - recentf-max-menu-items 100 - recentf-max-saved-items nil - recentf-auto-cleanup 'mode) + recentf-max-menu-items 100 + recentf-max-saved-items nil + recentf-auto-cleanup 'mode) (add-to-list 'recentf-exclude .etc) (recentf-mode +1)) (when (require 'repeat nil :noerror) (setq-default repeat-exit-key "g" - repeat-exit-timeout 5) + repeat-exit-timeout 5) (when (fboundp 'repeat-mode) ;; `repeat-mode' is defined in repeat.el, which is an older library. (repeat-mode +1))) (when (require 'savehist nil :noerror) (setq-default history-length t - history-delete-duplicates t - history-autosave-interval 60 - savehist-file (.etc "savehist.el")) + history-delete-duplicates t + history-autosave-interval 60 + savehist-file (.etc "savehist.el")) (dolist (var '(extended-command-history - global-mark-ring - kill-ring - regexp-search-ring - search-ring - mark-ring)) + global-mark-ring + kill-ring + regexp-search-ring + search-ring + mark-ring)) (add-to-list 'savehist-additional-variables var)) (savehist-mode +1)) (when (require 'saveplace nil :noerror) (setq-default save-place-file (.etc "places.el") - save-place-forget-unreadable-files (eq system-type 'gnu/linux)) + save-place-forget-unreadable-files (eq system-type 'gnu/linux)) (save-place-mode +1)) ;; (when (require 'tramp) diff --git a/lisp/+lookup.el b/lisp/+lookup.el index dfa0180..f13f535 100644 --- a/lisp/+lookup.el +++ b/lisp/+lookup.el @@ -7,11 +7,17 @@ ;;; Code: -(defvar +lookup-map (let ((map (make-sparse-keymap))) - (define-key map "f" #'find-function) - (define-key map "l" #'find-library) - map) - "Keymap for looking up things.") +(require '+key) + +(define-minor-mode +lookup-mode + "A mode for easily looking things up." + :lighter " l^" + :keymap (let ((map (make-sparse-keymap))) + (define-key map "f" #'find-function) + (define-key map "l" #'find-library) + map) + (define-key +key-mode-map (kbd "C-c l") (when +lookup-mode + +lookup-mode-map))) (provide '+lookup) ;;; +lookup.el ends here diff --git a/lisp/acdw.el b/lisp/acdw.el index a6fddfe..fcab61b 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -19,6 +19,8 @@ ;;; Code: +(require 'diary-lib) + ;;; Define a directory and an expanding function (defmacro +define-dir (name directory &optional docstring inhibit-mkdir) @@ -94,7 +96,11 @@ itself." ;; sunset-command. (funcall sunset-command) (run-at-time sunrise nil sunrise-command)) - ((time-less-p nil sunset-time) (run-at-time sunset nil sunset-command)) + ((time-less-p nil sunset-time) + ;; If it isn't sunset yet, it's still light---so we need to run the + ;; sunrise-command. + (funcall sunrise-command) + (run-at-time sunset nil sunset-command)) (t (run-at-time "12:00am" nil sunset-command))) ;; Reset everything at midnight (unless reset -- cgit 1.4.1-21-gabe81