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

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

[nongnu] elpa/scala-mode c71efcc 188/217: quoteids are now propertized a


From: ELPA Syncer
Subject: [nongnu] elpa/scala-mode c71efcc 188/217: quoteids are now propertized as symbols (#137)
Date: Sun, 29 Aug 2021 11:31:09 -0400 (EDT)

branch: elpa/scala-mode
commit c71efccab36a857f3ca4a8c5d3882e8d20e639e8
Author: Josef Vlach <vlach.josef@gmail.com>
Commit: Sam Halliday <sam.halliday@gmail.com>

    quoteids are now propertized as symbols (#137)
    
    * scala-syntax:quotedid-re fix to match quoted ids
    
    * quoteids are now propertized as symbols
---
 .ert-runner             |  1 +
 Cask                    |  3 +++
 scala-mode-syntax.el    | 14 ++++++++++++--
 test/scala-mode-test.el | 33 +++++++++++++++++++++++++++++++++
 test/test-helper.el     |  1 +
 5 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/.ert-runner b/.ert-runner
new file mode 100644
index 0000000..c07ab9f
--- /dev/null
+++ b/.ert-runner
@@ -0,0 +1 @@
+-L .
\ No newline at end of file
diff --git a/Cask b/Cask
index 23b58eb..dc6ee8a 100644
--- a/Cask
+++ b/Cask
@@ -20,6 +20,9 @@
 ;;
 ;;  are particularly useful commands.
 ;;
+;; To run the tests:
+;;    cask exec ert-runner
+;;
 ;;; Code:
 
 (source melpa-stable)
diff --git a/scala-mode-syntax.el b/scala-mode-syntax.el
index fd923ca..0249d99 100644
--- a/scala-mode-syntax.el
+++ b/scala-mode-syntax.el
@@ -132,7 +132,7 @@
 ;; stringlit is referred to, but not defined Scala Language Specification 2.9
 ;; we define it as consisting of anything but '`' and newline
 (defconst scala-syntax:stringlit-re "[^`\n\r]")
-(defconst scala-syntax:quotedid-re (concat "`" scala-syntax:stringlit-re "`"))
+(defconst scala-syntax:quotedid-re (concat "`" scala-syntax:stringlit-re "+`"))
 (defconst scala-syntax:id-re (concat "\\(" scala-syntax:plainid-re
                               "\\|" scala-syntax:quotedid-re "\\)"))
 (defconst scala-syntax:id-first-char-group
@@ -600,11 +600,21 @@ symbol constituents (syntax 3)."
                  (scala-syntax:put-syntax-table-property 0 '(3 . nil)))
                '(3 . nil))))))))) ;; symbol constituent syntax (3) also for 
the '_'
 
+(defun scala-syntax:propertize-quotedid (start end)
+  "Mark all `scala-syntax:quotedid-re' as symbol constituents (syntax 3)"
+  (save-excursion
+    (goto-char start)
+    (while (re-search-forward scala-syntax:quotedid-re end t)
+      (let ((match-beg (match-beginning 0))
+            (match-end (match-end 0)))
+        (put-text-property match-beg match-end 'syntax-table '(3 . nil))))))
+
 (defun scala-syntax:propertize (start end)
   "See syntax-propertize-function"
   (scala-syntax:propertize-char-and-string-literals start end)
   (scala-syntax:propertize-shell-preamble start end)
-  (scala-syntax:propertize-underscore-and-idrest start end))
+  (scala-syntax:propertize-underscore-and-idrest start end)
+  (scala-syntax:propertize-quotedid start end))
 
 ;;;;
 ;;;; Syntax navigation functions
diff --git a/test/scala-mode-test.el b/test/scala-mode-test.el
new file mode 100644
index 0000000..0f06c14
--- /dev/null
+++ b/test/scala-mode-test.el
@@ -0,0 +1,33 @@
+(ert-deftest smt:quotedid ()
+  (let* ((line "val `tvw xyz/*` = `abc def/*` + 123 /* comment `abc` abc */ + 
456")
+         (exps 
"22203333333333301033333333333010222011022222220333330222011010222") ;; 
expected codes of syntax class
+         (expf 
"KKK-VVVVVVVVVVV-K---------------CCC-DDDOOOOOOOOOOOOOOOOOOOO---CCC") ;; 
expected font-locks
+         (line-length (length line)))
+    (with-temp-buffer
+      (insert (format "package ensime
+
+object Ensime {
+  %s
+}" line))
+     (scala-mode)
+     (font-lock-ensure)
+     (re-search-backward (regexp-opt `(,line)) nil t)
+     (let ((end-point (+ (point) line-length))
+           (acc-syntax "")
+           (acc-font ""))
+       (while (< (point) end-point)
+         (setq acc-syntax (concat acc-syntax (number-to-string (syntax-class 
(syntax-after (point))))))
+         (setq acc-font (concat acc-font (font-lock-to-string 
(get-text-property (point) 'face))))
+         (forward-char))
+       (should (equal acc-syntax exps))
+       (should (equal acc-font expf))))))
+
+(defun font-lock-to-string (font-lock)
+  (pcase font-lock
+    (`nil "-")
+    ('font-lock-constant-face "C")
+    ('font-lock-variable-name-face "V")
+    ('font-lock-keyword-face "K")
+    ('font-lock-comment-face "O")
+    ('font-lock-comment-delimiter-face "D")
+    (_ "?")))
diff --git a/test/test-helper.el b/test/test-helper.el
new file mode 100644
index 0000000..7eeb038
--- /dev/null
+++ b/test/test-helper.el
@@ -0,0 +1 @@
+(require 'scala-mode)



reply via email to

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