unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* problem with c-indent-line-or-region
@ 2004-03-04  3:28 Greg Hill
  0 siblings, 0 replies; only message in thread
From: Greg Hill @ 2004-03-04  3:28 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 1833 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 4517 bytes --]

[-- Attachment #2: Type: text/plain, Size: 148 bytes --]

_______________________________________________
Bug-gnu-emacs mailing list
Bug-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-03-04  3:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-04  3:28 problem with c-indent-line-or-region Greg Hill

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