[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ccc9adc 16/36: Add register option for yas-wrap-around-reg
From: |
Noam Postavsky |
Subject: |
[elpa] master ccc9adc 16/36: Add register option for yas-wrap-around-region |
Date: |
Sat, 11 Jun 2016 19:21:10 +0000 (UTC) |
branch: master
commit ccc9adc3c41097dc848911141d76a6bc5bd1a7fc
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Add register option for yas-wrap-around-region
Replace `cua' setting with more general behaviour that can use any given
register. A `cua' setting is converted to ?0 for backwards
compatibility.
* yasnippet.el (yas--simple-mirror-parse-create): Use contents of any
register depending on `yas-wrap-around-region' value.
(yas-wrap-around-region): Update docstring.
---
yasnippet.el | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/yasnippet.el b/yasnippet.el
index 366c616..47618f9 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -346,11 +346,14 @@ Any other non-nil value, every submenu is listed."
:group 'yasnippet)
(defcustom yas-wrap-around-region nil
- "If non-nil, snippet expansion wraps around selected region.
-
-The wrapping occurs just before the snippet's exit marker. This
-can be overridden on a per-snippet basis."
- :type 'boolean
+ "What to insert for snippet's $0 field.
+
+If set to a character, insert contents of corresponding register.
+If non-nil insert region contents."
+ :type '(choice (character :tag "Insert from register")
+ (const t :tag "Insert region contents")
+ (const nil :tag "Don't insert anything")
+ (const cua)) ; backwards compat
:group 'yasnippet)
(defcustom yas-good-grace t
@@ -4127,14 +4130,14 @@ When multiple expressions are found, only the last one
counts."
(yas--make-exit (yas--make-marker (match-end 0))))
(save-excursion
(goto-char (match-beginning 0))
- (when yas-wrap-around-region
- (cond (yas-selected-text
- (insert yas-selected-text))
- ((and (eq yas-wrap-around-region 'cua)
- cua-mode
- (get-register ?0))
- (insert (prog1 (get-register ?0)
- (set-register ?0 nil))))))
+ (when (eq yas-wrap-around-region 'cua)
+ (setq yas-wrap-around-region ?0))
+ (cond ((and yas-wrap-around-region yas-selected-text)
+ (insert yas-selected-text))
+ ((and (characterp yas-wrap-around-region)
+ (get-register yas-wrap-around-region))
+ (insert (prog1 (get-register yas-wrap-around-region)
+ (set-register yas-wrap-around-region nil)))))
(push (cons (point) (yas--exit-marker (yas--snippet-exit
snippet)))
yas--dollar-regions)))
(t
- [elpa] master 497867c 32/36: Rename yas-backport-obsolete-alias, (continued)
- [elpa] master 497867c 32/36: Rename yas-backport-obsolete-alias, Noam Postavsky, 2016/06/11
- [elpa] master e23a053 34/36: Avoid bug in insert-file-contents with REPLACE=t, Noam Postavsky, 2016/06/11
- [elpa] master 567ada0 06/36: Decide field clearing based on command's effect, Noam Postavsky, 2016/06/11
- [elpa] master bdfab67 24/36: Make yasnippet less chatty, Noam Postavsky, 2016/06/11
- [elpa] master bbfa1f0 31/36: Add yas-backport-obsolete-alias option, Noam Postavsky, 2016/06/11
- [elpa] master bfe14f1 10/36: Test and fix problem with mirror+autofill, Noam Postavsky, 2016/06/11
- [elpa] master df229b9 23/36: Fix some doc formatting, Noam Postavsky, 2016/06/11
- [elpa] master 1b8f5b7 29/36: Don't use major-mode syntax-propertize-function, Noam Postavsky, 2016/06/11
- [elpa] master 47dbe93 33/36: Fix broken links in README.mdown, Noam Postavsky, 2016/06/11
- [elpa] master dc3e4ca 35/36: Release 0.10.0, Noam Postavsky, 2016/06/11
- [elpa] master ccc9adc 16/36: Add register option for yas-wrap-around-region,
Noam Postavsky <=
- [elpa] master eca2f99 15/36: Indent multi-line output from mirrors, Noam Postavsky, 2016/06/11
- [elpa] master 438f5db 36/36: packages/yasnippet: pull from external (0.10.0), Noam Postavsky, 2016/06/11