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

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

[elpa] master 7b783ee 308/433: Don't confuse script tags with EJS tags


From: Dmitry Gutov
Subject: [elpa] master 7b783ee 308/433: Don't confuse script tags with EJS tags
Date: Thu, 15 Mar 2018 19:44:25 -0400 (EDT)

branch: master
commit 7b783eee7af119b2eab3263afece1dcae38e7bbf
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Don't confuse script tags with EJS tags
---
 mmm-erb.el | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/mmm-erb.el b/mmm-erb.el
index d59a849..c8d846e 100644
--- a/mmm-erb.el
+++ b/mmm-erb.el
@@ -91,14 +91,16 @@
                      ("<%" . mmm-code-submode-face))
         :insert ((?% erb-code nil @ "<%" @ " " _ " " @ "%>" @)
                  (?# erb-comment nil @ "<%#" @ " " _ " " @ "%>" @)
-                 (?= erb-expression nil @ "<%=" @ " " _ " " @ "%>" @)))
+                 (?= erb-expression nil @ "<%=" @ " " _ " " @ "%>" @))
+        :creation-hook mmm-erb-mark-as-special)
    (ejs :submode js-mode :front "<%[#=]?" :back "-?%>"
         :match-face (("<%#" . mmm-comment-submode-face)
                      ("<%=" . mmm-output-submode-face)
                      ("<%" . mmm-code-submode-face))
         :insert ((?% ejs-code nil @ "<%" @ " " _ " " @ "%>" @)
                  (?# ejs-comment nil @ "<%#" @ " " _ " " @ "%>" @)
-                 (?= ejs-expression nil @ "<%=" @ " " _ " " @ "%>" @)))))
+                 (?= ejs-expression nil @ "<%=" @ " " _ " " @ "%>" @))
+        :creation-hook mmm-erb-mark-as-special)))
 
 (pushnew '(indent-line-function buffer) mmm-save-local-variables)
 
@@ -114,6 +116,10 @@
   "Hook function to run after primary or submode major mode function."
   (setq indent-line-function 'mmm-erb-indent-line))
 
+(defun mmm-erb-mark-as-special ()
+  "Hook function to run in ERB and EJS tag regions."
+  (overlay-put mmm-current-overlay 'mmm-special-tag t))
+
 (defun mmm-erb-indent-line ()
   "Indent the current line intelligently."
   (interactive)
@@ -205,11 +211,12 @@
       (let ((scan-fn (plist-get '(ruby-mode mmm-erb-scan-erb
                                   js-mode   mmm-erb-scan-ejs)
                                 submode)))
-        (when scan-fn
-          (save-excursion
-            (goto-char beg)
-            (skip-syntax-forward "-")
-            (funcall scan-fn end)))))))
+        (and scan-fn
+             (overlay-get (mmm-overlay-at beg) 'mmm-special-tag)
+             (save-excursion
+               (goto-char beg)
+               (skip-syntax-forward "-")
+               (funcall scan-fn end)))))))
 
 (defconst mmm-erb-ruby-close-re "\\<end\\>\\|}"
   "Regexp to match the end of a Ruby block.")



reply via email to

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