[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdesdk/scripts/kde-emacs
From:       David Faure <faure () kde ! org>
Date:       2004-04-06 22:41:25
Message-ID: 20040406224125.80AFB99F4 () office ! kde ! org
[Download RAW message or body]

CVS commit by faure: 

Fixed the support for namespace, to recognize constructors correctly (which fixes
the additional space that was inserted before them)


  M +11 -7     kde-emacs-utils.el   1.47


--- kdesdk/scripts/kde-emacs/kde-emacs-utils.el  #1.46:1.47
@@ -78,4 +78,5 @@
   (interactive)
   (let ((class nil)
+        (namespace "") ; will contain A::B::
         (function nil)
         (file (buffer-file-name))
@@ -95,6 +96,6 @@
                (forward-char 1))
              (cond 
-              (class
-               (setq class (concat (buffer-substring start (point)) "::" class)))
+              (class ; class found already, so the rest goes into the namespace
+               (setq namespace (concat (buffer-substring start (point)) "::" namespace)))
               (t ;class==nil
                (setq class (buffer-substring start (point)))))
@@ -104,4 +105,5 @@
         ; throw an error when not found.
         (let ((pos (scan-lists (point) -1 1 nil t)))
+          ; +1 added here so that the regexp in the while matches the { too.
           (goto-char (if pos (+ pos 1) (point-min))))
         ))
@@ -137,4 +139,6 @@
            (while (string-match "  +" function)
              (setq function (replace-match " " t t function)))
+           (while (string-match "^ " function)
+             (setq function (replace-match "" t t function)))
            (while (string-match "\t+" function)
              (setq function (replace-match " " t t function)))
@@ -147,18 +151,18 @@
          (stringp file)
          (progn
-           (cond ((string-match (concat "^ *" class "[ \\t]*(") function)
+           (cond ((string-match (concat "^ *" class "[ \\t]*(") function) ; constructor
                   (progn
                   (setq insertion-string
                         (concat
                          (replace-match
-                          (concat class "::" class "(")
+                          (concat namespace class "::" class "(")
                           t t function)
                          "\n{\n    \n}\n"))))
-                  ((string-match (concat "^ *~" class "[ \\t]*(") function)
+                  ((string-match (concat "^ *~" class "[ \\t]*(") function) ; destructor
                    (progn
                      (setq insertion-string
                            (concat
                             (replace-match
-                             (concat class "::~" class "(")
+                             (concat namespace class "::~" class "(")
                              t t function)
                             "\n{\n    \n}\n"))))
@@ -168,5 +172,5 @@
                            (concat
                             (replace-match
-                             (concat " " class "::" "\\1(")
+                             (concat " " namespace class "::" "\\1(")
                              t nil function)
                             "\n{\n    \n}\n"))))


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic