[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)))))
- [elpa] master b554efb 287/433: After fontifying the region, restore local vars, (continued)
- [elpa] master b554efb 287/433: After fontifying the region, restore local vars, Dmitry Gutov, 2018/03/15
- [elpa] master 0922481 254/433: Added narrow to submode region (Joe Kelsey), Dmitry Gutov, 2018/03/15
- [elpa] master b72e44c 369/433: Released 0.5.1, Dmitry Gutov, 2018/03/15
- [elpa] master bcc5adf 351/433: Define mmm-indent-line-function and its default value, Dmitry Gutov, 2018/03/15
- [elpa] master 8ab7041 297/433: Adjust indentation in primary mode for ERB blocks, Dmitry Gutov, 2018/03/15
- [elpa] master 68b2135 282/433: Fix obsolete backquotes, Dmitry Gutov, 2018/03/15
- [elpa] master e3ef1f8 267/433: Collapsed undo of insertion into one command., Dmitry Gutov, 2018/03/15
- [elpa] master 6dcd817 337/433: * mmm-syntax-propertize-function: Use font-lock-syntactic-keywords, Dmitry Gutov, 2018/03/15
- [elpa] master ea8a1b8 342/433: Rebinding syntax-propertize-chunk-size is pointless, Dmitry Gutov, 2018/03/15
- [elpa] master 970b52a 298/433: Check for EJS "blocks", Dmitry Gutov, 2018/03/15
- [elpa] master 20e65af 372/433: Primary mode spf should see the whole buffer,
Dmitry Gutov <=
- [elpa] master 2590b31 401/433: Update the checklist, Dmitry Gutov, 2018/03/15
- [elpa] master 5f80383 364/433: Fix typo: global-mmm-mode -> mmm-global-mode, Dmitry Gutov, 2018/03/15
- [elpa] master 7422b45 341/433: * mmm-regions-in: Keep overlay references in the return value, Dmitry Gutov, 2018/03/15
- [elpa] master 6156c7a 349/433: Add URL header, Dmitry Gutov, 2018/03/15
- [elpa] master 55bba22 343/433: Merge pull request #21 from dgutov/syntax-propertize, Dmitry Gutov, 2018/03/15
- [elpa] master f6dd37f 264/433: Added instructions for installing CVS version., Dmitry Gutov, 2018/03/15
- [elpa] master ddb7b42 393/433: fix the problem that mmm-major-mode-preferences has no effect for css., Dmitry Gutov, 2018/03/15
- [elpa] master 00c10a6 429/433: And more, Dmitry Gutov, 2018/03/15
- [elpa] master 859d231 417/433: Update the copyright notices, Dmitry Gutov, 2018/03/15
- [elpa] master 52d2714 388/433: Fix #40, Dmitry Gutov, 2018/03/15