fix(yasnippet): C-d clears field; ensure insert state on expand

This commit is contained in:
2026-02-24 14:54:12 +01:00
parent 8ba2c65fcf
commit a984353093

View File

@@ -1260,6 +1260,21 @@ Otherwise: runs interactive ement-connect, then opens rooms after sync."
;; TAB in Evil insert: with yasnippet-capf first in CAPF list,
;; corfu shows snippets as expandable items — no manual TAB override needed.
;; Standard indent-for-tab-command handles org-cycle / indent fallback.
;; Evil + yasnippet: when entering a field, select default text so typing replaces it.
;; Without this, default text is not visually selected in Evil insert state.
(add-hook 'yas-before-expand-snippet-hook
(lambda () (when (evil-normal-state-p) (evil-insert-state))))
;; Delete field content with a single key: C-d clears current field content
(add-hook 'yas-keymap-disable-hook
(lambda () (not (yas--snippets-at-point))))
(define-key yas-keymap (kbd "C-d")
(lambda ()
(interactive)
(delete-region (yas-field-start (yas-current-field))
(yas-field-end (yas-current-field)))))
)
;;; ============================================================