Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fix bug where quotes inside regexp will ruin everything.

It's much cleaner if we modify the syntax table to treat regexps as strings.

Fixes #111
  • Loading branch information...
commit be60c135a20cef0e8c6abd546354be2b3ac76b14 1 parent 6d44fa5
@jart jart authored
Showing with 4 additions and 6 deletions.
  1. +4 −6 coffee-mode.el
10 coffee-mode.el
@@ -404,10 +404,6 @@ called `coffee-compiled-buffer-name'."
;; Booleans
(defvar coffee-boolean-regexp "\\b\\(true\\|false\\|yes\\|no\\|on\\|off\\|null\\|undefined\\)\\b")
-;; Regular Expressions
-(defvar coffee-regexp-regexp "\\/\\(\\\\.\\|\\[\\(\\\\.\\|.\\)+?\\]\\|[^/
;; String Interpolation(This regexp is taken from ruby-mode)
(defvar coffee-string-interpolation-regexp "#{[^}\n\\\\]*\\(?:\\\\.[^}\n\\\\]*\\)*}")
@@ -453,9 +449,8 @@ called `coffee-compiled-buffer-name'."
(,coffee-prototype-regexp . font-lock-variable-name-face)
(,coffee-assign-regexp . font-lock-type-face)
(,coffee-local-assign-regexp 1 font-lock-variable-name-face)
- (,coffee-regexp-regexp . font-lock-constant-face)
(,coffee-boolean-regexp . font-lock-constant-face)
- (,coffee-lambda-regexp . (2 font-lock-function-name-face))
+ (,coffee-lambda-regexp 2 font-lock-function-name-face)
(,coffee-keywords-regexp 1 font-lock-keyword-face))
(,coffee-string-interpolation-regexp 0 font-lock-variable-name-face t))
@@ -886,6 +881,9 @@ END lie."
(modify-syntax-entry ?# "< b" coffee-mode-syntax-table)
(modify-syntax-entry ?\n "> b" coffee-mode-syntax-table)
+ ;; Treat regular expressions as strings.
+ (modify-syntax-entry ?/ "|" coffee-mode-syntax-table)

Appreciate the work on fixing regexp highlighting, but this seems to make everything after division (lone /) be highlighted as a string.

I glanced at perl-mode to see how they distinguish between division and regexp. They rely on some constructs that are particular to perl (natch) so probably not helpful here. Wish I had someething more helpful to contribute.

@jart Collaborator
jart added a note

How silly of me. I've pushed a quick fix to disable this entirely until I can figure out how to do it properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
(set (make-local-variable 'comment-start) "#")
;; single quote strings
Please sign in to comment.
Something went wrong with that request. Please try again.