[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19342: auto-fill scan-error in sh-mode
From: |
Lars Ingebrigtsen |
Subject: |
bug#19342: auto-fill scan-error in sh-mode |
Date: |
Thu, 05 May 2022 15:39:26 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
I took a stab at fixing this with the following patch. All tests pass
after applying it, but I'm unsure how much test coverage there is in
this area...
Any comments?
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index 2bab131913..3b9f983cdb 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -1850,20 +1850,26 @@ smie-auto-fill
(save-excursion
(let ((end (point))
(bsf nil) ;Best-so-far.
- (gain 0))
+ (gain 0)
+ newcol)
(beginning-of-line)
(while (progn
(smie-indent-forward-token)
- (and (<= (point) end)
- (<= (current-column) fc)))
- ;; FIXME? `smie-indent-calculate' can (and often
- ;; does) return a result that actually depends on the
- ;; presence/absence of a newline, so the gain computed
- ;; here may not be accurate, but in practice it seems
- ;; to work well enough.
- (skip-chars-forward " \t")
- (let* ((newcol (smie-indent-calculate))
- (newgain (- (current-column) newcol)))
+ (and
+ (<= (point) end)
+ (<= (current-column) fc)
+ ;; FIXME? `smie-indent-calculate' can
+ ;; (and often does) return a result that
+ ;; actually depends on the presence/absence
+ ;; of a newline, so the gain computed here
+ ;; may not be accurate, but in practice it
+ ;; seems to work well enough.
+ (progn
+ (skip-chars-forward " \t")
+ (setq newcol
+ (ignore-error 'scan-error
+ (smie-indent-calculate))))))
+ (let ((newgain (- (current-column) newcol)))
(when (> newgain gain)
(setq gain newgain)
(setq bsf (point)))))
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- bug#19342: auto-fill scan-error in sh-mode,
Lars Ingebrigtsen <=