Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options for selecting after meow-insert and meow-append. #619

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions meow-command.el
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
(meow--with-selection-fallback
(cond
((equal '(expand . join) (meow--selection-type))
(delete-indentation nil (region-beginning) (region-end)))

Check warning on line 259 in meow-command.el

View workflow job for this annotation

GitHub Actions / check (26.3, true)

delete-indentation called with 3 arguments, but accepts only 0-1
(t
(meow--prepare-region-for-kill)
(meow--execute-kbd-macro meow--kbd-kill-region)))))))
Expand All @@ -271,7 +271,7 @@
(meow--with-selection-fallback
(cond
((equal '(expand . join) (meow--selection-type))
(delete-indentation nil (region-beginning) (region-end)))

Check warning on line 274 in meow-command.el

View workflow job for this annotation

GitHub Actions / check (26.3, true)

delete-indentation called with 3 arguments, but accepts only 0-1
(t
(meow--prepare-region-for-kill)
(let ((s (buffer-substring-no-properties (region-beginning) (region-end))))
Expand Down Expand Up @@ -436,7 +436,9 @@
(meow--switch-state 'motion))
(meow--direction-backward)
(meow--cancel-selection)
(meow--switch-state 'insert)))
(meow--switch-state 'insert)
(when meow-select-on-insert
(setq-local meow--insert-pos (point)))))

(defun meow-append ()
"Move to the end of selection, switch to INSERT state."
Expand All @@ -451,7 +453,9 @@
(forward-char 1))
(meow--direction-forward)
(meow--cancel-selection))
(meow--switch-state 'insert)))
(meow--switch-state 'insert)
(when meow-select-on-append
(setq-local meow--insert-pos (point)))))

(defun meow-open-above ()
"Open a newline above and switch to INSERT state."
Expand Down Expand Up @@ -513,23 +517,26 @@
(meow--with-selection-fallback
(delete-region (region-beginning) (region-end))
(meow--switch-state 'insert)
(setq-local meow--insert-pos (point)))))
(when meow-select-on-change
(setq-local meow--insert-pos (point))))))

(defun meow-change-char ()
"Delete current char and switch to INSERT state."
(interactive)
(when (< (point) (point-max))
(meow--execute-kbd-macro meow--kbd-delete-char)
(meow--switch-state 'insert)
(setq-local meow--insert-pos (point))))
(when meow-select-on-change
(setq-local meow--insert-pos (point)))))

(defun meow-change-save ()
(interactive)
(let ((select-enable-clipboard meow-use-clipboard))
(when (and (meow--allow-modify-p) (region-active-p))
(kill-region (region-beginning) (region-end))
(meow--switch-state 'insert)
(setq-local meow--insert-pos (point)))))
(when meow-select-on-change
(setq-local meow--insert-pos (point))))))

(defun meow-replace ()
"Replace current selection with yank.
Expand Down Expand Up @@ -1292,7 +1299,7 @@
;;; VISIT and SEARCH
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun meow-search (arg)

Check warning on line 1302 in meow-command.el

View workflow job for this annotation

GitHub Actions / check (28.2, true)

docstring wider than 80 characters
" Search and select with the car of current `regexp-search-ring'.

If the contents of selection doesn't match the regexp, will push it to `regexp-search-ring' before searching.
Expand Down Expand Up @@ -1355,7 +1362,7 @@
(or (funcall func text nil t 1)
(funcall func-2 text nil t 1)))))

(defun meow-visit (arg)

Check warning on line 1365 in meow-command.el

View workflow job for this annotation

GitHub Actions / check (28.2, true)

docstring wider than 80 characters
"Read a string from minibuffer, then find and select it.

The input will be pushed into `regexp-search-ring'. So
Expand Down Expand Up @@ -1757,8 +1764,8 @@
(cmd (key-binding key)))
(if-let ((dispatch (and (commandp cmd)
(get cmd 'meow-dispatch))))
(describe-key (kbd dispatch) buffer up-event)

Check warning on line 1767 in meow-command.el

View workflow job for this annotation

GitHub Actions / check (27.1, true)

describe-key called with 3 arguments, but accepts only 1-2
(describe-key key-list buffer up-event)))

Check warning on line 1768 in meow-command.el

View workflow job for this annotation

GitHub Actions / check (27.1, true)

describe-key called with 3 arguments, but accepts only 1-2

Check warning on line 1768 in meow-command.el

View workflow job for this annotation

GitHub Actions / check (27.1, true)

describe-key called with 3 arguments, but accepts only 1-2
;; for mouse events
(describe-key key-list buffer up-event)))

Expand Down Expand Up @@ -1789,3 +1796,3 @@

(provide 'meow-command)
;;; meow-command.el ends here
4 changes: 3 additions & 1 deletion meow-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
(if meow-insert-mode
(run-hooks 'meow-insert-enter-hook)
(when (and meow--insert-pos
meow-select-on-change
(or meow-select-on-change
meow-select-on-append
meow-select-on-insert)
(not (= (point) meow--insert-pos)))
(thread-first
(meow--make-selection '(select . transient) meow--insert-pos (point))
Expand Down
10 changes: 10 additions & 0 deletions meow-var.el
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ This will affect how selection is displayed."
:group 'meow
:type 'boolean)

(defcustom meow-select-on-append nil
"Whether to activate region when exiting INSERT mode after `meow-append'."
:group 'meow
:type 'boolean)

(defcustom meow-select-on-insert nil
"Whether to activate region when exiting INSERT mode after `meow-insert'."
:group 'meow
:type 'boolean)

(defcustom meow-expand-hint-remove-delay 1.0
"The delay before the position hint disappears."
:group 'meow
Expand Down
Loading