Fix spurious error in beginning-of-defun in pascal-mode (bug#41740)

* lisp/progmodes/pascal.el (pascal-beg-of-defun):
Ignore errors in forward-sexp.
* test/lisp/progmodes/pascal-tests.el (pascal-beg-of-defun): New test.
This commit is contained in:
Mattias Engdegård 2020-06-21 21:11:17 +02:00
parent 73daab9991
commit 6242605731
2 changed files with 9 additions and 1 deletions

View file

@ -589,7 +589,7 @@ See also `pascal-comment-area'."
(interactive)
(catch 'found
(if (not (looking-at (concat "\\s \\|\\s)\\|" pascal-defun-re)))
(forward-sexp 1))
(ignore-errors (forward-sexp 1)))
(let ((nest 0) (max -1) (func 0)
(reg (concat pascal-beg-block-re "\\|"
pascal-end-block-re "\\|"

View file

@ -52,4 +52,12 @@
(should (equal completions nil))
(should (equal point-before point-after))))))
(ert-deftest pascal-beg-of-defun ()
(with-temp-buffer
(pascal-mode)
(insert "program test; procedure p(")
(forward-char -1)
(pascal-beg-of-defun)
(should (equal (point) 15))))
(provide 'pascal-tests)