Function: js-jsx--detect-and-enable
js-jsx--detect-and-enable is a byte-compiled function defined in
js.el.gz.
Signature
(js-jsx--detect-and-enable &optional BEG END)
Documentation
Detect if JSX is likely to be used, and enable it if so.
Might make js-jsx-syntax buffer-local and set it to t. Matches
between BEG..END (defaults to the first 4KB of the buffer).
Return non-nil after enabling, nil otherwise.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js-jsx--detect-and-enable (&optional beg end)
"Detect if JSX is likely to be used, and enable it if so.
Might make `js-jsx-syntax' buffer-local and set it to t. Matches
between BEG..END (defaults to the first 4KB of the buffer).
Return non-nil after enabling, nil otherwise."
(when (or (and (buffer-file-name)
(string-match-p "\\.jsx\\'" (buffer-file-name)))
(and js-jsx-detect-syntax
(save-excursion
(unless (integerp beg)
(setq beg (point-min) end (min (+ beg 4000) (point-max))))
(goto-char beg)
(catch 'match
(mapc
(lambda (regexp)
(when (let (case-fold-search)
(re-search-forward regexp end t))
(throw 'match t)))
js-jsx-regexps)
nil))))
(js-jsx-enable)
t))