[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 78af78e 4/4: * packages/yasnippet: Merge version 0.12.2 fr
From: |
Noam Postavsky |
Subject: |
[elpa] master 78af78e 4/4: * packages/yasnippet: Merge version 0.12.2 from upstream. |
Date: |
Mon, 28 Aug 2017 22:21:48 -0400 (EDT) |
branch: master
commit 78af78e3b84f78205c000692076540b7a2c10937
Merge: 29ab310 89eb7ab
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
* packages/yasnippet: Merge version 0.12.2 from upstream.
---
packages/yasnippet/NEWS | 10 +++++++++-
packages/yasnippet/yasnippet-tests.el | 17 +++++++++++++++++
packages/yasnippet/yasnippet.el | 23 +++++++++++++++++------
3 files changed, 43 insertions(+), 7 deletions(-)
diff --git a/packages/yasnippet/NEWS b/packages/yasnippet/NEWS
index bc0863f..57d9259 100644
--- a/packages/yasnippet/NEWS
+++ b/packages/yasnippet/NEWS
@@ -1,9 +1,17 @@
Yasnippet NEWS -- history of user-visible changes.
-Copyright (C) 2016 Free Software Foundation, Inc.
+Copyright (C) 2017 Free Software Foundation, Inc.
See the end of the file for license conditions.
+* 0.12.2 (Aug 28, 2017)
+** The new option 'yas-also-auto-indent-empty-lines' allows restoring
+the old indent behavior. See Github #850, #710, #685, #679.
+
+** Keybinding triggered snippets once again deactivate the mark.
+See Github #840.
+
+
* 0.12.1 (Jul 23, 2017)
This is a quick bugfix release.
diff --git a/packages/yasnippet/yasnippet-tests.el
b/packages/yasnippet/yasnippet-tests.el
index 748ba97..fc66de3 100644
--- a/packages/yasnippet/yasnippet-tests.el
+++ b/packages/yasnippet/yasnippet-tests.el
@@ -384,6 +384,23 @@ end" (buffer-string)))
end" (buffer-string)))
(should (= 4 (current-column)))))
+(ert-deftest yas-also-indent-empty-lines ()
+ "Respect `yas-also-indent-empty-lines' setting."
+ (with-temp-buffer
+ (ruby-mode)
+ (yas-minor-mode 1)
+ (set (make-local-variable 'yas-indent-line) 'auto)
+ (set (make-local-variable 'yas-also-auto-indent-first-line) t)
+ (set (make-local-variable 'yas-also-indent-empty-lines) t)
+ (yas-expand-snippet "def foo\n\nend")
+ (should (string= "def foo\n \nend" (buffer-string)))
+ ;; Test that it keeps working without setting
+ ;; `yas-also-auto-indent-first-line'.
+ (setq yas-also-auto-indent-first-line nil)
+ (erase-buffer)
+ (yas-expand-snippet "def foo\n\nend")
+ (should (string= "def foo\n \nend" (buffer-string)))))
+
(ert-deftest indentation-markers ()
"Test a snippet with indentation markers (`$<')."
(with-temp-buffer
diff --git a/packages/yasnippet/yasnippet.el b/packages/yasnippet/yasnippet.el
index 94ccffb..6660f57 100644
--- a/packages/yasnippet/yasnippet.el
+++ b/packages/yasnippet/yasnippet.el
@@ -5,7 +5,7 @@
;; João Távora <address@hidden>,
;; Noam Postavsky <address@hidden>
;; Maintainer: Noam Postavsky <address@hidden>
-;; Version: 0.12.1
+;; Version: 0.12.2
;; X-URL: http://github.com/joaotavora/yasnippet
;; Keywords: convenience, emulation
;; URL: http://github.com/joaotavora/yasnippet
@@ -261,7 +261,11 @@ applies)."
(defcustom yas-also-auto-indent-first-line nil
"Non-nil means also auto indent first line according to mode.
-Naturally this is only valid when `yas-indent-line' is `auto'"
+Naturally this is only valid when `yas-indent-line' is `auto'."
+ :type 'boolean)
+
+(defcustom yas-also-indent-empty-lines nil
+ "Non-nil means also indent empty lines according to mode."
:type 'boolean)
(defcustom yas-snippet-revival t
@@ -536,7 +540,7 @@ override bindings from other packages (e.g.,
`company-mode')."
;;; Internal variables
-(defconst yas--version "0.12.1")
+(defconst yas--version "0.12.2")
(defvar yas--menu-table (make-hash-table)
"A hash table of MAJOR-MODE symbols to menu keymaps.")
@@ -3839,9 +3843,14 @@ considered when expanding the snippet."
(when first-field
(sit-for 0) ;; fix issue 125
(yas--letenv (yas--snippet-expand-env snippet)
- (yas--move-to-field snippet first-field))))
+ (yas--move-to-field snippet first-field))
+ (when (and (eq (yas--field-number first-field) 0)
+ (> (length (yas--field-text-for-display
+ first-field))
+ 0))
+ ;; Keep region for ${0:exit text}.
+ (setq deactivate-mark nil))))
(yas--message 4 "snippet %d expanded." (yas--snippet-id snippet))
- (setq deactivate-mark nil)
t))))
(defun yas--take-care-of-redo (_beg _end snippet)
@@ -4222,7 +4231,9 @@ The SNIPPET's markers are preserved."
(goto-char from)
(cl-loop for bol = (line-beginning-position)
for eol = (line-end-position)
- if (/= bol eol) do
+ if (or yas-also-indent-empty-lines
+ (/= bol eol))
+ do
;; Indent each non-empty line.
(let ((remarkers nil))
(dolist (m snippet-markers)