emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master ee89c1c: Make js-jsx-regexps case-sensitive


From: Jackson Ray Hamilton
Subject: [Emacs-diffs] master ee89c1c: Make js-jsx-regexps case-sensitive
Date: Sun, 22 Sep 2019 15:06:28 -0400 (EDT)

branch: master
commit ee89c1cdb5a3bb7b69b763a59a20b34508ddf3ae
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    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.
---
 lisp/progmodes/js.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 161fd5c..65a2538 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -4484,7 +4484,7 @@ their `mode-name' updates to show enabled syntax 
extensions."
 
 (defvar js-jsx-regexps
   (list "\\_<\\(?:var\\|let\\|const\\|import\\)\\_>.*?React")
-  "Regexps for detecting JSX in JavaScript buffers.
+  "Case-sensitive regexps for detecting JSX in JavaScript buffers.
 When `js-jsx-detect-syntax' is non-nil and any of these regexps
 match text near the beginning of a JavaScript buffer,
 `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."
                    (catch 'match
                      (mapc
                       (lambda (regexp)
-                        (if (re-search-forward regexp 4000 t) (throw 'match 
t)))
+                        (when (let (case-fold-search)
+                                (re-search-forward regexp 4000 t))
+                          (throw 'match t)))
                       js-jsx-regexps)
                      nil))))
     (js-jsx-enable)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]