Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify/fix regexes for font locking etc #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions talonscript-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@

(defconst talonscript-font-lock-definitions
(list
;; Matches speech commands at the start of a line, but NOT actions.
;; Excludes actions by disallowing parens next to letters.
;;
;; It's difficult to stop this highlighting left-hand expressions before the
;; divider (-). It's easier to let it highlight those with the same format,
;; so we tolerate variable syntax too.
(cons "^\\(\\^?[(]?\\([]a-z-A-Z0-9[<>{} ._|)]\\|\\([^-a-zA-Z0-9_](\\)\\)*\\)[$]?[ \t]*:"
'(1 font-lock-function-name-face))
;; To find speech commands, we look for unindented lines, and match the part
;; before the first colon. However, we exclude action/settings/tag blocks by
;; disallowing parens next to alphanumerics. It's difficult to stop this from
;; also highlighting left-hand expressions before the divider (-), so we
;; don't bother.
(cons
(rx line-start
(group (or (not blank) "^(")
(*? (or (not (in "(\n"))
(seq (not (any alnum "-_.\n")) "("))))
":")
'(1 font-lock-function-name-face))

;; Matches the start & end anchors (^ and $)
;;
Expand All @@ -54,7 +58,7 @@

;; Matches keys that are function calls, e.g will match "action" in:
;; action(edit.zoom_in): key(ctrl-+)
(cons "^\\([a-zA-Z0-9_-.]*\\)(" '(1 font-lock-type-face t))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a mistake in the original? If not, I don't understand what it is supposed to do.

(cons "^\\([-a-zA-Z0-9_.]*\\)(" '(1 font-lock-type-face t))

;; Matches function references
;; (cons "\\(\\([-a-zA-Z0-9_](\\)\\|:\\)[ \t]*\\([-a-zA-Z0-9_.]+\\)"
Expand Down Expand Up @@ -93,7 +97,7 @@ recognition."
(modify-syntax-entry ?# "<" talonscript-mode-syntax-table)
(modify-syntax-entry ?\n ">" talonscript-mode-syntax-table)
(setq-local comment-start "# ")
(setq-local comment-start-skip "#+[\t ]*")
(setq-local comment-start-skip "#+[[:blank:]]*")
;; TODO: Convenient indentation
;; (setq-local indent-line-function 'talonscript-toggle-indent)
)
Expand Down