unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Marshall, Simon" <simon.marshall@misys.com>
Cc: "'fengli@gmail.com'" <fengli@gmail.com>
Subject: FW: about cc-mode bug
Date: Wed, 1 Nov 2006 14:56:30 -0000	[thread overview]
Message-ID: <81CCA6588E60BB42BE68BD029ED482600CA5EA64@wimex2.wim.midas-kapiti.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2130 bytes --]

This patch (redone for cvs emacs and attached) works great for me, so I
suggest it is incorporated...

Many thanks to Feng Li!

Simon.



-----Original Message-----
From: fengli [mailto:fengli@gmail.com] 
Sent: 28 October 2006 11:10
To: Marshall, Simon
Subject: about cc-mode bug

Hi,

this patch will fix the "variable instantiation fontified as function name"
bug.  I'm not sure if this hack will cause too much performance hit though
(because we have to look back at the context to decide if it is a variable
or a function anyway).

Index: cc-fonts.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/cc-fonts.el,v
retrieving revision 1.16
diff -c -r1.16 cc-fonts.el
*** cc-fonts.el    10 Jul 2006 13:17:09 -0000    1.16
--- cc-fonts.el    28 Oct 2006 09:49:23 -0000
***************
*** 817,822 ****
--- 817,831 ----
        (goto-char pos)))))
    nil)
 
+ (defun my-c-maybe-defun (location)
+   (condition-case nil
+       (save-excursion
+         (goto-char location)
+         (backward-up-list)
+         (c-beginning-of-statement 1)
+         (looking-at "\\(template[ \t]*<[^>*]>[
\t\n]+\\)?\\(class\\|struct|\\interface\\|namespace\\)"))
+     (error t)))
+
  (defun c-font-lock-declarators (limit list types)
    ;; Assuming the point is at the start of a declarator in a
    ;; declaration, fontify it.  If LIST is non-nil, fontify also all
***************
*** 897,903 ****
           "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
 
        (setq next-pos (match-beginning 0)
!         id-face (if (eq (char-after next-pos) ?\()
              'font-lock-function-name-face
                'font-lock-variable-name-face)
          got-init (and (match-beginning 1)
--- 906,913 ----
           "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
 
        (setq next-pos (match-beginning 0)
!         id-face (if (and (eq (char-after next-pos) ?\()
!                          (my-c-maybe-defun next-pos))
              'font-lock-function-name-face
                'font-lock-variable-name-face)
          got-init (and (match-beginning 1)

--
Feng Li


[-- Attachment #2: cc-fonts.diff --]
[-- Type: application/octet-stream, Size: 671 bytes --]

Index: cc-fonts.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/cc-fonts.el,v
retrieving revision 1.16
diff -r1.16 cc-fonts.el
819a820,828
> (defun my-c-maybe-defun (location)
>   (condition-case nil
>       (save-excursion
> 	(goto-char location)
> 	(backward-up-list)
> 	(c-beginning-of-statement 1)
> 	(looking-at "\\(template[ \t]*<[^>*]>[\t\n]+\\)?\\(class\\|struct|\\interface\\|namespace\\)"))
>     (error t)))
> 
900c909,910
< 	    id-face (if (eq (char-after next-pos) ?\()
---
> 	    id-face (if (and (eq (char-after next-pos) ?\()
> 			     (my-c-maybe-defun next-pos))

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

             reply	other threads:[~2006-11-01 14:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-01 14:56 Marshall, Simon [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-11-01 16:54 FW: about cc-mode bug Marshall, Simon
2006-11-02 21:46 ` Richard Stallman
2006-11-03  9:24 Marshall, Simon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81CCA6588E60BB42BE68BD029ED482600CA5EA64@wimex2.wim.midas-kapiti.com \
    --to=simon.marshall@misys.com \
    --cc=fengli@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).