From f345dd91b6d8cbece44616dcf72c00d26af14d0c Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 11 Jul 2022 20:00:04 -0500 Subject: 2022-07-11 --- init.el | 37 ++++++------------------------------- lisp/+emacs.el | 38 ++++++++++++++++++++++++++++---------- lisp/acdw.el | 18 ++++++++++-------- 3 files changed, 44 insertions(+), 49 deletions(-) diff --git a/init.el b/init.el index db5f512..a234d4e 100644 --- a/init.el +++ b/init.el @@ -43,14 +43,13 @@ read-file-name-completion-ignore-case t) ;; Bindings (:global "C-x C-k" #'kill-current-buffer - "C-x 4 n" #'clone-buffer + "C-M--" #'+goto-matching-paren "C-c v" #'visible-mode "C-M-;" #'+lisp-comment-or-uncomment-sexp "C-x C-o" #'+switch-to-last-buffer "C-x o" #'+switch-to-last-buffer "C-x C-l" #'+open-paragraph ; original: downcase-region "C-w" #'+kill-word-backward-or-region - "C-x C-m" #'execute-extended-command ; original: coding systems "C-" #'+backward-kill-word "C-x TAB" #'+indent-rigidly "" #'flyspell-mode @@ -60,8 +59,8 @@ ;; Disable bindings (:global "M-j" nil "" nil) - (:+leader "C-t d" #'toggle-debug-on-error - "C-t q" #'toggle-debug-on-quit) + (:+leader "C-d e" #'toggle-debug-on-error + "C-d q" #'toggle-debug-on-quit) ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults (global-set-key (kbd "C-h") 'delete-backward-char) (keyboard-translate ?\C-h ?\C-?) @@ -131,31 +130,6 @@ (global-goto-address-mode) (add-hook 'after-change-major-mode-hook #'goto-address-mode))) -(setup (:require hide-cursor-mode) ; In lisp/ - (:hook-into view-mode - Info-mode - Man-mode - help-mode - helpful-mode - notmuch-show-mode - magit-log-mode - vc-log-mode - nov-mode - elfeed-show-mode - reading-mode) - (:bind-into (view - Info - help-mode - helpful - notmuch-show - magit-log - nov - elfeed-show - reading) - "" #'hide-cursor-mode) - (:with-mode Man-mode - (:bind "" #'hide-cursor-mode))) - (setup (:require pulse) (:also-load +pulse) (:option pulse-flag nil @@ -258,7 +232,7 @@ (list (cons (rx bos (or "gemini:" "gopher:")) #'elpher-browse-url-elpher) (cons (rx ; images - "." (or "jpeg" "jpg" "png" "bmp") eos) + "." (or "jpeg" "jpg" "png" "bmp" "webp") eos) (lambda (&rest args) (apply (cond ((executable-find "mpv") #'+browse-image-with-mpv) @@ -513,7 +487,8 @@ (+kmacro-block-undo-mode +1))) (setup midnight - (midnight-mode +1)) + (midnight-mode +1) + (add-hook 'midnight-hook #'recentf-cleanup)) (setup minibuffer (:require +minibuffer) diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 322e8a9..b69d1a0 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el @@ -222,6 +222,22 @@ Do this only if the buffer is not visiting a file." (add-hook 'find-file-not-found-functions #'+auto-create-missing-dirs) +(defvar +save-some-buffers-debounce-time nil + "Last time `+save-some-buffers-debounce' was run.") + +(defcustom +save-some-buffers-debounce-timeout 5 + "Number of seconds to wait before saving buffers again.") + +(defun +save-some-buffers-debounce (&rest _) + "Run `save-some-buffers', but only if it's been a while." + (unless (and +save-some-buffers-debounce-time + (< (- (time-convert nil 'integer) +save-some-buffers-debounce-time) + +save-some-buffers-debounce-timeout)) + (save-some-buffers t) + (setq +save-some-buffers-debounce-time (time-convert nil 'integer)))) + +(add-function :after after-focus-change-function #'+save-some-buffers-debounce) + ;;; Better-default functions ... @@ -320,16 +336,18 @@ It returns nil with remote files." ;;; Bindings -(define-key (current-global-map) (kbd "C-x C-c") #'+save-buffers-quit) -(define-key (current-global-map) (kbd "M-SPC") #'+cycle-spacing) -(define-key (current-global-map) (kbd "M-/") #'hippie-expand) -(define-key (current-global-map) (kbd "M-=") #'count-words) -(define-key (current-global-map) (kbd "C-x C-b") #'ibuffer) -(define-key (current-global-map) (kbd "C-s") #'isearch-forward-regexp) -(define-key (current-global-map) (kbd "C-r") #'isearch-backward-regexp) -(define-key (current-global-map) (kbd "C-M-s") #'isearch-forward) -(define-key (current-global-map) (kbd "C-M-r") #'isearch-backward) -(define-key (current-global-map) (kbd "C-M--") #'+goto-matching-paren) +(global-set-key (kbd "C-x C-c") #'+save-buffers-quit) +(global-set-key (kbd "M-SPC") #'+cycle-spacing) +(global-set-key (kbd "M-/") #'hippie-expand) +(global-set-key (kbd "M-=") #'count-words) +(global-set-key (kbd "C-x C-b") #'ibuffer) +(global-set-key (kbd "C-s") #'isearch-forward-regexp) +(global-set-key (kbd "C-r") #'isearch-backward-regexp) +(global-set-key (kbd "C-M-s") #'isearch-forward) +(global-set-key (kbd "C-M-r") #'isearch-backward) +(global-set-key (kbd "C-x 4 n") #'clone-buffer) +;; https://christiantietze.de/posts/2022/07/shift-click-in-emacs-to-select/ +(global-set-key (kbd "S-") #'mouse-set-mark) ;;; Required libraries diff --git a/lisp/acdw.el b/lisp/acdw.el index fdcca84..26d1494 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -94,17 +94,19 @@ If body executes without errors, MESSAGE...Done will be displayed." (:success (message "%s...done" ,msg)) (t (signal (car e) (cdr e))))))) -(defun +mapc-some-buffers (func &optional predicate) - "Perform FUNC on all buffers satisfied by PREDICATE. +(defun +mapc-some-buffers (func &optional predicate-or-modes) + "Perform FUNC on all buffers satisfied by PREDICATE-OR-MODES. By default, act on all buffers. -Both PREDICATE and FUNC are called with no arguments, but within -a `with-current-buffer' form on the currently-active buffer. +Both PREDICATE-OR-MODES and FUNC are called with no arguments, +but within a `with-current-buffer' form on the currently-active +buffer. -As a special case, if PREDICATE is a list, it will be interpreted -as a list of major modes. In this case, FUNC will only be called -on buffers derived from one of the modes in PREDICATE." - (let ((pred (or predicate t))) +As a special case, if PREDICATE-OR-MODES is a list, it will be +interpreted as a list of major modes. In this case, FUNC will +only be called on buffers derived from one of the modes in +PREDICATE-OR-MODES." + (let ((pred (or predicate-or-modes t))) (dolist (buf (buffer-list)) (with-current-buffer buf (when (cond ((functionp pred) -- cgit 1.4.1-21-gabe81