From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Dirk Ullrich <dirk.ullrich@gmail.com>
Cc: 13942@debbugs.gnu.org
Subject: bug#13942: 24.3.50; `smie-auto-fill' loops
Date: Wed, 13 Mar 2013 23:05:24 -0400 [thread overview]
Message-ID: <jwvy5dqznr0.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAFgzs6qM7QnT7dcmvhsBjYGPGkZH3omV6-3Vt=uYneYSG1pWVw@mail.gmail.com> (Dirk Ullrich's message of "Wed, 13 Mar 2013 05:29:38 +0100")
> 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)
next prev parent reply other threads:[~2013-03-14 3:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-13 4:29 bug#13942: 24.3.50; `smie-auto-fill' loops Dirk Ullrich
2013-03-14 3:05 ` Stefan Monnier [this message]
2013-03-14 6:31 ` Dirk Ullrich
2013-03-14 16:10 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvy5dqznr0.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=13942@debbugs.gnu.org \
--cc=dirk.ullrich@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.