unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dirk Ullrich <dirk.ullrich@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 13942@debbugs.gnu.org
Subject: bug#13942: 24.3.50; `smie-auto-fill' loops
Date: Thu, 14 Mar 2013 07:31:29 +0100	[thread overview]
Message-ID: <CAFgzs6rcQJBqASBVSxPCd2BsZ8Buj7S-hFnXeoQOvQHfQzBayA@mail.gmail.com> (raw)
In-Reply-To: <jwvy5dqznr0.fsf-monnier+emacs@gnu.org>

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@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	other threads:[~2013-03-14  6:31 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
2013-03-14  6:31   ` Dirk Ullrich [this message]
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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFgzs6rcQJBqASBVSxPCd2BsZ8Buj7S-hFnXeoQOvQHfQzBayA@mail.gmail.com \
    --to=dirk.ullrich@gmail.com \
    --cc=13942@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).