[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:       2005-04-25 11:33:42
Message-ID: 20050425113342.A98D7653 () office ! kde ! org
[Download RAW message or body]

CVS commit by faure: 

Improve parsing in method-under-point to:
- work from anywhere in the method decl (used to assume end-of-decl)
- support exception specification (per Kalle's request)
- avoid parsing the same decl back and then forth again
- save excursion, i.e. no side effect

In agulbra-make-member: add voluntary side-effect which used to be done
by method-under-point, so that F9-F6-F9-F6-... allows implementing multiple
methods in a row.


  M +29 -24    kde-emacs-utils.el   1.57


--- kdesdk/scripts/kde-emacs/kde-emacs-utils.el  #1.56:1.57
@@ -71,5 +71,5 @@
         (function nil))
     (save-excursion
-      (progn
+      (save-excursion
         ; Go up a level, skipping entire classes etc.
         ; This is a modified version of (backward-up-list) which doesn't
@@ -103,27 +103,28 @@
         (let ((pos (c-safe-scan-lists (point) -1 1)))
           (goto-char (if pos (+ pos 1) (point-min))))
-        )))
+        ))
 
-    (progn ; Back to where we were, parse function name
-      (and (looking-at "$")
-           (progn
+    ; Back to where we were, parse function name
+    (backward-char)             ; in case we're after the ';'
+    (search-forward ";" nil t)  ; look for the ';'
+    (backward-char)
+    (let ((end (point)))          ; remember where the function decl ends
+      (search-backward ")" nil t) ; look back for the end of the argument list
+      (forward-char)
+      (backward-sexp)             ; brings us back to the '('
+      (backward-word)
+      (when (looking-at "throw[ \t]") ; exception specification, look for () again
              (search-backward ")" nil t)
              (forward-char)
-             (backward-sexp)))
+             (backward-sexp))
+      ; now that we moved back enough, go to beginning of line.
+      ; (we assume that the return type, function name, and '(' are on the same line)
       (re-search-backward "^[ \t]*")
-      (progn
-        (while (looking-at "[ \t]")
-          (forward-char 1))
-        (setq start (point))
-        (and (search-forward "(" nil t)
-             (progn
-               (forward-char -1)
-               (forward-sexp)))
-        (and (looking-at "[ \t]+const")
-             (forward-word 1))
-        (and (looking-at ";")
-             (setq function (buffer-substring start (point))))
-        (re-search-forward "(" nil t)))
-    (cons namespace (cons class function))
+      (while (looking-at "[ \t]")
+        (forward-char 1))
+      (setq function (buffer-substring (point) end))
+      )
+    ) ; end of global save-excursion
+    (cons namespace (cons class function)) ; the returned value
     )
   )
@@ -273,8 +274,12 @@
     (setq insertion-string 
           (concat (kde-function-impl-sig namespace class function) "\n{\n    \n}\n"))
+    ; move to next method, to be ready for next call
+    (backward-char)                ; in case we're after the ';'
+    (re-search-forward ";" nil t)  ; end of this method decl
+    (re-search-forward ";" nil t)  ; end of next method decl
+
     (if (string-match "\\.h$" file)
         (kde-switch-cpp-h)
-    )
-    (progn
+      )
     (goto-char (point-max))
     (kde-comments-begin)
@@ -300,7 +305,7 @@
       (and (string-match "\\.h$" file)
            (functionp 'kdab-insert-include-file)
-           (kdab-insert-include-file file 't nil))))
+           (kdab-insert-include-file file 't nil)))
     (when (featurep 'fume-rescan-buffer)
-    (fume-rescan-buffer))
+      (fume-rescan-buffer))
     ))
 


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

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