aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJackson Ray Hamilton2019-09-22 11:57:57 -0700
committerJackson Ray Hamilton2019-09-22 12:03:03 -0700
commitee89c1cdb5a3bb7b69b763a59a20b34508ddf3ae (patch)
tree1c05bfdb8d00861bb66bff1526b304e12eacccc5
parent2f600e97e7ca43965f55f019759582d93d8bca73 (diff)
downloademacs-ee89c1cdb5a3bb7b69b763a59a20b34508ddf3ae.tar.gz
emacs-ee89c1cdb5a3bb7b69b763a59a20b34508ddf3ae.zip
Make js-jsx-regexps case-sensitive
The regexp in this list used a capitalized “React” because it actually should be capitalized like that. Otherwise, the following code would produce a false positive match: import Thing from './react/Thing' * lisp/progmodes/js.el (js-jsx-regexps): Update docstring. (js-jsx--detect-and-enable): Match case-sensitively when determining whether JSX should be enabled.
-rw-r--r--lisp/progmodes/js.el6
1 files changed, 4 insertions, 2 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 161fd5c00b0..65a2538c30a 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -4484,7 +4484,7 @@ their `mode-name' updates to show enabled syntax extensions."
4484 4484
4485(defvar js-jsx-regexps 4485(defvar js-jsx-regexps
4486 (list "\\_<\\(?:var\\|let\\|const\\|import\\)\\_>.*?React") 4486 (list "\\_<\\(?:var\\|let\\|const\\|import\\)\\_>.*?React")
4487 "Regexps for detecting JSX in JavaScript buffers. 4487 "Case-sensitive regexps for detecting JSX in JavaScript buffers.
4488When `js-jsx-detect-syntax' is non-nil and any of these regexps 4488When `js-jsx-detect-syntax' is non-nil and any of these regexps
4489match text near the beginning of a JavaScript buffer, 4489match text near the beginning of a JavaScript buffer,
4490`js-jsx-syntax' (which see) will be made buffer-local and set to 4490`js-jsx-syntax' (which see) will be made buffer-local and set to
@@ -4504,7 +4504,9 @@ is non-nil. Return t after enabling, nil otherwise."
4504 (catch 'match 4504 (catch 'match
4505 (mapc 4505 (mapc
4506 (lambda (regexp) 4506 (lambda (regexp)
4507 (if (re-search-forward regexp 4000 t) (throw 'match t))) 4507 (when (let (case-fold-search)
4508 (re-search-forward regexp 4000 t))
4509 (throw 'match t)))
4508 js-jsx-regexps) 4510 js-jsx-regexps)
4509 nil)))) 4511 nil))))
4510 (js-jsx-enable) 4512 (js-jsx-enable)