Function: conf-toml-recognize-section

conf-toml-recognize-section is a byte-compiled function defined in conf-mode.el.gz.

Signature

(conf-toml-recognize-section LIMIT)

Documentation

Font-lock helper function for conf-toml-mode.

Handles recognizing TOML section names, like [section],
[[section]], or [something."else".section].

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/conf-mode.el.gz
(defun conf-toml-recognize-section (limit)
  "Font-lock helper function for `conf-toml-mode'.
Handles recognizing TOML section names, like [section],
\[[section]], or [something.\"else\".section]."
  ;; Skip any number of "[" to handle things like [[section]].
  (when (re-search-forward "^\\s-*\\[+" limit t)
    (let ((start (point)))
      (backward-char)
      (let ((end (min limit
                      (condition-case nil
                          (progn
                            (forward-list)
                            (1- (point)))
                        (scan-error
                         (end-of-line)
                         (point))))))
        ;; If there is a comma in the text, then we assume this is
        ;; an array and not a section.  (This could be refined to
        ;; look only for unquoted commas if necessary.)
        (save-excursion
          (goto-char start)
          (unless (search-forward "," end t)
            (set-match-data (list start end))
            t))))))