GNU bug report logs -
#19342
auto-fill scan-error in sh-mode
Previous Next
Reported by: Glenn Morris <rgm <at> gnu.org>
Date: Wed, 10 Dec 2014 21:52:02 UTC
Severity: normal
Tags: confirmed
Found in versions 24.4, 28.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #52 received at 19342 <at> debbugs.gnu.org (full text, mbox):
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
This bug report was last modified 3 years and 73 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.