From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#13942: 24.3.50; `smie-auto-fill' loops Date: Wed, 13 Mar 2013 23:05:24 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1363230358 22795 80.91.229.3 (14 Mar 2013 03:05:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Mar 2013 03:05:58 +0000 (UTC) Cc: 13942@debbugs.gnu.org To: Dirk Ullrich Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 14 04:06:23 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UFyUn-0007wr-3V for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Mar 2013 04:06:21 +0100 Original-Received: from localhost ([::1]:44231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFyUQ-0003sl-JC for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Mar 2013 23:05:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFyUM-0003sg-LW for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 23:05:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFyUL-0002Ad-Jw for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 23:05:54 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFyUL-0002AY-Fx for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 23:05:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UFyVS-00028b-1z for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 23:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Mar 2013 03:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13942 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13942-submit@debbugs.gnu.org id=B13942.13632304018188 (code B ref 13942); Thu, 14 Mar 2013 03:07:01 +0000 Original-Received: (at 13942) by debbugs.gnu.org; 14 Mar 2013 03:06:41 +0000 Original-Received: from localhost ([127.0.0.1]:52261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFyV6-000281-TS for submit@debbugs.gnu.org; Wed, 13 Mar 2013 23:06:41 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:22360) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFyV5-00027p-1Q for 13942@debbugs.gnu.org; Wed, 13 Mar 2013 23:06:39 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFHO+KL9/2dsb2JhbABEuzWDWRdzgh4BAQQBJy8WCgMFCws0EhQYDSSIHgbBLZEKA6R6gV6DEw X-IPAS-Result: Av8EABK/CFHO+KL9/2dsb2JhbABEuzWDWRdzgh4BAQQBJy8WCgMFCws0EhQYDSSIHgbBLZEKA6R6gV6DEw X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="4864857" Original-Received: from 206-248-162-253.dsl.teksavvy.com (HELO pastel.home) ([206.248.162.253]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 13 Mar 2013 23:05:22 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 17B3B678BC; Wed, 13 Mar 2013 23:05:24 -0400 (EDT) In-Reply-To: (Dirk Ullrich's message of "Wed, 13 Mar 2013 05:29:38 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:72443 Archived-At: > 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)