all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [simon.marshall@misys.com: RE: Font-lock fontifies C/C++ case keyword as a constant]
@ 2006-11-09  0:54 Richard Stallman
  2006-11-10 16:59 ` Chong Yidong
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Stallman @ 2006-11-09  0:54 UTC (permalink / raw)


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

------- Start of forwarded message -------
From: "Marshall, Simon" <simon.marshall@misys.com>
To: "'emacs-pretest-bug@gnu.org'" <emacs-pretest-bug@gnu.org>,
	"'bug-cc-mode@gnu.org'" <bug-cc-mode@gnu.org>
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' <fengli@gmail.com>
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  <simon@gnu.org>

	* 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: 'bug-cc-mode@gnu.org'
> Cc: 'emacs-pretest-bug@gnu.org'
> 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
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [simon.marshall@misys.com: RE: Font-lock fontifies C/C++ case keyword as a constant]
  2006-11-09  0:54 [simon.marshall@misys.com: RE: Font-lock fontifies C/C++ case keyword as a constant] Richard Stallman
@ 2006-11-10 16:59 ` Chong Yidong
  0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2006-11-10 16:59 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

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

Installed.

> From: "Marshall, Simon" <simon.marshall@misys.com>
> Subject: RE: Font-lock fontifies C/C++ case keyword as a constant
> To: "'emacs-pretest-bug@gnu.org'" <emacs-pretest-bug@gnu.org>,
> 	"'bug-cc-mode@gnu.org'" <bug-cc-mode@gnu.org>
> Cc: 'Feng Li' <fengli@gmail.com>
>
> 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  <simon@gnu.org>
>
> 	* 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: 'bug-cc-mode@gnu.org'
>> Cc: 'emacs-pretest-bug@gnu.org'
>> 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
> emacs-pretest-bug@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
>
> - ------_=_NextPart_000_01C7032E.400E4C2A--
> ----------
>
>
>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-11-10 16:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-09  0:54 [simon.marshall@misys.com: RE: Font-lock fontifies C/C++ case keyword as a constant] Richard Stallman
2006-11-10 16:59 ` Chong Yidong

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.