bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13942: 24.3.50; `smie-auto-fill' loops


From: Dirk Ullrich
Subject: bug#13942: 24.3.50; `smie-auto-fill' loops
Date: Thu, 14 Mar 2013 07:31:29 +0100

Hello Stefan,

I've just tested your patch. It works for me, too.

Thank you for the quick solution!
Dirk

2013/3/14 Stefan Monnier <address@hidden>:
>> 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)
>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]