Skip to content

Commit

Permalink
Add selection fallback to meow-expand with meow-digit-argument as def…
Browse files Browse the repository at this point in the history
…ault
  • Loading branch information
DogLooksGood committed Oct 26, 2024
1 parent 33a2479 commit d037525
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
37 changes: 19 additions & 18 deletions meow-command.el
Original file line number Diff line number Diff line change
Expand Up @@ -1616,24 +1616,25 @@ Argument ARG if not nil, switching in a new window."

(defun meow-expand (&optional n)
(interactive)
(when (and meow--expand-nav-function
(region-active-p)
(meow--selection-type))
(let* ((n (or n (string-to-number (char-to-string last-input-event))))
(n (if (= n 0) 10 n))
(sel-type (cons meow-expand-selection-type (cdr (meow--selection-type)))))
(thread-first
(meow--make-selection sel-type (mark)
(save-mark-and-excursion
(let ((meow--expanding-p t))
(dotimes (_ n)
(funcall
(if (meow--direction-backward-p)
(car meow--expand-nav-function)
(cdr meow--expand-nav-function)))))
(point)))
(meow--select))
(meow--maybe-highlight-num-positions meow--expand-nav-function))))
(meow--with-selection-fallback
(when (and meow--expand-nav-function
(region-active-p)
(meow--selection-type))
(let* ((n (or n (string-to-number (char-to-string last-input-event))))
(n (if (= n 0) 10 n))
(sel-type (cons meow-expand-selection-type (cdr (meow--selection-type)))))
(thread-first
(meow--make-selection sel-type (mark)
(save-mark-and-excursion
(let ((meow--expanding-p t))
(dotimes (_ n)
(funcall
(if (meow--direction-backward-p)
(car meow--expand-nav-function)
(cdr meow--expand-nav-function)))))
(point)))
(meow--select))
(meow--maybe-highlight-num-positions meow--expand-nav-function)))))

(defun meow-expand-1 () (interactive) (meow-expand 1))
(defun meow-expand-2 () (interactive) (meow-expand 2))
Expand Down
3 changes: 2 additions & 1 deletion meow-var.el
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ This will affect how selection is displayed."
(meow-kill . meow-C-k)
(meow-cancel-selection . keyboard-quit)
(meow-pop-selection . meow-pop-grab)
(meow-beacon-change . meow-beacon-change-char))
(meow-beacon-change . meow-beacon-change-char)
(meow-expand . meow-digit-argument))
"Fallback commands for selection commands when there is no available selection."
:group 'meow
:type '(alist :key-type (function :tag "Command")
Expand Down

0 comments on commit d037525

Please sign in to comment.