aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2025-07-28 16:05:05 -0700
committerGravatar Tom Willemse2025-07-28 16:05:05 -0700
commitf3c6b1870d5cbe1b52bc1ad244bd0310ffdec555 (patch)
tree612ce5135e3fe3c69db215a0d9136a62cab823f8
parent98b10b21fcee5f376437cd3a0952763032c28310 (diff)
downloademacs-config-f3c6b1870d5cbe1b52bc1ad244bd0310ffdec555.tar.gz
emacs-config-f3c6b1870d5cbe1b52bc1ad244bd0310ffdec555.zip
oni-core: Add functions to inc-/decrement number at point
-rw-r--r--oni-core.el22
1 files changed, 21 insertions, 1 deletions
diff --git a/oni-core.el b/oni-core.el
index a62f8ef..8e7798b 100644
--- a/oni-core.el
+++ b/oni-core.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2025.0707.145555
+;; Version: 2025.0728.160458
;; Package-Requires: (oni-data-dir oni-embrace oni-hydra expand-region multiple-cursors gcmh diminish ws-butler which-key insert-char-preview mixed-pitch ace-window vertico marginalia orderless consult embark docstr mini-frame)
;; This program is free software; you can redistribute it and/or modify
@@ -103,6 +103,24 @@
(let ((inhibit-message t))
(recentf-save-list)))
+(defun mutate-number-at-point (mutator)
+ (let ((bounds (bounds-of-thing-at-point 'symbol)))
+ (replace-region-contents
+ (car bounds)
+ (cdr bounds)
+ (lambda ()
+ (number-to-string
+ (funcall mutator (string-to-number
+ (buffer-substring (point-min) (point-max)))))))))
+
+(defun increment-number-at-point ()
+ (interactive)
+ (mutate-number-at-point '1+))
+
+(defun decrement-number-at-point ()
+ (interactive)
+ (mutate-number-at-point '1-))
+
(defhydra oni-sort-and-align-hydra (:color teal :hint nil)
"
^Sort^
@@ -218,6 +236,8 @@ _s_: String list"
(global-set-key [remap upcase-word] #'upcase-dwim)
(global-set-key [remap downcase-word] #'downcase-dwim)
(global-set-key [remap capitalize-word] #'capitalize-dwim)
+(global-set-key (kbd "C-c i +") #'increment-number-at-point)
+(global-set-key (kbd "C-c i -") #'decrement-number-at-point)
(global-set-key (kbd "C-<left>") 'winner-undo)
(global-set-key (kbd "C-<right>") 'winner-redo)