]> git.eshelyaron.com Git - emacs.git/commitdiff
(conf-toml-recognize-section): Fix bug#70383
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 17 Apr 2024 18:30:10 +0000 (14:30 -0400)
committerEshel Yaron <me@eshelyaron.com>
Sat, 20 Apr 2024 11:04:07 +0000 (14:04 +0300)
* lisp/textmodes/conf-mode.el (conf-toml-recognize-section): Move
point, like font-lock matchers are expected to do.

(cherry picked from commit c15c9f4de62b5bf06d6ccdb5bbada4f542108a38)

lisp/textmodes/conf-mode.el

index 5e1636033f69be981c99dd9dd7281da407138d54..e74409128df49a427229ed1016145d3ae7bdbfbc 100644 (file)
@@ -613,27 +613,26 @@ For details see `conf-mode'.  Example:
   "Font-lock helper function for `conf-toml-mode'.
 Handles recognizing TOML section names, like [section],
 \[[section]], or [something.\"else\".section]."
-  (save-excursion
-    ;; 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)))))))
+  ;; 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))))))
 
 ;;;###autoload
 (define-derived-mode conf-toml-mode conf-mode "Conf[TOML]"