Skip to content

Commit

Permalink
Add meow(-backward)-kill-{word,symbol} (#644)
Browse files Browse the repository at this point in the history
* add: meow(-backward)-kill-word

Versions of `kill-word` and `backward-kill-word` that respect
`meow-word-thing`.

* revise: meow-(backward-)kill-{word,symbol}

We should have commands for both `meow-word-thing` and
`meow-symbol-thing`.

---------

Co-authored-by: 45mg <[email protected]>
  • Loading branch information
45mg and 45mg authored Oct 12, 2024
1 parent 675cd12 commit 620a06e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
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 @@ -299,6 +299,43 @@ This command supports `meow-selection-command-fallback'."
(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

0 comments on commit 620a06e

Please sign in to comment.