summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-07-11 20:00:04 -0500
committerCase Duckworth2022-07-11 20:00:04 -0500
commitf345dd91b6d8cbece44616dcf72c00d26af14d0c (patch)
tree9cec8da1e5b9f44069c9da18070690f056a1cfb6 /lisp
parentAdd goto-matching-paren (diff)
downloademacs-f345dd91b6d8cbece44616dcf72c00d26af14d0c.tar.gz
emacs-f345dd91b6d8cbece44616dcf72c00d26af14d0c.zip
2022-07-11
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+emacs.el38
-rw-r--r--lisp/acdw.el18
2 files changed, 38 insertions, 18 deletions
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."
222 222
223(add-hook 'find-file-not-found-functions #'+auto-create-missing-dirs) 223(add-hook 'find-file-not-found-functions #'+auto-create-missing-dirs)
224 224
225(defvar +save-some-buffers-debounce-time nil
226 "Last time `+save-some-buffers-debounce' was run.")
227
228(defcustom +save-some-buffers-debounce-timeout 5
229 "Number of seconds to wait before saving buffers again.")
230
231(defun +save-some-buffers-debounce (&rest _)
232 "Run `save-some-buffers', but only if it's been a while."
233 (unless (and +save-some-buffers-debounce-time
234 (< (- (time-convert nil 'integer) +save-some-buffers-debounce-time)
235 +save-some-buffers-debounce-timeout))
236 (save-some-buffers t)
237 (setq +save-some-buffers-debounce-time (time-convert nil 'integer))))
238
239(add-function :after after-focus-change-function #'+save-some-buffers-debounce)
240
225 241
226;;; Better-default functions ... 242;;; Better-default functions ...
227 243
@@ -320,16 +336,18 @@ It returns nil with remote files."
320 336
321;;; Bindings 337;;; Bindings
322 338
323(define-key (current-global-map) (kbd "C-x C-c") #'+save-buffers-quit) 339(global-set-key (kbd "C-x C-c") #'+save-buffers-quit)
324(define-key (current-global-map) (kbd "M-SPC") #'+cycle-spacing) 340(global-set-key (kbd "M-SPC") #'+cycle-spacing)
325(define-key (current-global-map) (kbd "M-/") #'hippie-expand) 341(global-set-key (kbd "M-/") #'hippie-expand)
326(define-key (current-global-map) (kbd "M-=") #'count-words) 342(global-set-key (kbd "M-=") #'count-words)
327(define-key (current-global-map) (kbd "C-x C-b") #'ibuffer) 343(global-set-key (kbd "C-x C-b") #'ibuffer)
328(define-key (current-global-map) (kbd "C-s") #'isearch-forward-regexp) 344(global-set-key (kbd "C-s") #'isearch-forward-regexp)
329(define-key (current-global-map) (kbd "C-r") #'isearch-backward-regexp) 345(global-set-key (kbd "C-r") #'isearch-backward-regexp)
330(define-key (current-global-map) (kbd "C-M-s") #'isearch-forward) 346(global-set-key (kbd "C-M-s") #'isearch-forward)
331(define-key (current-global-map) (kbd "C-M-r") #'isearch-backward) 347(global-set-key (kbd "C-M-r") #'isearch-backward)
332(define-key (current-global-map) (kbd "C-M--") #'+goto-matching-paren) 348(global-set-key (kbd "C-x 4 n") #'clone-buffer)
349;; https://christiantietze.de/posts/2022/07/shift-click-in-emacs-to-select/
350(global-set-key (kbd "S-<down-mouse-1>") #'mouse-set-mark)
333 351
334 352
335;;; Required libraries 353;;; 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."
94 (:success (message "%s...done" ,msg)) 94 (:success (message "%s...done" ,msg))
95 (t (signal (car e) (cdr e))))))) 95 (t (signal (car e) (cdr e)))))))
96 96
97(defun +mapc-some-buffers (func &optional predicate) 97(defun +mapc-some-buffers (func &optional predicate-or-modes)
98 "Perform FUNC on all buffers satisfied by PREDICATE. 98 "Perform FUNC on all buffers satisfied by PREDICATE-OR-MODES.
99By default, act on all buffers. 99By default, act on all buffers.
100 100
101Both PREDICATE and FUNC are called with no arguments, but within 101Both PREDICATE-OR-MODES and FUNC are called with no arguments,
102a `with-current-buffer' form on the currently-active buffer. 102but within a `with-current-buffer' form on the currently-active
103buffer.
103 104
104As a special case, if PREDICATE is a list, it will be interpreted 105As a special case, if PREDICATE-OR-MODES is a list, it will be
105as a list of major modes. In this case, FUNC will only be called 106interpreted as a list of major modes. In this case, FUNC will
106on buffers derived from one of the modes in PREDICATE." 107only be called on buffers derived from one of the modes in
107 (let ((pred (or predicate t))) 108PREDICATE-OR-MODES."
109 (let ((pred (or predicate-or-modes t)))
108 (dolist (buf (buffer-list)) 110 (dolist (buf (buffer-list))
109 (with-current-buffer buf 111 (with-current-buffer buf
110 (when (cond ((functionp pred) 112 (when (cond ((functionp pred)