From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Greg Hill Newsgroups: gmane.emacs.bugs Subject: problem with c-indent-line-or-region Date: Wed, 3 Mar 2004 19:28:24 -0800 Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1249282142==" X-Trace: sea.gmane.org 1078597591 27346 80.91.224.253 (6 Mar 2004 18:26:31 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 6 Mar 2004 18:26:31 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 06 19:26:22 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AzgVB-0007Qs-01 for ; Sat, 06 Mar 2004 19:26:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1AzgUo-0003sU-0c for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Mar 2004 13:25:58 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1AyjXr-00076O-5H for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2004 22:29:11 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1AyjXF-0006ec-JW for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2004 22:29:04 -0500 Original-Received: from [153.105.4.26] (helo=renfield.synergymicro.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.30) id 1AyjXF-0006bc-2Q for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2004 22:28:33 -0500 Original-Received: from synergy.san.synergymicro.com (synergy.san.synergymicro.com [10.1.2.12]) by renfield.synergymicro.com (8.12.10/8.12.10) with ESMTP id i243VGSQ018356 for ; Wed, 3 Mar 2004 19:31:17 -0800 Original-Received: from [10.1.6.251] ([10.1.6.251]) by synergy.san.synergymicro.com (8.12.10/8.12.10) with ESMTP id i243UWXk012192 for ; Wed, 3 Mar 2004 19:30:32 -0800 X-Sender: ghill@synergy (Unverified) Original-To: bug-gnu-emacs@gnu.org X-Virus-Scanned: clamd / ClamAV version 0.67, clamav-milter version 0.67a X-CanItPRO-Stream: default X-Spam-Score: undef - Host Whitelisted (10.1.2.12: ) X-Scanned-By: CanIt (www . canit . ca) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:7180 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:7180 --===============1249282142== Content-Type: multipart/alternative; boundary="============_-1133751589==_ma============" --============_-1133751589==_ma============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" When I set up C indentation to leave the indentation of block comments unchanged, c-indent-line-or-region is sometimes broken by the presence of parentheses within block comments. With the files junk.c and bug.el shown below in my current directory, I execute the command line shown below and get the debugger output shown at the bottom. The problem appears to depend on the behavior of the built-in function forward-comment, which is called from c-forward-comment, which is called from c-backward-syntactic-ws. If '(forward-comment (- (point-max))) is executed when point is just after the comment-closing "*/", point does not move. But if a space character is inserted in front of the "(A)", then '(forward-comment (- (point-max))) moves point to in front of the "/*". Inserting a space in front of the "(A)" also makes the problem in c-indent-line-or-region go away. junk.c -------------------- /* (A) 1) */ void dummy () { return; } bug.el -------------------- (defun bugtest () (setq c-mode-hook nil) (add-hook 'c-mode-hook (function (lambda () (setq ;;Problem depends in part on the line below c-offsets-alist '((c . c-lineup-dont-change)) tab-width 2) (c-set-style "gnu" t)))) (find-file "junk.c") (mark-whole-buffer) (setq debug-on-error t) (c-indent-line-or-region)) command line -------------------- emacs -q -l bug.el -f bugtest debugger output ------------------------ Debugger entered--Lisp error: (scan-error "Unbalanced parentheses" 13 1) scan-lists(13 -1 1) up-list(-1) backward-up-list(1) c-beginning-of-statement-1(1) c-guess-basic-syntax() c-indent-line(nil t) c-indent-region(1 42) c-indent-line-or-region() bugtest() command-line-1(("-l" "bug.el" "-f" "bugtest")) command-line() normal-top-level() --============_-1133751589==_ma============ Content-Type: text/html; charset="us-ascii" problem with c-indent-line-or-region
When I set up C indentation to leave the indentation of block comments unchanged, c-indent-line-or-region is sometimes broken by the presence of parentheses within block comments.

With the files junk.c and bug.el shown below in my current directory, I execute the command line shown below and get the debugger output shown at the bottom.

The problem appears to depend on the behavior of the built-in function forward-comment, which is called from c-forward-comment, which is called from c-backward-syntactic-ws.  If '(forward-comment (- (point-max))) is executed when point is just after the comment-closing "*/", point does not move.  But if a space character is inserted in front of the "(A)", then '(forward-comment (- (point-max))) moves point to in front of the "/*".

Inserting a space in front of the "(A)" also makes the problem in c-indent-line-or-region go away.


junk.c
--------------------
/*
(A)
1)
*/

void dummy ()
{
  return;
}


bug.el
--------------------
(defun bugtest ()
  (setq c-mode-hook nil)
  (add-hook 'c-mode-hook
            (function
             (lambda ()
               (setq
                ;;Problem depends in part on the line below
                c-offsets-alist '((c . c-lineup-dont-change))
                tab-width 2)
               (c-set-style "gnu" t))))
  (find-file "junk.c")
  (mark-whole-buffer)
  (setq debug-on-error t)
  (c-indent-line-or-region))

command line
--------------------
emacs -q -l bug.el -f bugtest

debugger output
------------------------
 Debugger entered--Lisp error: (scan-error "Unbalanced parentheses" 13 1)
  scan-lists(13 -1 1)
  up-list(-1)
  backward-up-list(1)
  c-beginning-of-statement-1(1)
  c-guess-basic-syntax()
  c-indent-line(nil t)
  c-indent-region(1 42)
  c-indent-line-or-region()
  bugtest()
  command-line-1(("-l" "bug.el" "-f" "bugtest"))
  command-line()
  normal-top-level()
--============_-1133751589==_ma============-- --===============1249282142== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bug-gnu-emacs mailing list Bug-gnu-emacs@gnu.org http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs --===============1249282142==--