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

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

[elpa] master 20e65af 372/433: Primary mode spf should see the whole buf


From: Dmitry Gutov
Subject: [elpa] master 20e65af 372/433: Primary mode spf should see the whole buffer
Date: Thu, 15 Mar 2018 19:44:38 -0400 (EDT)

branch: master
commit 20e65af818f59f361c13d71e2a0255b4691a59fe
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Primary mode spf should see the whole buffer
    
    Or it becomes mistaken about the level of nesting.
    
    Also, don't keep cached `syntax-ppss' values between subregions, they can be
    incompatible (#26).
---
 mmm-region.el     | 11 +++++-----
 tests/html-erb.el | 62 +++++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 50 insertions(+), 23 deletions(-)

diff --git a/mmm-region.el b/mmm-region.el
index b4c9485..6ea8ec9 100644
--- a/mmm-region.el
+++ b/mmm-region.el
@@ -812,15 +812,16 @@ of the REGIONS covers START to STOP."
                   (let* ((mode (car elt))
                          (func (get mode 'mmm-syntax-propertize-function))
                          (beg (cadr elt)) (end (caddr elt))
-                         (ovl (cadddr elt)))
+                         (ovl (cadddr elt))
+                         syntax-ppss-cache
+                         syntax-ppss-last)
                     (goto-char beg)
                     (mmm-set-current-pair mode ovl)
                     (mmm-set-local-variables mode mmm-current-overlay)
                     (save-restriction
-                      (if mmm-current-overlay
-                          (narrow-to-region (overlay-start mmm-current-overlay)
-                                            (overlay-end mmm-current-overlay))
-                        (narrow-to-region beg end))
+                      (when mmm-current-overlay
+                        (narrow-to-region (overlay-start mmm-current-overlay)
+                                          (overlay-end mmm-current-overlay)))
                       (cond
                        (func
                         (funcall func beg end))
diff --git a/tests/html-erb.el b/tests/html-erb.el
index eb83ebf..6d8fab7 100644
--- a/tests/html-erb.el
+++ b/tests/html-erb.el
@@ -2,7 +2,7 @@
 (require 'ert-x)
 (require 'mmm-erb)
 
-(defvar erb-text
+(defvar mmm-erb-text
   "<%= foo do %>
      <div class=\"clear\"/>
    <% end %>")
@@ -12,20 +12,46 @@
    (overlay-start mmm-current-overlay)
    (overlay-end mmm-current-overlay)))
 
-(ert-deftest mmm-erb-parses-buffer ()
-  (ert-with-test-buffer nil
-    (let ((buffer-file-name "foo.html.erb")
-          (mmm-global-mode 'maybe)
-          mmm-mode-ext-classes-alist)
-      (mmm-add-mode-ext-class 'html-erb-mode "\\.html\\.erb\\'" 'erb)
-      (insert erb-text)
-      (html-erb-mode)
-      (mmm-mode-on-maybe)
-      (should mmm-mode)
-      (should (not mmm-current-overlay))
-      (search-backward "foo")
-      (should (mmm-update-current-submode))
-      (should (string= " foo do " (mmm-erb-current-overlay-string)))
-      (search-forward "end")
-      (should (mmm-update-current-submode))
-      (should (string= " end " (mmm-erb-current-overlay-string))))))
+(defmacro mmm-erb-deftest (name &rest body)
+  `(ert-deftest ,(intern (format "mmm-erb-%s" name)) ()
+     (ert-with-test-buffer nil
+       (let ((buffer-file-name "foo.html.erb")
+             (mmm-global-mode 'maybe)
+             mmm-parse-when-idle
+             mmm-mode-ext-classes-alist)
+         (mmm-add-mode-ext-class 'html-erb-mode "\\.html\\.erb\\'" 'erb)
+         (html-erb-mode)
+         (mmm-mode-on-maybe)
+         (should mmm-mode)
+         ,@body))))
+
+(put 'mmm-erb-deftest 'lisp-indent-function 'defun)
+
+(mmm-erb-deftest parses-buffer
+  (insert mmm-erb-text)
+  (mmm-apply-all)
+  (should (not mmm-current-overlay))
+  (search-backward "foo")
+  (should (mmm-update-current-submode))
+  (should (string= " foo do " (mmm-erb-current-overlay-string)))
+  (search-forward "end")
+  (should (mmm-update-current-submode))
+  (should (string= " end " (mmm-erb-current-overlay-string))))
+
+(mmm-erb-deftest attribute-values-are-strings
+  (insert mmm-erb-text)
+  (mmm-apply-all)
+  (goto-char (point-min))
+  (search-forward "\"")
+  (should (nth 3 (syntax-ppss)))
+  (search-forward "\"")
+  (should (not (nth 3 (syntax-ppss)))))
+
+(mmm-erb-deftest quotes-outside-tags-dont-make-strings
+  (insert "<% foo do %><p>\"foo bar\"</p><% end %>")
+  (mmm-apply-all)
+  (goto-char (point-min))
+  (search-forward "\"")
+  (should (not (nth 3 (syntax-ppss))))
+  (search-forward "\"")
+  (should (not (nth 3 (syntax-ppss)))))



reply via email to

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