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 ARBITRARILY)

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 from the beginning of the buffer, unless optional arg ARBITRARILY is non-nil. Return t after enabling, nil otherwise.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js-jsx--detect-and-enable (&optional arbitrarily)
  "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
from the beginning of the buffer, unless optional arg ARBITRARILY
is non-nil.  Return t 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 arbitrarily
                     (goto-char (point-min)))
                   (catch 'match
                     (mapc
                      (lambda (regexp)
                        (when (let (case-fold-search)
                                (re-search-forward regexp 4000 t))
                          (throw 'match t)))
                      js-jsx-regexps)
                     nil))))
    (js-jsx-enable)
    t))