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: Mysterious fontification/C++ context issue - Patch for c-basic-common-init Date: 17 Dec 2006 19:36:53 +0100 Message-ID: <20061217194741.GF2643@muc.de> References: <87d56rpk7a.fsf@stupidchicken.com> <20061213224009.GA1206@muc.de> <87odq72ssy.fsf@stupidchicken.com> <20061214084713.GA1333@muc.de> <45812BDF.5050107@gmx.at> <20061214193733.GA1269@muc.de> <45824FA5.3050702@gmx.at> <20061215203326.GB2795@muc.de> <4583C7B0.4020201@gmx.at> <20061217125521.GB2643@muc.de> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1166380636 11556 80.91.229.10 (17 Dec 2006 18:37:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 17 Dec 2006 18:37:16 +0000 (UTC) Cc: Chong Yidong , Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 17 19:37:14 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1Gw0sq-00047F-8y for ged-emacs-devel@m.gmane.org; Sun, 17 Dec 2006 19:37:12 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gw0sp-0004if-Mz for ged-emacs-devel@m.gmane.org; Sun, 17 Dec 2006 13:37:11 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gw0sc-0004gD-Gz for emacs-devel@gnu.org; Sun, 17 Dec 2006 13:36:58 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gw0sZ-0004eC-Gq for emacs-devel@gnu.org; Sun, 17 Dec 2006 13:36:58 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gw0sZ-0004e9-Es for emacs-devel@gnu.org; Sun, 17 Dec 2006 13:36:55 -0500 Original-Received: from [193.149.48.1] (helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1Gw0sZ-00009L-5Q for emacs-devel@gnu.org; Sun, 17 Dec 2006 13:36:55 -0500 Original-Received: (qmail 36266 invoked by uid 3782); 17 Dec 2006 18:36:53 -0000 Original-Received: from acm.muc.de (p54A3EEA3.dip.t-dialin.net [84.163.238.163]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Sun, 17 Dec 2006 19:36:46 +0100 (CET) Original-Received: (qmail 9701 invoked by uid 1000); 17 Dec 2006 19:47:41 -0000 Original-Date: Sun, 17 Dec 2006 19:47:41 +0000 Original-To: martin rudalics , Richard Stallman Content-Disposition: inline In-Reply-To: <20061217125521.GB2643@muc.de> User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.0.3 (Seattle Slew) X-Primary-Address: acm@muc.de 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:63894 Archived-At: Hi, Martin, and everybody else. On Sun, Dec 17, 2006 at 12:55:22PM +0000, Alan Mackenzie wrote: [ .... ] > OK, you've convinced me. I now agree with you that CC Mode should not > itself set that horrible variable to nil, not even as a default. I > should remove the offending line from cc-mode.el, and put some extra > explanation into cc-mode.texi and programs.texi. Here's a pair of patches to do the job. I think most people will be happy about them. ;-) Richard, please review my change to programs.texi. I'll have a look at cc-mode.texi ASAP. Thanks to Chong, Stefan and Martin for talking me through this at such great length and persuading me to do the right thing. 2006-12-17 Alan Mackenzie * progmodes/cc-mode.el (c-basic-common-init): don't set open-paren-in-column-0-is-defun-start to nil any more. Index: cc-mode.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-mode.el,v retrieving revision 1.50 diff -c -r1.50 cc-mode.el *** cc-mode.el 3 Dec 2006 00:59:33 -0000 1.50 --- cc-mode.el 17 Dec 2006 18:10:38 -0000 *************** *** 531,539 **** ;; heuristic that open parens in column 0 are defun starters. Since ;; we have c-state-cache, that heuristic isn't useful and only causes ;; trouble, so turn it off. ! (when (memq 'col-0-paren c-emacs-features) ! (make-local-variable 'open-paren-in-column-0-is-defun-start) ! (setq open-paren-in-column-0-is-defun-start nil)) (c-clear-found-types) --- 531,541 ---- ;; heuristic that open parens in column 0 are defun starters. Since ;; we have c-state-cache, that heuristic isn't useful and only causes ;; trouble, so turn it off. ! ;; 2006/12/17: This facility is somewhat confused, and doesn't really seem ! ;; helpful. Comment it out for now. ! ;; (when (memq 'col-0-paren c-emacs-features) ! ;; (make-local-variable 'open-paren-in-column-0-is-defun-start) ! ;; (setq open-paren-in-column-0-is-defun-start nil)) (c-clear-found-types) 2006-12-17 Alan Mackenzie * programs.texi (Left Margin Paren): Remove the bit which says that CC Mode sets open-paren-in-column-0-is-defun-start to nil. Discuss some of the issues of setting this option to nil. Index: programs.texi =================================================================== RCS file: /cvsroot/emacs/emacs/man/programs.texi,v retrieving revision 1.121 diff -c -r1.121 programs.texi *** programs.texi 30 Sep 2006 21:07:21 -0000 1.121 --- programs.texi 17 Dec 2006 18:28:40 -0000 *************** *** 156,178 **** @cindex open-parenthesis in leftmost column @cindex ( in leftmost column Emacs assumes by default that any opening delimiter found at the ! left margin is the start of a top-level definition, or defun. You can ! override this default by setting this user option: ! ! @defvar open-paren-in-column-0-is-defun-start ! If this user option is set to @code{t} (the default), opening ! parentheses or braces at column zero always start defuns. When it's ! @code{nil}, defuns are found by searching for parens or braces at the ! outermost level. Some major modes, including C and related modes, set ! @code{open-paren-in-column-0-is-defun-start} buffer-locally to ! @code{nil} ! @end defvar ! ! In modes where @code{open-paren-in-column-0-is-defun-start} is ! @code{t}, @strong{don't put an opening delimiter at the left margin ! unless it is a defun start}. For instance, never put an open-parenthesis at the left margin in a Lisp file unless it is the ! start of a top-level list. If you don't follow this convention, not only will you have trouble when you explicitly use the commands for motion by defuns; other --- 156,166 ---- @cindex open-parenthesis in leftmost column @cindex ( in leftmost column Emacs assumes by default that any opening delimiter found at the ! left margin is the start of a top-level definition, or defun. ! Therefore, @strong{don't put an opening delimiter at the left margin ! unless it should have that significance}. For instance, never put an open-parenthesis at the left margin in a Lisp file unless it is the ! start of a top-level list. If you don't follow this convention, not only will you have trouble when you explicitly use the commands for motion by defuns; other *************** *** 182,191 **** The most likely problem case is when you want an opening delimiter at the start of a line inside a string. To avoid trouble, put an ! escape character (@samp{\}, in Emacs Lisp, @samp{/} in some other Lisp ! dialects) before the opening delimiter. This will not affect the ! contents of the string, but will prevent that opening delimiter from ! starting a defun. Here's an example: @example (insert "Foo: --- 170,179 ---- The most likely problem case is when you want an opening delimiter at the start of a line inside a string. To avoid trouble, put an ! escape character (@samp{\}, in C and Emacs Lisp, @samp{/} in some ! other Lisp dialects) before the opening delimiter. This will not ! affect the contents of the string, but will prevent that opening ! delimiter from starting a defun. Here's an example: @example (insert "Foo: *************** *** 197,202 **** --- 185,209 ---- highlights confusing opening delimiters (those that ought to be quoted) in bold red. + If you need to override this convention, you can so by setting this + user option: + + @defvar open-paren-in-column-0-is-defun-start + If this user option is set to @code{t} (the default), opening + parentheses or braces at column zero always start defuns. When it's + @code{nil}, defuns are found by searching for parens or braces at the + outermost level. + @end defvar + + Usually, you shouldn't need to set + @code{open-paren-in-column-0-is-defun-start} to @code{nil}. However, + if your buffer contains parentheses or braces in column zero which + don't start defuns and this confuses Emacs, it sometimes helps to set + the option to @code{nil}. Be aware, though, that this will make + scrolling and display in large buffers quite sluggish, and that + parentheses and braces must be correctly matched throughout the buffer + for it to work properly. + In the earliest days, the original Emacs found defuns by moving upward a level of parentheses or braces until there were no more levels to go up. This always required scanning all the way back to *************** *** 1557,1566 **** @table @kbd @item C-c C-@key{DEL} @itemx C-c @key{DEL} ! @findex c-hungry-backspace @kindex C-c C-@key{DEL} (C Mode) @kindex C-c @key{DEL} (C Mode) ! @code{c-hungry-backspace}---Delete the entire block of whitespace preceding point. @item C-c C-d --- 1564,1573 ---- @table @kbd @item C-c C-@key{DEL} @itemx C-c @key{DEL} ! @findex c-hungry-delete-backwards @kindex C-c C-@key{DEL} (C Mode) @kindex C-c @key{DEL} (C Mode) ! @code{c-hungry-delete-backwards}---Delete the entire block of whitespace preceding point. @item C-c C-d -- Alan.