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 meow(-backward)-kill-{word,symbol} #644

Merged
merged 2 commits into from
Oct 12, 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
6 changes: 6 additions & 0 deletions COMMANDS.org
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ Call the command on ~C-k~.

Call the command on ~C-d~.

*** meow-kill-word, meow-backward-kill-word, meow-kill-symbol, meow-backward-kill-symbol

Versions of ~kill-word~ and ~backward-kill-word~ that respect ~meow-word-thing~
and ~meow-symbol-thing~. May be bound to M-d and M-DEL in place of ~kill-word~
and ~backward-kill-word~.

*** meow-save

Copy.
Expand Down
5 changes: 5 additions & 0 deletions CUSTOMIZATIONS.org
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ Default: ='((?c . ?c) (?h . ?h) (?x . ?x))=
Alist of keys to begin keypad translation. For instance, given the default
value, pressing "c" in keypad mode will look up it's value in the alist, and
add "C-c" to the keypad.

** meow-keypad-self-insert-undefined

Default: =t=
Expand Down Expand Up @@ -225,6 +226,7 @@ Default:
#+end_src

A association list of state symbols to strings describing the state.

** meow-indicator-face-alist
Default:

Expand Down Expand Up @@ -410,3 +412,6 @@ to Vim's -

(setq meow-word-thing 'vimlike-word)
#+end_src

Meow also provides ~meow-kill-word~ and ~meow-backward-kill-word~, versions of
~kill-word~ and ~backward-kill-word~ that respect ~meow-word-thing~.
37 changes: 37 additions & 0 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 @@ -299,6 +299,43 @@
(interactive)
(meow--execute-kbd-macro meow--kbd-delete-char))

(defun meow-backward-kill-word (arg)
"Kill characters backward until the beginning of a `meow-word-thing'.
With argument ARG, do this that many times."
(interactive "p")
(meow-kill-word (- arg)))

(defun meow-kill-word (arg)
"Kill characters forward until the end of a `meow-word-thing'.
With argument ARG, do this that many times."
(interactive "p")
(meow-kill-thing meow-word-thing arg))

(defun meow-backward-kill-symbol (arg)
"Kill characters backward until the beginning of a `meow-symbol-thing'.
With argument ARG, do this that many times."
(interactive "p")
(meow-kill-symbol (- arg)))

(defun meow-kill-symbol (arg)
"Kill characters forward until the end of a `meow-symbol-thing'.
With argument ARG, do this that many times."
(interactive "p")
(meow-kill-thing meow-symbol-thing arg))


(defun meow-kill-thing (thing arg)
"Kill characters forward until the end of a THING.
With argument ARG, do this that many times."
(let ((start (point))
(end (progn (forward-thing thing arg) (point))))
(condition-case _
(kill-region start end)
((text-read-only buffer-read-only)
(condition-case err
(meow--delete-region start end)
(t (signal (car err) (cdr err))))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; PAGE UP&DOWN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -1799,3 +1836,3 @@

(provide 'meow-command)
;;; meow-command.el ends here
Loading