From: g0dil Date: Thu, 26 Jul 2007 07:46:28 +0000 (+0000) Subject: Emacs/cc-ide: More robust function movement X-Git-Url: http://g0dil.de/git?p=emacsstuff.git;a=commitdiff_plain;h=a6d829771dafce1c0f0e597f5af806cf392d4936 Emacs/cc-ide: More robust function movement Network/MediaServ: Sync with SENF updates --- diff --git a/cc-ide/cc-engine-2.el b/cc-ide/cc-engine-2.el index 8b741fc..4a5a972 100644 --- a/cc-ide/cc-engine-2.el +++ b/cc-ide/cc-engine-2.el @@ -310,6 +310,10 @@ (and new-point brace-point))) (defun c-beginning-of-defun-or-decl () + (if (c-in-literal) + (goto-char (car (c-literal-limits)))) + (while (and (not (c-at-toplevel-p)) + (c-save-uplist -1))) (c-move-to-start-of-defun) (let ((point (point)) beg) (c-beginning-of-statement-1) diff --git a/cc-ide/cc-ide.el b/cc-ide/cc-ide.el index dd44d1b..67b7a44 100644 --- a/cc-ide/cc-ide.el +++ b/cc-ide/cc-ide.el @@ -674,12 +674,13 @@ copy constructor, assignment operator and destructor." (defun ccide-function-comment () "Add comment for current function" (interactive) - (if (c-in-literal) + (if (memq (c-in-literal) '(c c++)) ; Assume, we are in the functions comment ... (progn (c-forward-out-of-comment) (c-backward-syntactic-ws) (c-backward-sexp))) + (c-beginning-of-defun-or-decl) (let ((defun (c-get-defun-state)) (indent (make-string comment-column ? )) place) @@ -739,7 +740,7 @@ copy constructor, assignment operator and destructor." (defun ccide-function-comment-parse-arg (start end) (save-excursion (goto-char start) - (re-search-forward "\\param\\(\\[[^]*\\]\\)?\\s-*\\(\\S-*\\)" end t) + (re-search-forward "\\\\param\\(\\[[^]]*\\]\\)?\\s-*\\(\\S-*\\)" end t) (cons (match-string 2) (cons (buffer-substring start (match-beginning 2)) (buffer-substring (match-end 2) end))))) @@ -813,13 +814,15 @@ copy constructor, assignment operator and destructor." "Grab prototype of function defined or declared at point. Prefix arg, if given, specifies the kind of prefix (inline, static, ...) to use." (interactive "P") - (let* ((prfx (or (and prefix (nth (prefix-numeric-value prefix) c-user-prefixes)) - ccide-default-prefix)) - (defn (c-build-defun prfx))) - (kill-new (concat (cadr defn) "\n{}\n")) - (message (concat (or prfx "") - (if prfx " " "") - (car defn))))) + (save-excursion + (c-beginning-of-defun-or-decl) + (let* ((prfx (or (and prefix (nth (prefix-numeric-value prefix) c-user-prefixes)) + ccide-default-prefix)) + (defn (c-build-defun prfx))) + (kill-new (concat (cadr defn) "\n{}\n")) + (message (concat (or prfx "") + (if prfx " " "") + (car defn)))))) (defun ccide-reformat-defun () "Reformat the defn of the current defun." @@ -845,7 +848,8 @@ ring (presumably placed there using c++-grab-prototype)." (aref parse 1) (aref parse 2)) (or (aref parse 5) - (aref parse 6))) + (aref parse 6) + (aref parse 7))) (yank) (delete-char -3))))