emacs-devel
[Top][All Lists]
Advanced

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

Fix for highlighting constructor/destructor in font-lock.el


From: Krishnakumar B
Subject: Fix for highlighting constructor/destructor in font-lock.el
Date: Wed, 15 May 2002 20:21:21 -0500

Hi,

The following patch seems to fix the highlighting of constructor and
destructor inside a C++ class declaration. I don't if this is the preferred
way but it seems to work. The existing code doesn't highlight the
constructor/destructor of a simple class like

class Foo {
public:
  Foo ();
  ~Foo ();
};


diff -ubBw /usr/share/emacs/21.2/lisp/font-lock.el /u/kitty/font-lock.el
--- /usr/share/emacs/21.2/lisp/font-lock.el     Tue May 14 22:27:44 2002
+++ /u/kitty/font-lock.el       Tue May 14 22:27:44 2002
@@ -2450,10 +2450,10 @@
 (defun font-lock-match-c++-structor-declaration (limit)
   ;; Match C++ constructors and destructors inside class declarations.
   (let ((res nil)
-       (regexp (concat 
"^\\s-+\\(\\(virtual\\|explicit\\)\\s-+\\)*~?\\(\\sw+\\|"
+       (regexp (concat "^\\s-+\\(\\(virtual\\|explicit\\)\\s-+\\)*~?\\(\\<"
                        (mapconcat 'identity
                                   c++-font-lock-extra-types "\\|")
-                       "\\)\\s-*("
+                       "\\>\\)\\s-*("
                        ;; Don't match function pointer declarations, e.g.:
                        ;;    Foo (*fptr)();
                        "\\s-*[^*( \t]")))

The same can be acheived by adding \\sw+ to c++-font-lock-extra-types which
is IMHO is ugly as the function name is not a type. I don't see the point
why that mapconcat exists at all. It matches code like:

class Foo {
public:
  <bit_vector> ();
};

Am I missing something here ? Also can this function
(font-lock-match-c++-structor-declaration) be moved from
c++-font-lock-keywords-3 to c++-font-lock-keywords-2 as highlighting
constructors, destructors is no different from highlighting member
functions which is done even at c++-font-lock-keywords-1 ?

-kitty

-- 
Krishnakumar B <kitty at cs dot wustl dot edu>
Distributed Object Computing Laboratory, Washington University in St.Louis



reply via email to

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