[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scala-mode 1dd5825 085/217: Added comment syntax for bash
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scala-mode 1dd5825 085/217: Added comment syntax for bash preambles (#!...!#) in scala script files |
Date: |
Sun, 29 Aug 2021 11:30:48 -0400 (EDT) |
branch: elpa/scala-mode
commit 1dd582566f1085ccfb798112083865306904cd81
Author: Andrew Jones <andrew@jones.ec>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Added comment syntax for bash preambles (#!...!#) in scala script files
If the first characters of the file are #!, the character combination
is given comment starter syntax. The comment is ended with a
corresponding !#. The rule does not apply elsewhere in a file.
Closes #42
---
README.md | 3 ++-
scala-mode-syntax.el | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 899673e..1008073 100644
--- a/README.md
+++ b/README.md
@@ -395,5 +395,6 @@ Contributors and valuable feedback:
- Ray Racine
- Eiríkr Åsheim (aka Erik Osheim)
- Seth Tisue
-- Gary Pamparà
+- Gary Pamparà
- Evan Meagher
+- Andrew Jones
diff --git a/scala-mode-syntax.el b/scala-mode-syntax.el
index d1cd41c..a4a8bb5 100644
--- a/scala-mode-syntax.el
+++ b/scala-mode-syntax.el
@@ -218,6 +218,12 @@
;;; Other regular expressions
;;;
+(defconst scala-syntax:preamble-start-re
+ "\#\!")
+
+(defconst scala-syntax:preamble-end-re
+ "\!\\(\#\\)[ \t]*$")
+
(defconst scala-syntax:empty-line-re
"^\\s *$")
@@ -473,6 +479,21 @@ characters and one-line strings will not be fontified."
(scala-syntax:put-syntax-table-property 9 '(7 . nil))))
(t (throw 'break nil)))))))))
+(defun scala-syntax:propertize-shell-preamble (start end)
+ "Mark a shell preamble pair (#!/!#) at the beginning of a script as a
comment."
+ (save-excursion
+ (let ((comment-start (nth 8 (syntax-ppss))))
+ (goto-char start)
+ (when (and (= start 1)
+ (looking-at scala-syntax:preamble-start-re))
+ (scala-syntax:put-syntax-table-property 0 '(11 . nil))
+ (setq comment-start 1))
+ (when (and (eq comment-start 1)
+ (goto-char comment-start)
+ (looking-at scala-syntax:preamble-start-re)
+ (re-search-forward scala-syntax:preamble-end-re end t))
+ (scala-syntax:put-syntax-table-property 1 '(12 . nil))))))
+
(defun scala-syntax:propertize-underscore-and-idrest (start end)
"Mark all underscores (_) as symbol constituents (syntax 3) or
upper case letter (syntax 2). Also mark opchars in idrest as
@@ -502,6 +523,7 @@ symbol constituents (syntax 3)"
(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))
- [nongnu] elpa/scala-mode d27a39b 130/217: added Tillmann Rendel to the list of commiters, (continued)
- [nongnu] elpa/scala-mode d27a39b 130/217: added Tillmann Rendel to the list of commiters, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode f5280ad 137/217: forward-token for #75, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode e6967f7 154/217: Add Ivan Malison as a contributor., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 3953269 127/217: Tweaked syntax rules to make highlighting more customizeable, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode c0842f6 157/217: Use cl functions to avoid mapcan missing error., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d1fbe2d 171/217: Implemented prettify/conceal with a base set of rules. (#108), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 2e8fd35 180/217: Fix for fill-paragraph with prefix arg. Fixes #125. (#126), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 7e63002 182/217: Add "inline" keyword from scalameta (#128), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 1357eba 183/217: Fix for #94, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 730e16d 186/217: Merge pull request #130 from ensime/fix/120, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 1dd5825 085/217: Added comment syntax for bash preambles (#!...!#) in scala script files,
ELPA Syncer <=
- [nongnu] elpa/scala-mode 16d6f36 067/217: Added a not to README about font-lock-doc-face, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode b55ca83 066/217: Merge pull request #23 from hvesalai/issue22, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode aa38dae 083/217: Fixes #38: 100% CPU usage for multi-line strings in some cases., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 0af3b07 069/217: Added Makefile and fixed compilation warnings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode be89855 084/217: Multi-line comment indentation and asterisk-insertion on mid-line return., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 711091a 087/217: moved provides to end of files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 6312b36 082/217: Make the code agreeable to Emacs-Lisp mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 18a52f0 094/217: Update installation instructions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode a1ea0b7 097/217: Proper instructions and autoload settings for package-based install, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 763c93c 107/217: scala-indent:join-line, ELPA Syncer, 2021/08/29