[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mysterious fontification/C++ context issue - Patch for c-basic-commo
From: |
Alan Mackenzie |
Subject: |
Re: Mysterious fontification/C++ context issue - Patch for c-basic-common-init |
Date: |
17 Dec 2006 19:36:53 +0100 |
Date: |
Sun, 17 Dec 2006 19:47:41 +0000 |
User-agent: |
Mutt/1.5.9i |
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 <address@hidden>
* 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 <address@hidden>
* 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 address@hidden
@itemx C-c @key{DEL}
! @findex c-hungry-backspace
@kindex C-c address@hidden (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 address@hidden
@itemx C-c @key{DEL}
! @findex c-hungry-delete-backwards
@kindex C-c address@hidden (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.
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., (continued)
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Alan Mackenzie, 2006/12/15
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., David Kastrup, 2006/12/15
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Alan Mackenzie, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., David Kastrup, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Alan Mackenzie, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., David Kastrup, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Alan Mackenzie, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., David Kastrup, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for c-basic-common-init,
Alan Mackenzie <=
- Re: Mysterious fontification/C++ context issue - Patch for c-basic-common-init, Chong Yidong, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for c-basic-common-init, Alan Mackenzie, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for c-basic-common-init, Chong Yidong, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Stefan Monnier, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Stefan Monnier, 2006/12/15
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Chong Yidong, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Chong Yidong, 2006/12/16