unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#3688: Also need (auto-fill-mode nil) to trigger this bug
@ 2009-06-26 11:56 Kees Bakker
  2009-06-26 15:26 ` Alan Mackenzie
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kees Bakker @ 2009-06-26 11:56 UTC (permalink / raw)
  To: 3688

Hi,

In my report I forgot to run emacs with -Q, but the problem is still
present with -Q. But here is extra information to reproduce the error.

After entering the suggested C text (and emacs is in a basic C mode)
you have to evaluate the following before the error can be reproduced.
   (auto-fill-mode nil)

In the status bar it shows "*C/l Abbrev Fill)". In the buffer you'll
have the following.

   /*type a space here=>
   /* 3 tabs following after this=>			*/

(Notice that there are 3 TABs before the closing C comment.)
If you type a space on the first comment line, you'll see that it jumps
back 21 positions.

If you evaluate this again, the problem goes away.
   (auto-fill-mode nil)
Now, the "Fill" flag is gone from the status bar.

Kind regards,
Kees Bakker





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#3688: Also need (auto-fill-mode nil) to trigger this bug
  2009-06-26 11:56 bug#3688: Also need (auto-fill-mode nil) to trigger this bug Kees Bakker
@ 2009-06-26 15:26 ` Alan Mackenzie
  2009-06-26 21:14 ` Alan Mackenzie
       [not found] ` <20090626211431.GE4685@muc.de>
  2 siblings, 0 replies; 4+ messages in thread
From: Alan Mackenzie @ 2009-06-26 15:26 UTC (permalink / raw)
  To: Kees Bakker, 3688; +Cc: emacs-pretest-bug

Hi, Kees,

On Fri, Jun 26, 2009 at 01:56:48PM +0200, Kees Bakker wrote:
> Hi,

> In my report I forgot to run emacs with -Q, but the problem is still
> present with -Q. But here is extra information to reproduce the error.

> After entering the suggested C text (and emacs is in a basic C mode)
> you have to evaluate the following before the error can be reproduced.
>    (auto-fill-mode nil)

> In the status bar it shows "*C/l Abbrev Fill)". In the buffer you'll
> have the following.

>    /*type a space here=>
>    /* 3 tabs following after this=>			*/

> (Notice that there are 3 TABs before the closing C comment.) If you
> type a space on the first comment line, you'll see that it jumps back
> 21 positions.

OK, I've got it now.  As a matter of interest, M-x auto-fill-mode is
equivalent to your expression.

It also happens in Emacs 22, and it also happens on the console, not just
on a GUI system.  So it looks like a CC mode bug.

Give me a few days to track this down.

> If you evaluate this again, the problem goes away.
>    (auto-fill-mode nil)
> Now, the "Fill" flag is gone from the status bar.

Again, thanks for reporting this bug.

