From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: bug#3688: Also need (auto-fill-mode nil) to trigger this bug Date: Fri, 26 Jun 2009 21:14:31 +0000 Message-ID: <20090626211431.GE4685@muc.de> References: <200906261356.48352.kees.bakker@altium.nl> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1246050795 8258 80.91.229.12 (26 Jun 2009 21:13:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 26 Jun 2009 21:13:15 +0000 (UTC) Cc: Chong Yidong , Stefan Monnier , emacs-devel@gnu.org To: Kees Bakker , 3688@emacsbugs.donarmstrong.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 26 23:13:07 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MKIjK-0002CZ-FT for ged-emacs-devel@m.gmane.org; Fri, 26 Jun 2009 23:13:06 +0200 Original-Received: from localhost ([127.0.0.1]:34832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MKIjJ-0004GT-Mf for ged-emacs-devel@m.gmane.org; Fri, 26 Jun 2009 17:13:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MKIjF-0004G4-6k for emacs-devel@gnu.org; Fri, 26 Jun 2009 17:13:01 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MKIjA-0004CE-0j for emacs-devel@gnu.org; Fri, 26 Jun 2009 17:13:00 -0400 Original-Received: from [199.232.76.173] (port=51631 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MKIj9-0004C9-UL for emacs-devel@gnu.org; Fri, 26 Jun 2009 17:12:55 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:4584 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MKIj9-0001Yk-EO for emacs-devel@gnu.org; Fri, 26 Jun 2009 17:12:55 -0400 Original-Received: (qmail 27362 invoked by uid 3782); 26 Jun 2009 21:12:53 -0000 Original-Received: from acm.muc.de (pD9E51439.dip.t-dialin.net [217.229.20.57]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Fri, 26 Jun 2009 23:12:49 +0200 Original-Received: (qmail 21344 invoked by uid 1000); 26 Jun 2009 21:14:31 -0000 Content-Disposition: inline In-Reply-To: <200906261356.48352.kees.bakker@altium.nl> User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:111756 Archived-At: 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 * 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).