GNU bug report logs - #13942
24.3.50; `smie-auto-fill' loops

Previous Next

Package: emacs;

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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13942 in the body.
You can then email your comments to 13942 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#13942; Package emacs. (Wed, 13 Mar 2013 04:32:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dirk Ullrich <dirk.ullrich <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 13 Mar 2013 04:32:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dirk Ullrich <dirk.ullrich <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; `smie-auto-fill' loops
Date: Wed, 13 Mar 2013 05:29:38 +0100
[Message part 1 (text/plain, inline)]
Prerequisits:
1. An Emacs with recent-enough `lisp/emacs-lisp/smie.el' module such
that `smie-auto-fill' is provided.
2. A ProofGeneral (PG) with its Coq mode based on `smie' (and
`load-path' properly set).
3. A Coq file with a comment longer than `fill-column'.

How to reproduce the bug:
1. Initialize PG by loading `pg-init.el'.
2. Enable auto-filling for PG's Coq mode.
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.

Remarks:
1. A debugger session shows that the looping is caused by
`smie-auto-fill'.
2. A simple Coq test file is appended to this bug report.



In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.4.2)
 of 2013-03-13 on koan
Windowing system distributor `The X.Org Foundation', version 11.0.11204000
System Description:	Debian GNU/Linux 7.0 (wheezy)

Configured using:
 `configure --prefix=/usr/local/packages/emacs-devel --sysconfdir=/etc
 --mandir=/usr/local/packages/emacs-devel/share/man
 --localstatedir=/var/local/packages/emacs-devel
 --libexecdir=/usr/local/packages/emacs-devel/lib
 --enable-locallisppath=/etc/emacs --without-sound
 --with-gameuser=packages --program-suffix=-devel --with-x-toolkit=gtk3'

Important settings:
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Coq

Minor modes in effect:
  holes-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  auto-fill-function: smie-auto-fill
  transient-mark-mode: t

Recent input:
C-x C-f P <tab> . <tab> <return> M-x a u <tab> - f
<tab> <return> <end> SPC <backspace> C-x C-s <up> M-q
C-x u <down> <return> C-x C-s <return> <C-end> <backspace>
<backspace> <backspace> C-x C-s <return> <down> <down>
<backspace> C-x C-s M-x e m a <tab> <tab> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
r e p o r t <tab> <return>

Recent messages:
Wrote /common/depot/unfinished/2do/emacs-devel/smie-auto-fill/PG_Autofill.v
Quit
Mark set
Saving file /common/depot/unfinished/2do/emacs-devel/smie-auto-fill/PG_Autofill.v...
Wrote /common/depot/unfinished/2do/emacs-devel/smie-auto-fill/PG_Autofill.v
Quit
End of buffer
Saving file /common/depot/unfinished/2do/emacs-devel/smie-auto-fill/PG_Autofill.v...
Wrote /common/depot/unfinished/2do/emacs-devel/smie-auto-fill/PG_Autofill.v
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils help-mode vc-git which-func imenu coq
coq-smie-lexer smie coq-indent coq-par-compile coq-seq-compile
coq-compile-common coq-abbrev coq-local-vars local-vars-list coq-syntax
coq-db holes proof proof-shell pg-user completion pg-goals pg-response
proof-toolbar pg-assoc proof-tree proof-script proof-menu cus-edit
cus-start cus-load wid-edit span proof-auxmodes proof-utils scomint
proof-syntax advice help-fns bufhist easy-mmode ring proof-splash
derived pg-custom proof-config proof-faces proof-useropts pg-pamacs
proof-compat easymenu proof-site proof-autoloads cl-macs gv cl nadvice
cl-lib pg-vars time-date tooltip ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind inotify dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)
[PG_Autofill.v (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13942; Package emacs. (Thu, 14 Mar 2013 03:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 13942 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dirk Ullrich <dirk.ullrich <at> gmail.com>
Cc: 13942 <at> debbugs.gnu.org
Subject: Re: bug#13942: 24.3.50; `smie-auto-fill' loops
Date: Wed, 13 Mar 2013 23:05:24 -0400
> 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)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13942; Package emacs. (Thu, 14 Mar 2013 06:33:02 GMT) Full text and rfc822 format available.

Message #11 received at 13942 <at> debbugs.gnu.org (full text, mbox):

From: Dirk Ullrich <dirk.ullrich <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13942 <at> debbugs.gnu.org
Subject: Re: 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 <monnier <at> iro.umontreal.ca>:
>> 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 sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Thu, 14 Mar 2013 16:13:02 GMT) Full text and rfc822 format available.

Notification sent to Dirk Ullrich <dirk.ullrich <at> gmail.com>:
bug acknowledged by developer. (Thu, 14 Mar 2013 16:13:03 GMT) Full text and rfc822 format available.

Message #16 received at 13942-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dirk Ullrich <dirk.ullrich <at> gmail.com>
Cc: 13942-done <at> debbugs.gnu.org
Subject: Re: bug#13942: 24.3.50; `smie-auto-fill' loops
Date: Thu, 14 Mar 2013 12:10:51 -0400
> I've just tested your patch. It works for me, too.

Thank you, installed in emacs-24.


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 12 Apr 2013 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 69 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.