matlab-scan.el:

(matlab-compute-line-context-lvl-1):
Optimize use of `syntax-ppss'.  See big comment for details on how it works.

matlab.el:
(matlab-functions-have-end-minor-mode):
Re-enable command-line-dual checking in classes.
This commit is contained in:
Eric Ludlam 2021-04-01 09:14:07 -04:00
parent 32aef8ebc1
commit b8343915f9
2 changed files with 32 additions and 4 deletions

View file

@ -194,9 +194,37 @@ and other simple states.
Computes multiple styles of line by checking for multiple types of context
in a single call using fastest methods."
(save-excursion
(back-to-indentation)
(let* ((ppsend (save-excursion (syntax-ppss (point-at-eol))))
(pps (syntax-ppss (point)))
;; About use of `syntax-ppss' - This util has a 1 element cache,
;; and can utilize the cache as it parses FORWARD only. Tools
;; like `back-to-indentation' also needs to propertize the buffer
;; since that uses syntax elements to do it's work. To make this
;; fcn faster, we call `syntax-ppss' once on BOL, and then
;; parse-partial-sexp for other locations as a way to boost the
;; speed of calls to `syntax-ppss' that come later.
;; Additional note: `back-to-indentation' used below calls
;; syntax-propertize. Command dual needs to call
;; `syntax-ppss' which it does on bol By setting `syntax-ppss'
;; internal cache on bol, in cases where propertize needs to
;; be called, the cache returns immediatly during the
;; propertize, and needs to do no extra work.
(beginning-of-line)
(let* ((ppsbol (syntax-ppss (point))) ;; Use the cache
(pps (progn (back-to-indentation)
;; Compute by hand - leaving cache alone.
(parse-partial-sexp (point-at-bol)
(point)
nil nil
;; previous state
ppsbol)))
(ppsend (save-excursion
;; Starting @ indentation, parse forward to eol
;; and see where we are.
;; Compute by hand, leaving cache alone.
(parse-partial-sexp (point) (point-at-eol)
nil nil
;; Previous state
pps)))
(ltype 'empty)
(stype nil)
(pt (point))

View file

@ -222,7 +222,7 @@ If the value is 'guess, then we guess if a file has end when
;;(setq matlab-syntax-support-command-dual t)
)
((eq matlab-functions-have-end 'class)
(setq matlab-syntax-support-command-dual nil)
;;(setq matlab-syntax-support-command-dual nil)
)
(matlab-functions-have-end
;;(setq matlab-syntax-support-command-dual t)