From e7e05e24527e5ba7ccad7fbd4f8e9404218f7b87 Mon Sep 17 00:00:00 2001 From: Daniel Luna Date: Tue, 20 Mar 2018 22:27:57 -0300 Subject: [PATCH] Surrounding behavior with active region This commit ensures that the expanded snippet follows the default behavior of yasnippet-insert-snippet, surrounding the active region. --- helm-c-yasnippet.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/helm-c-yasnippet.el b/helm-c-yasnippet.el index a61a348..6b46bd2 100644 --- a/helm-c-yasnippet.el +++ b/helm-c-yasnippet.el @@ -303,7 +303,11 @@ space match anyword greedy" (candidate-transformer . (lambda (candidates) (helm-yas-get-transformed-list helm-yas-cur-snippets-alist helm-yas-initial-input))) (action . (("Insert snippet" . (lambda (template) - (yas-expand-snippet template helm-yas-point-start helm-yas-point-end) + (let ((start helm-yas-point-start) + (end helm-yas-point-end)) + (when mark-active + (setq start (region-beginning) end (region-end))) ; works as a surrounding snippet if mark is active + (yas-expand-snippet template start end)) (when helm-yas-display-msg-after-complete (message "this snippet is bound to [ %s ]" (helm-yas-get-key-by-template template helm-yas-cur-snippets-alist)))))