emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

address@hidden: RE: Font-lock fontifies C/C++ case keyword as a constant


From: Richard Stallman
Subject: address@hidden: RE: Font-lock fontifies C/C++ case keyword as a constant]
Date: Wed, 08 Nov 2006 19:54:46 -0500

If there is no objection from bug-cc-mode in 3 days, would someone
please install this?

------- Start of forwarded message -------
From: "Marshall, Simon" <address@hidden>
To: "'address@hidden'" <address@hidden>,
        "'address@hidden'" <address@hidden>
Date: Wed, 8 Nov 2006 12:05:58 -0000 
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C7032E.400E4C2A"
Cc: 'Feng Li' <address@hidden>
Subject: RE: Font-lock fontifies C/C++ case keyword as a constant
X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=failed 
        version=3.0.4

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

- ------_=_NextPart_000_01C7032E.400E4C2A
Content-Type: text/plain

Here is a patch that fixes the below problem for cvs emacs.

The patch prevents the re-fontification of the "case" keyword as a constant.
I also toyed with some code that fontifies the case constants as constants,
as Emacs 19-21 tries to do, but it doesn't (can't) work in all cases.  Also,
I think that's probably over the top, so I have left the additional code in
but commented it out.

2006-11-08  Simon Marshall  <address@hidden>

        * progmodes/cc-fonts.el (c-font-lock-declarations): Don't overwrite
        fontification for "case" and "default" keywords.

Simon.

> -----Original Message-----
> From: Marshall, Simon 
> Sent: 08 September 2006 11:53
> To: 'address@hidden'
> Cc: 'address@hidden'
> Subject: Font-lock fontifies C/C++ case keyword as a constant
> 
> In Emacs 19-21 fontifies the following C/C++ snippet:
> 
>       case fubar:
> 
> so that the keyword "case" is fontified as a keyword and 
> "fubar" is fontified as a constant.  Seems reasonable.
> 
> In Emacs CVS, the keyword "case" is fontified as a constant, 
> and "fubar" is not fontified at all.
> 
> (With the C++ snippet "case foo::bar:" you get the bemusing 
> situation where everything is fontified as a constant---apart 
> from the constant.  Fontifying the type/namespace qualifier 
> as a constant is the subject of another bug report.)
> 
> The first bug is that the "case" keyword should not be 
> fontified as a constant.  
> 
> For the second bug, IWBNI the constant was fontified as a 
> constant too, as it used to be, though that can be awkward 
> where the constant is a constant expression.  Still, Emacs 
> used to manage to correctly fontify:
> 
>       case foo | bar:
> 
> so that the keyword "case" is fontified as a keyword and 
> "foo" and "bar" are fontified as constants.  But if you don't 
> want to fontify constants like this for some reason, you 
> should make the "default" keyword be fontified as a keyword too.
> 
> Simon.


- ------_=_NextPart_000_01C7032E.400E4C2A
Content-Type: application/octet-stream;
        name="cc-fonts.diff2"
Content-Disposition: attachment;
        filename="cc-fonts.diff2"
Content-Transfer-Encoding: quoted-printable

Index: cc-fonts.el=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /sources/emacs/emacs/lisp/progmodes/cc-fonts.el,v=0A=
retrieving revision 1.16=0A=
diff -r1.16 cc-fonts.el=0A=
1173c1173=0A=
<         ;; It was a false alarm.  Check if we're in a label instead.=0A=
- ---=0A=
>         ;; It was a false alarm.=0A=
1175,1187c1175,1205=0A=
<         (when (c-forward-label t match-pos nil)=0A=
<           ;; Can't use `c-fontify-types-and-refs' here since we=0A=
<           ;; should use the label face.=0A=
<           (let (elem)=0A=
<             (while c-record-ref-identifiers=0A=
<               (setq elem (car c-record-ref-identifiers)=0A=
<                     c-record-ref-identifiers (cdr 
c-record-ref-identifiers))=0A=
<               (c-put-font-lock-face (car elem) (cdr elem)=0A=
<                                     c-label-face-name)))=0A=
<           ;; `c-forward-label' probably has added a `c-decl-end'=0A=
<           ;; marker, so return t to `c-find-decl-spots' to signal=0A=
<           ;; that.=0A=
<           t))))=0A=
- ---=0A=
>         ;; The below code attempts to fontify the case constants in=0A=
>         ;; c-label-face-name, but it cannot catch every case [sic].=0A=
>         ;; And do we want to fontify case constants anyway?=0A=
>         nil=0A=
> ;;;     (when (c-forward-label t match-pos nil)=0A=
> ;;;       ;; Can't use `c-fontify-types-and-refs' here since we=0A=
> ;;;       ;; should use the label face.=0A=
> ;;;       (save-excursion=0A=
> ;;;         (while c-record-ref-identifiers=0A=
> ;;;           (let ((elem (car c-record-ref-identifiers))=0A=
> ;;;                 c-record-type-identifiers)=0A=
> ;;;             (goto-char (cdr elem))=0A=
> ;;;             ;; Find the end of any label.=0A=
> ;;;             (while (and (re-search-forward "\\sw\\|:" nil t)=0A=
> ;;;                         (progn (backward-char 1) t)=0A=
> ;;;                         (or (re-search-forward=0A=
> ;;;                              "\\=3D0[Xx][0-9A-Fa-f]+\\|\\([0-9]+\\)" nil 
> t)=0A=
> ;;;                             (c-forward-name)))=0A=
> ;;;               (c-backward-syntactic-ws)=0A=
> ;;;               (let ((end (point)))=0A=
> ;;;                 ;; Now find the start of the bit we regard as the =
label.=0A=
> ;;;                 (when (and (c-simple-skip-symbol-backward)=0A=
> ;;;                            (not (c-get-char-property (point) 'face)))=0A=
> ;;;                   (c-put-font-lock-face (point) end 
> c-label-face-name))=0A=
> ;;;                 (goto-char end))))=0A=
> ;;;           (setq c-record-ref-identifiers (cdr =
c-record-ref-identifiers))))=0A=
> ;;;       ;; `c-forward-label' probably has added a `c-decl-end'=0A=
> ;;;       ;; marker, so return t to `c-find-decl-spots' to signal=0A=
> ;;;       ;; that.=0A=
> ;;;       t)=0A=
>         )))=0A=

- ------_=_NextPart_000_01C7032E.400E4C2A
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
emacs-pretest-bug mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug

- ------_=_NextPart_000_01C7032E.400E4C2A--
------- End of forwarded message -------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]