mirror of
https://github.com/abo-abo/avy.git
synced 2025-10-13 13:33:03 +00:00
Add "X" dispatch to kill a word without moving there
* avy.el (avy-dispatch-alist): Extend. (avy-action-kill-move): Rename from `avy-action-kill'. (avy-action-kill-stay): New defun. To kill a word without moving there: 1. `avy-goto-word-1' or `avy-goto-char'. 2. word's letter. 3. X. 4. words' overlay chars.
This commit is contained in:
parent
9e61f786d8
commit
a80f95c015
19
avy.el
19
avy.el
@ -120,7 +120,8 @@ If the commands isn't on the list, `avy-style' is used."
|
||||
(const :tag "De Bruijn" de-bruijn))))
|
||||
|
||||
(defcustom avy-dispatch-alist
|
||||
'((?x . avy-action-kill)
|
||||
'((?x . avy-action-kill-move)
|
||||
(?X . avy-action-kill-stay)
|
||||
(?m . avy-action-mark)
|
||||
(?n . avy-action-copy))
|
||||
"List of actions for `avy-handler-default'.
|
||||
@ -134,7 +135,8 @@ pressed during the dispatch, ACTION is set to replace the default
|
||||
:value-type (choice
|
||||
(const :tag "Mark" avy-action-mark)
|
||||
(const :tag "Copy" avy-action-copy)
|
||||
(const :tag "Kill" avy-action-kill))))
|
||||
(const :tag "Kill and move point" avy-action-kill-move)
|
||||
(const :tag "Kill" avy-action-kill-stay))))
|
||||
|
||||
(defcustom avy-background nil
|
||||
"When non-nil, a gray background will be added during the selection."
|
||||
@ -505,13 +507,22 @@ Set `avy-style' according to COMMMAND as well."
|
||||
(select-window (cdr dat))
|
||||
(goto-char (car dat))))
|
||||
|
||||
(defun avy-action-kill (pt)
|
||||
"Kill sexp at PT."
|
||||
(defun avy-action-kill-move (pt)
|
||||
"Kill sexp at PT and move there."
|
||||
(goto-char pt)
|
||||
(forward-sexp)
|
||||
(kill-region pt (point))
|
||||
(message "Killed: %s" (current-kill 0)))
|
||||
|
||||
(defun avy-action-kill-stay (pt)
|
||||
"Kill sexp at PT."
|
||||
(save-excursion
|
||||
(goto-char pt)
|
||||
(forward-sexp)
|
||||
(kill-region pt (point))
|
||||
(just-one-space))
|
||||
(message "Killed: %s" (current-kill 0)))
|
||||
|
||||
(defun avy--process (candidates overlay-fn)
|
||||
"Select one of CANDIDATES using `avy-read'.
|
||||
Use OVERLAY-FN to visualize the decision overlay."
|
||||
|
Loading…
x
Reference in New Issue
Block a user