* bug#13942: 24.3.50; `smie-auto-fill' loops
@ 2013-03-13 4:29 Dirk Ullrich
2013-03-14 3:05 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Dirk Ullrich @ 2013-03-13 4:29 UTC (permalink / raw)
To: 13942
[-- Attachment #1: Type: text/plain, Size: 4291 bytes --]
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)
[-- Attachment #2: PG_Autofill.v --]
[-- Type: application/octet-stream, Size: 87 bytes --]
(* We start to load some modules for Coq's standard library whose stuff we use here. *)
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#13942: 24.3.50; `smie-auto-fill' loops
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
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2013-03-14 3:05 UTC (permalink / raw)
To: Dirk Ullrich; +Cc: 13942
> 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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#13942: 24.3.50; `smie-auto-fill' loops
2013-03-14 3:05 ` Stefan Monnier
@ 2013-03-14 6:31 ` Dirk Ullrich
2013-03-14 16:10 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Dirk Ullrich @ 2013-03-14 6:31 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 13942
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)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#13942: 24.3.50; `smie-auto-fill' loops
2013-03-14 6:31 ` Dirk Ullrich
@ 2013-03-14 16:10 ` Stefan Monnier
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-03-14 16:10 UTC (permalink / raw)
To: Dirk Ullrich; +Cc: 13942-done
> I've just tested your patch. It works for me, too.
Thank you, installed in emacs-24.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-14 16:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2013-03-14 16:10 ` Stefan Monnier
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.