> Kind regards,
> Kees Bakker

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#3688: Also need (auto-fill-mode nil) to trigger this bug
  2009-06-26 11:56 bug#3688: Also need (auto-fill-mode nil) to trigger this bug Kees Bakker
  2009-06-26 15:26 ` Alan Mackenzie
@ 2009-06-26 21:14 ` Alan Mackenzie
       [not found] ` <20090626211431.GE4685@muc.de>
  2 siblings, 0 replies; 4+ messages in thread
From: Alan Mackenzie @ 2009-06-26 21:14 UTC (permalink / raw)
  To: Kees Bakker, 3688; +Cc: Chong Yidong, emacs-devel

Hi, Kees!

On Fri, Jun 26, 2009 at 01:56:48PM +0200, Kees Bakker wrote:
> Hi,

> In my report I forgot to run emacs with -Q, but the problem is still
> present with -Q. But here is extra information to reproduce the error.

> After entering the suggested C text (and emacs is in a basic C mode)
> you have to evaluate the following before the error can be reproduced.
>    (auto-fill-mode nil)

> In the status bar it shows "*C/l Abbrev Fill)". In the buffer you'll
> have the following.

>    /*type a space here=>
>    /* 3 tabs following after this=>			*/

> (Notice that there are 3 TABs before the closing C comment.) If you
> type a space on the first comment line, you'll see that it jumps back
> 21 positions.  (The 21 appears to be equal to NumOfTabs * (8-1)).

Yes, that's exactly where the 21 comes from.  :-)

> If you evaluate this again, the problem goes away.
>    (auto-fill-mode nil)
> Now, the "Fill" flag is gone from the status bar.

The mechanism for the bug is thus: when doing filling, c-mask-paragraph
temporarily replaces the whitespace before "*/" with a string of "x"s, so
that Emacs's low level filling routine can't put "*/" on a line of its
own.  At the end of the routine, the calculation to restore point does a
spurious correction to correct for an imagined difference between the
size of the WS (24 columns) and the number of bytes (3 tab characters).

Removing this "uncorrection" fixes things.  Please test out the patch
below.

Yidong and Stefan: would it be OK to install this patch for Emacs 23?
The original coding error was my own, made on 2005-08-18 in version 5.314
of cc-cmds.el at SourceForge
(http://cc-mode.cvs.sourceforge.net/viewvc/cc-mode/cc-mode/cc-cmds.el).



2009-06-26  Alan Mackenzie  <acm@muc.de>

	* progmodes/cc-cmds.el (c-mask-paragraph): Remove a spurious
	correction between the visible width of TABs and their number of
	bytes.

Index: cc-cmds.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-cmds.el,v
retrieving revision 1.82
diff -c -r1.82 cc-cmds.el
*** cc-cmds.el	13 Feb 2009 14:54:27 -0000	1.82
--- cc-cmds.el	26 Jun 2009 20:54:39 -0000
***************
*** 4202,4209 ****
  	  (forward-char (- hang-ender-stuck))
  	  (if (or fill-paragraph (not auto-fill-spaces))
  	      (insert-char ?\  hang-ender-stuck t)
! 	    (insert auto-fill-spaces)
! 	    (setq here (- here (- hang-ender-stuck (length auto-fill-spaces)))))
  	  (delete-char hang-ender-stuck)
  	  (goto-char here))
  	(set-marker tmp-post nil))
--- 4202,4208 ----
  	  (forward-char (- hang-ender-stuck))
  	  (if (or fill-paragraph (not auto-fill-spaces))
  	      (insert-char ?\  hang-ender-stuck t)
! 	    (insert auto-fill-spaces))
  	  (delete-char hang-ender-stuck)
  	  (goto-char here))
  	(set-marker tmp-post nil))

> Kind regards,
> Kees Bakker

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#3688: Also need (auto-fill-mode nil) to trigger this bug
       [not found] ` <20090626211431.GE4685@muc.de>
@ 2009-06-29  8:01   ` Kees Bakker
  0 siblings, 0 replies; 4+ messages in thread
From: Kees Bakker @ 2009-06-29  8:01 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Chong Yidong, 3688, emacs-devel

On Friday 26 June 2009, Alan Mackenzie wrote:
> Hi, Kees!

Hi Alan,

> 
> The mechanism for the bug is thus: when doing filling, c-mask-paragraph
> temporarily replaces the whitespace before "*/" with a string of "x"s, so
> that Emacs's low level filling routine can't put "*/" on a line of its
> own.  At the end of the routine, the calculation to restore point does a
> spurious correction to correct for an imagined difference between the
> size of the WS (24 columns) and the number of bytes (3 tab characters).
> 
> Removing this "uncorrection" fixes things.  Please test out the patch
> below.

Yes, the patch fixes it. Thanks for looking into this, and having it solved
so quickly.

BTW. I never intended to enable auto-fill. But strangly enough the following
will _toggle_ auto-fill-mode. (I know, this function is "Toggle Auto Fill mode".
Besides a clear description to turn it on, it should also have a clear
description to turn it off.)

  (auto-fill-mode nil)
-- 
Kees





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-06-29  8:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-26 11:56 bug#3688: Also need (auto-fill-mode nil) to trigger this bug Kees Bakker
2009-06-26 15:26 ` Alan Mackenzie
2009-06-26 21:14 ` Alan Mackenzie
     [not found] ` <20090626211431.GE4685@muc.de>
2009-06-29  8:01   ` Kees Bakker

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).