mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
Make backspace/DEL clear field (#957)
* yasnippet.el (yas-clear-field): New command. (yas-maybe-clear-field): New conditional binding value. (yas-keymap): Bind it to DEL.
This commit is contained in:
parent
fb253ac607
commit
bceb65ba29
16
yasnippet.el
16
yasnippet.el
@ -402,7 +402,15 @@ It must be set to nil before loading yasnippet to take effect."
|
|||||||
"A conditional key definition.
|
"A conditional key definition.
|
||||||
This can be used as a key definition in keymaps to bind a key to
|
This can be used as a key definition in keymaps to bind a key to
|
||||||
`yas-skip-and-clear-field' only when at the beginning of an
|
`yas-skip-and-clear-field' only when at the beginning of an
|
||||||
unmodified snippey field.")
|
unmodified snippet field.")
|
||||||
|
|
||||||
|
(defconst yas-maybe-clear-field
|
||||||
|
'(menu-item "" yas-clear-field
|
||||||
|
:filter yas--maybe-clear-field-filter)
|
||||||
|
"A conditional key definition.
|
||||||
|
This can be used as a key definition in keymaps to bind a key to
|
||||||
|
`yas-clear-field' only when at the beginning of an
|
||||||
|
unmodified snippet field.")
|
||||||
|
|
||||||
(defvar yas-keymap (let ((map (make-sparse-keymap)))
|
(defvar yas-keymap (let ((map (make-sparse-keymap)))
|
||||||
(define-key map [(tab)] 'yas-next-field-or-maybe-expand)
|
(define-key map [(tab)] 'yas-next-field-or-maybe-expand)
|
||||||
@ -411,6 +419,7 @@ unmodified snippey field.")
|
|||||||
(define-key map [backtab] 'yas-prev-field)
|
(define-key map [backtab] 'yas-prev-field)
|
||||||
(define-key map (kbd "C-g") 'yas-abort-snippet)
|
(define-key map (kbd "C-g") 'yas-abort-snippet)
|
||||||
(define-key map (kbd "C-d") yas-maybe-skip-and-clear-field)
|
(define-key map (kbd "C-d") yas-maybe-skip-and-clear-field)
|
||||||
|
(define-key map (kbd "DEL") yas-maybe-clear-field)
|
||||||
map)
|
map)
|
||||||
"The active keymap while a snippet expansion is in progress.")
|
"The active keymap while a snippet expansion is in progress.")
|
||||||
|
|
||||||
@ -3678,6 +3687,11 @@ Use as a `:filter' argument for a conditional keybinding."
|
|||||||
(yas--skip-and-clear (or field (yas-current-field)))
|
(yas--skip-and-clear (or field (yas-current-field)))
|
||||||
(yas-next-field 1))
|
(yas-next-field 1))
|
||||||
|
|
||||||
|
(defun yas-clear-field (&optional field)
|
||||||
|
"Clears unmodified FIELD if at field start."
|
||||||
|
(interactive)
|
||||||
|
(yas--skip-and-clear (or field (yas-current-field))))
|
||||||
|
|
||||||
(defun yas-skip-and-clear-or-delete-char (&optional field)
|
(defun yas-skip-and-clear-or-delete-char (&optional field)
|
||||||
"Clears unmodified field if at field start, skips to next tab.
|
"Clears unmodified field if at field start, skips to next tab.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user