emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master d218ed8 11/40: Do indent the first line of mirrors, but in


From: Noam Postavsky
Subject: [elpa] master d218ed8 11/40: Do indent the first line of mirrors, but in correct order
Date: Wed, 26 Oct 2016 23:06:32 +0000 (UTC)

branch: master
commit d218ed8b1bf95809edc148e609c59b124598695d
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Do indent the first line of mirrors, but in correct order
    
    This changes the strategy for fixing #712 to a simpler alternative,
    which doesn't remove the benefits of indenting single line mirrors.
    
    It reverts the functional parts of commit
    351c1e3dcbb73e3154aae0755d5b7016f1561ebc, while keeping the tests.
    
    * yasnippet.el (yas--update-mirrors): Sort mirrors to be updated by
      start position.
---
 yasnippet-tests.el |    1 +
 yasnippet.el       |   17 +++++++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 8da5f7d..219b2b3 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -255,6 +255,7 @@ mapconcat #'(lambda (arg)
     (ert-simulate-command '(yas-next-field))
     (let ((expected (mapconcat #'identity
                                '("@bla = bla"
+                                 ;; assume ruby is always indented to 2 spaces
                                  "  @ble = ble"
                                  "  @bli = bli")
                                "\n")))
diff --git a/yasnippet.el b/yasnippet.el
index 57dcdbc..bfe5590 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -4247,7 +4247,11 @@ When multiple expressions are found, only the last one 
counts."
                 (cl-mapcan #'(lambda (field)
                                (mapcar #'(lambda (mirror)
                                            (cons field mirror))
-                                       (yas--field-mirrors field)))
+                                       (cl-sort
+                                        (cl-copy-list
+                                         (yas--field-mirrors field))
+                                        #'<
+                                        :key #'yas--mirror-start)))
                            (yas--snippet-fields snippet))
                 ;; then sort this list so that entries with mirrors with parent
                 ;; fields appear before. This was important for fixing #290, 
and
@@ -4294,13 +4298,10 @@ When multiple expressions are found, only the last one 
counts."
         (yas--advance-start-maybe (yas--mirror-next mirror) (point))
         ;; super-special advance
         (yas--advance-end-of-parents-maybe mirror-parent-field (point)))
-      (let ((yas--inhibit-overlay-hooks t)
-            (beg (save-excursion (goto-char (yas--mirror-start mirror))
-                                 (forward-line 1)
-                                 (point)))
-            (end (yas--mirror-end mirror)))
-        (when (< beg end)
-          (yas--indent-region beg end snippet))))))
+      (let ((yas--inhibit-overlay-hooks t))
+        (yas--indent-region (yas--mirror-start mirror)
+                            (yas--mirror-end mirror)
+                            snippet)))))
 
 (defun yas--field-update-display (field)
   "Much like `yas--mirror-update-display', but for fields."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]