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 . M-x a u - f SPC C-x C-s M-q C-x u C-x C-s C-x C-s C-x C-s M-x e m a r e p o r t 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)