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 --- lisp/+emacs.el | 38 ++++++++++++++++++++++++++++---------- lisp/acdw.el | 18 ++++++++++-------- 2 files changed, 38 insertions(+), 18 deletions(-) (limited to 'lisp') 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