matlab-scan.el:

(matlab-re-search-keyword-forward): If bad list found, jump to end of buffer.

matlab-syntax.el:
(matlab--scan-line-for-unterminated-string)
(matlab--scan-line-comment-disable-strings): Minor optimization
computing where to drop character category.
(matlab-end-of-outer-list): Error if going to end of list
leaves pt before starting location.
This commit is contained in:
Eric Ludlam 2021-03-22 08:29:15 -04:00
parent daa3569bc7
commit d7e158f2cc
2 changed files with 14 additions and 8 deletions

View file

@ -1098,8 +1098,10 @@ Limit search to within BOUNDS. If keyword not found, return nil."
(condition-case nil
;; Protect against unterminated lists.
(matlab-end-of-outer-list)
;; if no longer in a list, say we're done
(error (setq err t)))
;; if no longer in a list, say we're done, move to end
;; of the buffer.
(error (goto-char (point-max))
(setq err t)))
(setq ans nil))
((matlab-syntax-keyword-as-variable-p)
(setq ans nil))

View file

@ -252,8 +252,7 @@ and `matlab--scan-line-for-unterminated-string' for specific details."
;; If we just finished and we have a double of ourselves,
;; convert those doubles into punctuation.
(when (looking-at start-str)
(forward-char -1)
(matlab--put-char-category (point) 'matlab--quoted-string-syntax)
(matlab--put-char-category (1- (point)) 'matlab--quoted-string-syntax)
;; and try again.
(goto-char start-char)
))
@ -275,9 +274,8 @@ Called when comments found in `matlab--scan-line-for-unterminated-string'."
(save-excursion
(while (re-search-forward "\\s\"" nil t)
(save-excursion
(forward-char -1)
(matlab--put-char-category (point) 'matlab--transpose-syntax))
)))
(matlab--put-char-category (1- (point)) 'matlab--transpose-syntax)
))))
(defun matlab--scan-line-bad-blockcomment ()
"Scan this line for invalid block comment starts."
@ -541,12 +539,18 @@ Returns non-nil if the cursor moved."
(defun matlab-end-of-outer-list ()
"If the cursor is in a list, move to the end of the outermost list..
Returns non-nil if the cursor moved."
(let ((pps (syntax-ppss (point))))
(let ((pps (syntax-ppss (point)))
(start (point)))
(when (nth 9 pps)
;; syntax-ppss doesn't have the end, so go to the front
;; and then skip forward.
(goto-char (car (nth 9 pps)))
(goto-char (scan-sexps (point) 1))
;; This checks for malformed buffer content
;; that can cause this to go backwards.
(when (> start (point))
(goto-char start)
(error "Malformed List"))
)))
;;; Useful checks for state around point.