]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix beginning-of-defun not jumping to BOF
authorJens Schmidt <jschmidt4gnu@vodafonemail.de>
Tue, 26 Sep 2023 19:36:19 +0000 (21:36 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 14 Oct 2023 08:01:52 +0000 (11:01 +0300)
In batch mode or when font-lock and some other niceties are switched
off, function `syntax-ppss' can modify match data held by function
`beginning-of-defun-raw'.  In that case, `beginning-of-defun' can jump
to some seemingly arbitrary position, and not the actual BOF.

* lisp/emacs-lisp/lisp.el (beginning-of-defun-raw): Save match data
around a call to `syntax-ppss'. (Bug#66218)

lisp/emacs-lisp/lisp.el

index a4aa79c171e4d3062948e5eba46762369d449dbe..ee481dc4ed30bc85e6bfb6d1cf6d72787d1e9551 100644 (file)
@@ -422,7 +422,8 @@ of a defun, nil if it failed to find one."
                                       "\\(?:" defun-prompt-regexp "\\)\\s(")
                             "^\\s(")
                                              nil 'move arg))
-                    (nth 8 (syntax-ppss))))
+                    (save-match-data
+                      (nth 8 (syntax-ppss)))))
            found)
         (progn (goto-char (1- (match-end 0)))
                 t)))