[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)
- [nongnu] elpa/scala-mode c154f16 139/217: better join-line and fixup-whitespace, (continued)
- [nongnu] elpa/scala-mode c154f16 139/217: better join-line and fixup-whitespace, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode e277378 143/217: WIP on end-of-defun and beggining of defun which should make writing imenu functionality much easier., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 811494f 155/217: Support nesting of classes in imenu index creation function., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d4885ac 159/217: Use [[:space:]] instead of literal space in syntax end/beggining of, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode c5ab657 160/217: Merge pull request #82 from IvanMalison/support_imenu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode b8e835f 161/217: scala-mode:goto-start-of-code close #90, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode e8c8a51 169/217: Couple imenu-related issues (#95), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 3989897 174/217: bump version (#111), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 360b5ba 162/217: Merge pull request #92 from fommil/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 387e93c 178/217: revert 618f0fbef4d3d94156f834a66e36c79f07a54e02, fixes #118 (#119), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode c71efcc 188/217: quoteids are now propertized as symbols (#137),
ELPA Syncer <=
- [nongnu] elpa/scala-mode 1d08e88 201/217: Merge pull request #154 from pgronkievitz/patch-1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 265dadc 214/217: fix: `//`-comments filled incorrectly (`//` not acting as prefix), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode b85fa5e 213/217: Merge pull request #167 from Kazark/trailing-comma, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 6966328 216/217: Merge pull request #168 from Kazark/slash-slash, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode e23875e 054/217: Fixed number literals not highlighting after foo_123, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 3142f5c 071/217: Fixed #26, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode e79e627 072/217: Fix highlighting for operators beginning with colon., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 17c6306 070/217: Highlight "var"s differently., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode f76902a 105/217: Merge pull request #53 from jjl/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 9cfc522 110/217: fix to scala-indent:fix-line, ELPA Syncer, 2021/08/29