GNU bug report logs -
#13942
24.3.50; `smie-auto-fill' loops
Previous Next
Reported by: Dirk Ullrich <dirk.ullrich <at> gmail.com>
Date: Wed, 13 Mar 2013 04:32:02 UTC
Severity: normal
Found in version 24.3.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 13942 <at> debbugs.gnu.org (full text, mbox):
> 3. Load the Coq test file, and trigger auto-filling by placing the
> cursor just after a to-long comment line and hitting ENTER. -> Emacs
> loops.
Aha! The trick was to hit enter *after* the end of the comment!
I think the patch below fixes this problem, while still providing the
same auto-fill feature. Can you confirm it works well for you?
Stefan
=== modified file 'lisp/emacs-lisp/smie.el'
--- lisp/emacs-lisp/smie.el 2013-01-01 09:11:05 +0000
+++ lisp/emacs-lisp/smie.el 2013-03-14 00:49:52 +0000
@@ -1631,21 +1631,23 @@
(defun smie-auto-fill ()
(let ((fc (current-fill-column)))
(while (and fc (> (current-column) fc))
- (cond
- ((not (or (nth 8 (save-excursion
+ (or (unless (or (nth 8 (save-excursion
(syntax-ppss (line-beginning-position))))
- (nth 8 (syntax-ppss))))
+ (nth 8 (syntax-ppss)))
(save-excursion
- (beginning-of-line)
+ (let ((end (point))
+ (bsf (progn (beginning-of-line)
(smie-indent-forward-token)
- (let ((bsf (point))
+ (point)))
(gain 0)
curcol)
- (while (<= (setq curcol (current-column)) fc)
+ (while (and (<= (point) end)
+ (<= (setq curcol (current-column)) fc))
;; FIXME? `smie-indent-calculate' can (and often will)
- ;; 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 works well enough.
+ ;; 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 works
+ ;; well enough.
(let* ((newcol (smie-indent-calculate))
(newgain (- curcol newcol)))
(when (> newgain gain)
@@ -1654,8 +1656,9 @@
(smie-indent-forward-token))
(when (> gain 0)
(goto-char bsf)
- (newline-and-indent)))))
- (t (do-auto-fill))))))
+ (newline-and-indent)
+ 'done))))
+ (do-auto-fill)))))
(defun smie-setup (grammar rules-function &rest keywords)
This bug report was last modified 12 years and 70 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.