From: Stefan Bund Date: Mon, 6 May 2013 14:16:02 +0000 (+0200) Subject: ccide fixes X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=0f2d15f66459e62102f6f2aac1e3c83641563c51;p=emacsstuff.git ccide fixes --- diff --git a/cc-ide/cc-engine-2.el b/cc-ide/cc-engine-2.el index 5933977..12e37e6 100644 --- a/cc-ide/cc-engine-2.el +++ b/cc-ide/cc-engine-2.el @@ -29,19 +29,19 @@ (modify-syntax-entry ?> ")" table) table)) -(defconst c-any-key +(defconst c-any-key (eval-when-compile (concat (regexp-opt '("break" "continue" "do" "else" "for" "if" - "return" "switch" "while" "sizeof" "typedef" - "extern" "auto" "register" "static" "friend" - "volatile" "const" "restrict" "enum" - "struct" "union" "class" "char" "short" - "int" "long" "signed" "unsigned" "float" - "double" "void" "complex" "case" "goto" - "inline" "try" "catch" "throw" "inline_" - "throw_" "virtual" "new" "delete" "explicit" + "return" "switch" "while" "sizeof" "typedef" + "extern" "auto" "register" "static" "friend" + "volatile" "const" "restrict" "enum" + "struct" "union" "class" "char" "short" + "int" "long" "signed" "unsigned" "float" + "double" "void" "complex" "case" "goto" + "inline" "try" "catch" "throw" "inline_" + "throw_" "virtual" "new" "delete" "explicit" "prefix_" "typename" "template") t) - "\\b[^_]"))) + "\\b[^_]"))) (defconst c-blocking-key (eval-when-compile @@ -56,7 +56,7 @@ (defconst c-operator-operators nil) (defconst c-typedef-key "typedef\\b[^_]") (defconst c-friend-key "friend\\b[^_]") -(defconst c-access-key "\\(public\\|protected\\|private\\)\\s-*:") +(defconst c-access-key "\\(public\\|protected\\|private\\|signals\\|public\\s-*slots\\|protected\\s-*slots\\|private\\s-slots\\)\\s-*:") (defconst c-access-keys '(("public\\s-*:" . public) ("protected\\s-*:" . protected) @@ -65,13 +65,13 @@ (let ((assable '("+" "-" "*" "/" "%" "^" "&" "|" "~" "!" "=" "<" ">" ">>" "<<")) (others '("&&" "||" "++" "--" "->*" "," "->" "[]" "()" "new" "new[]" - "delete" "delete[]" "bool"))) + "delete" "delete[]" "bool"))) (setq c-operator-operators - (regexp-opt (nconc (mapcar (function (lambda (x) (concat x "="))) - assable) - assable others) t))) + (regexp-opt (nconc (mapcar (function (lambda (x) (concat x "="))) + assable) + assable others) t))) -(defconst c-operator-word +(defconst c-operator-word (concat "operator\\s-*" c-operator-operators)) (defconst c-skip-syntaxes '(? ?. ?')) @@ -88,10 +88,10 @@ (let ((saved-syntax-table (make-symbol "saved-syntax-table"))) `(let ((,saved-syntax-table (syntax-table))) (unwind-protect - (progn - (set-syntax-table ,table) - ,@body) - (set-syntax-table ,saved-syntax-table))))) + (progn + (set-syntax-table ,table) + ,@body) + (set-syntax-table ,saved-syntax-table))))) (def-edebug-spec c-with-temporary-syntax-table (sexp body)) (put 'c-with-temporary-syntax-table 'lisp-indent-function 1) @@ -103,8 +103,8 @@ ;; skip char's not considered part of sexps forward (c-forward-syntactic-ws) (while (and (not (eq (following-char) ?<)) - (memq (char-syntax (following-char)) c-skip-syntaxes) - (not (eobp))) + (memq (char-syntax (following-char)) c-skip-syntaxes) + (not (eobp))) (forward-char 1) (c-forward-syntactic-ws))) @@ -112,8 +112,8 @@ ;; skip char's not considered part of sexps backward (c-backward-syntactic-ws) (while (and (not (eq (preceding-char) ?>)) - (memq (char-syntax (preceding-char)) c-skip-syntaxes) - (not (bobp))) + (memq (char-syntax (preceding-char)) c-skip-syntaxes) + (not (bobp))) (forward-char -1) (c-backward-syntactic-ws))) @@ -129,16 +129,16 @@ (let ((level 1)) (forward-char 1) (while (and (> level 0) - (re-search-forward "[[({<>]" nil t)) - (if (not (c-in-literal)) - (cond ((memq (preceding-char) '(?\[ ?\( ?{)) - (up-list 1)) - - ((eq (preceding-char) ?<) - (setq level (1+ level))) - - ((eq (preceding-char) ?>) - (setq level (1- level))))))))) + (re-search-forward "[[({<>]" nil t)) + (if (not (c-in-literal)) + (cond ((memq (preceding-char) '(?\[ ?\( ?{)) + (up-list 1)) + + ((eq (preceding-char) ?<) + (setq level (1+ level))) + + ((eq (preceding-char) ?>) + (setq level (1- level))))))))) (defun c-backward-template-arglist () ;; reverse of c-forward-template-arglist @@ -148,16 +148,16 @@ (let ((level 1)) (forward-char -1) (while (and (> level 0) - (re-search-backward "[])}<>]" nil t)) - (if (not (c-in-literal)) - (cond ((memq (following-char) '(?\] ?\) ?})) - (up-list -1)) + (re-search-backward "[])}<>]" nil t)) + (if (not (c-in-literal)) + (cond ((memq (following-char) '(?\] ?\) ?})) + (up-list -1)) - ((eq (following-char) ?>) - (setq level (1+ level))) - - ((eq (following-char) ?<) - (setq level (1- level))))))))) + ((eq (following-char) ?>) + (setq level (1+ level))) + + ((eq (following-char) ?<) + (setq level (1- level))))))))) (defsubst c-at-symbol-p () (memq (char-syntax (following-char)) '(?w ?_))) @@ -167,16 +167,16 @@ (defun c-forward-extended-sexp () ;; Move forward one sexp. This function tries to correctly skip - ;; template argument lists delimited by angle brackets. + ;; template argument lists delimited by angle brackets. (c-skip-non-sexp-chars-forward) (if (and (eq (following-char) ?<) - (condition-case nil - (let ((start (point))) - (c-forward-template-arglist) - (if (or (not (eq (preceding-char) ?>)) - (c-crosses-statement-barrier-p start (point))) - (progn (goto-char start) nil) t)) - (error nil))) + (condition-case nil + (let ((start (point))) + (c-forward-template-arglist) + (if (or (not (eq (preceding-char) ?>)) + (c-crosses-statement-barrier-p start (point))) + (progn (goto-char start) nil) t)) + (error nil))) nil (c-forward-sexp))) @@ -184,13 +184,13 @@ ;; reverse of c-forward-extenden-sexp (c-skip-non-sexp-chars-backward) (if (and (eq (preceding-char) ?>) - (condition-case nil - (let ((start (point))) - (c-backward-template-arglist) - (if (or (not (eq (following-char) ?<)) - (c-crosses-statement-barrier-p (point) start)) - (progn (goto-char start) nil) t)) - (error nil))) + (condition-case nil + (let ((start (point))) + (c-backward-template-arglist) + (if (or (not (eq (following-char) ?<)) + (c-crosses-statement-barrier-p (point) start)) + (progn (goto-char start) nil) t)) + (error nil))) nil (c-backward-sexp))) @@ -202,13 +202,13 @@ ;; separators in the name (c-forward-syntactic-ws) (let (points) - (while - (progn - (setq points (cons (point) points)) - (if (looking-at "::") - (forward-char 2)) - (c-forward-syntactic-ws) - (if (and (cond ((looking-at c-operator-word) + (while + (progn + (setq points (cons (point) points)) + (if (looking-at "::") + (forward-char 2)) + (c-forward-syntactic-ws) + (if (and (cond ((looking-at c-operator-word) (goto-char (match-end 0))) ((looking-at "~") (forward-char 1) @@ -219,11 +219,11 @@ (prog1 (c-at-symbol-p) (c-forward-token-1)))) - (eq (following-char) ?<)) - (progn - (c-forward-template-arglist) - (c-forward-syntactic-ws))) - (looking-at "::"))) + (eq (following-char) ?<)) + (progn + (c-forward-template-arglist) + (c-forward-syntactic-ws))) + (looking-at "::"))) (nreverse points))) (defun c-backward-scoped-name () @@ -231,49 +231,49 @@ (c-backward-syntactic-ws) (while (progn - (if (and (eq (preceding-char) ?>) - (not (save-excursion - (re-search-backward (concat c-operator-word "\\=") nil t)))) - (c-backward-template-arglist)) - (c-backward-syntactic-ws) - (if (re-search-backward (concat c-operator-word "\\=") nil t) - (goto-char (match-beginning 0)) - (c-backward-token-1) + (if (and (eq (preceding-char) ?>) + (not (save-excursion + (re-search-backward (concat c-operator-word "\\=") nil t)))) + (c-backward-template-arglist)) + (c-backward-syntactic-ws) + (if (re-search-backward (concat c-operator-word "\\=") nil t) + (goto-char (match-beginning 0)) + (c-backward-token-1) (if (and (c-at-symbol-p) (eq (preceding-char) ?~)) (forward-char -1))) (c-backward-syntactic-ws) - (if (eq (preceding-char) ?:) - (progn - (forward-char -1) - (if (eq (preceding-char) ?:) - (progn - (forward-char -1) - (c-backward-syntactic-ws) - t) - (forward-char 1) - nil))))) + (if (eq (preceding-char) ?:) + (progn + (forward-char -1) + (if (eq (preceding-char) ?:) + (progn + (forward-char -1) + (c-backward-syntactic-ws) + t) + (forward-char 1) + nil))))) (c-forward-syntactic-ws)) (defun c-forward-balanced-token () (c-forward-syntactic-ws) (cond ((or (c-at-symbol-p) - (looking-at c-operator-word)) - (c-forward-scoped-name)) - ((memq (following-char) '(?\( ?{ ?<)) - (c-forward-extended-sexp)) - (t - (c-forward-token-1)))) + (looking-at c-operator-word)) + (c-forward-scoped-name)) + ((memq (following-char) '(?\( ?{ ?<)) + (c-forward-extended-sexp)) + (t + (c-forward-token-1)))) (defun c-backward-balanced-token () (c-backward-syntactic-ws) (cond ((or (c-after-symbol-p) - (re-search-backward (concat c-operator-word "\\=") nil t)) - (c-backward-scoped-name)) - ((memq (preceding-char) '(?\) ?} ?>)) - (c-backward-extended-sexp)) - (t - (c-backward-token-1)))) + (re-search-backward (concat c-operator-word "\\=") nil t)) + (c-backward-scoped-name)) + ((memq (preceding-char) '(?\) ?} ?>)) + (c-backward-extended-sexp)) + (t + (c-backward-token-1)))) ;; defun's @@ -285,28 +285,28 @@ ;; move farther back than that. (let (new-point brace-point) (save-excursion - (while - (and (c-save-uplist -1) - (or (not limit) - (> (point) limit)) - (not (setq new-point - (if (and (eq (following-char) ?{) - (c-just-after-func-arglist-p)) - (progn - (setq brace-point (point)) - (c-beginning-of-statement-1) - (while (and (< (point) brace-point) - (not (eq (following-char) ?\())) - (c-forward-extended-sexp) - (c-forward-syntactic-ws)) - (if (eq (following-char) ?\() - (progn - (c-backward-syntactic-ws) - (c-backward-scoped-name) - (if (not (looking-at c-conditional-key)) - (point))))))))))) + (while + (and (c-save-uplist -1) + (or (not limit) + (> (point) limit)) + (not (setq new-point + (if (and (eq (following-char) ?{) + (c-just-after-func-arglist-p)) + (progn + (setq brace-point (point)) + (c-beginning-of-statement-1) + (while (and (< (point) brace-point) + (not (eq (following-char) ?\())) + (c-forward-extended-sexp) + (c-forward-syntactic-ws)) + (if (eq (following-char) ?\() + (progn + (c-backward-syntactic-ws) + (c-backward-scoped-name) + (if (not (looking-at c-conditional-key)) + (point))))))))))) (if new-point - (goto-char new-point)) + (goto-char new-point)) (and new-point brace-point))) (defun c-beginning-of-defun-or-decl () @@ -314,19 +314,19 @@ (goto-char (car (c-literal-limits)))) (c-save-buffer-state () (while (and (not (c-at-toplevel-p)) - (c-save-uplist -1))) + (c-save-uplist -1))) (c-move-to-start-of-defun) (let ((point (point)) - (flag (c-beginning-of-statement-1)) - beg) + (flag (c-beginning-of-statement-1)) + beg) (cond ((eq flag 'label) - (c-forward-label)) - ((eq flag 'previous) - (goto-char point))) + (c-forward-label)) + ((eq flag 'previous) + (goto-char point))) ;(setq beg (point)) ;(c-end-of-statement) ;(if (> (point) point) - ;(goto-char beg) + ;(goto-char beg) ;(goto-char point)) (c-forward-syntactic-ws)))) @@ -337,22 +337,22 @@ (defun c-beginning-of-statement-2 () ;; Move to the REAL beginning of the statement, ignoring all subexpressions (let ((point (point)) - (state (c-parse-state)) - (last (point))) + (state (c-parse-state)) + (last (point))) (while (and state - (not (consp (car state))) - (progn - (goto-char (car state)) - (looking-at "("))) + (not (consp (car state))) + (progn + (goto-char (car state)) + (looking-at "("))) (setq last (car state) - state (cdr state))) + state (cdr state))) (if (and state last - (not (consp (car state)))) - (goto-char last)) + (not (consp (car state)))) + (goto-char last)) (c-beginning-of-statement-1) (while (and (< (point) point) - (or (c-crosses-statement-barrier-p (point) point) - (not (equal (c-parse-state) state)))) + (or (c-crosses-statement-barrier-p (point) point) + (not (equal (c-parse-state) state)))) (c-end-of-statement)) (c-forward-syntactic-ws) (while (looking-at c-any-key) @@ -390,8 +390,8 @@ ;; like up-list but return nil on error (condition-case nil (progn - (up-list arg) - (point)) + (up-list arg) + (point)) (scan-error nil))) (defun c-full-parse-state () @@ -413,28 +413,28 @@ (save-excursion (let (key element keys) (while (setq key (c-aggressive-search-uplist-for-scopekey)) - (goto-char (aref key 0)) - (setq element (vector nil - (aref key 0) - (aref key 1) - nil)) - (cond ((looking-at c-class-scope-key) - (aset element 0 'class) - (c-backward-syntactic-ws) - (if (eq (preceding-char) ?>) - ;; this is a templated class/struct declaration - (save-excursion - (c-backward-template-arglist) - (c-backward-token-1) - (if (looking-at c-template-key) - (aset element 3 (point)))))) - - ((looking-at c-namespace-scope-key) - (aset element 0 'namespace))) - - (if (aref element 0) - (setq keys (cons element keys)))) - keys))) + (goto-char (aref key 0)) + (setq element (vector nil + (aref key 0) + (aref key 1) + nil)) + (cond ((looking-at c-class-scope-key) + (aset element 0 'class) + (c-backward-syntactic-ws) + (if (eq (preceding-char) ?>) + ;; this is a templated class/struct declaration + (save-excursion + (c-backward-template-arglist) + (c-backward-token-1) + (if (looking-at c-template-key) + (aset element 3 (point)))))) + + ((looking-at c-namespace-scope-key) + (aset element 0 'namespace))) + + (if (aref element 0) + (setq keys (cons element keys)))) + keys))) (defun c-get-scope () ;; This is like c-get-block-scope. Additionaly, if in a function @@ -446,14 +446,14 @@ (let ((scope (c-get-block-scope))) (save-excursion (if (c-move-to-start-of-defun (and scope (aref (car (last scope)) 1))) - (let ((element (vector 'defun (point) nil nil))) - (c-forward-scoped-name) - (aset element 2 (point)) - (c-beginning-of-statement-1) - (if (looking-at c-template-key) - (aset element 3 (point))) - (nconc scope (list element))) - scope)))) + (let ((element (vector 'defun (point) nil nil))) + (c-forward-scoped-name) + (aset element 2 (point)) + (c-beginning-of-statement-1) + (if (looking-at c-template-key) + (aset element 3 (point))) + (nconc scope (list element))) + scope)))) (defun c-scope-name (p &optional strip) ;; return the name of the scope at P. if STRIP is non-nil, strip @@ -461,18 +461,18 @@ (save-excursion (goto-char p) (if (looking-at c-scope-key) - (c-forward-token-1)) + (c-forward-token-1)) (let ((points (c-forward-scoped-name))) (c-backward-syntactic-ws) (buffer-substring-no-properties (car points) - (or (and strip (> strip 0) - (or (and (<= strip (length points)) - (car - (last - (nbutlast points - (1- strip))))) - (car points))) - (point)))))) + (or (and strip (> strip 0) + (or (and (<= strip (length points)) + (car + (last + (nbutlast points + (1- strip))))) + (car points))) + (point)))))) (defun c-get-class-at-point () ;; Return block scope for class at point. @@ -483,7 +483,7 @@ (c-forward-extended-sexp) (c-forward-syntactic-ws)) (and (looking-at c-class-scope-key) - (search-forward "{" nil t)) + (search-forward "{" nil t)) (last (c-get-block-scope)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -494,11 +494,11 @@ ;; cons'es of argument def ranges. (save-excursion (if (looking-at c-template-key) - (c-forward-token-1) + (c-forward-token-1) (c-forward-syntactic-ws)) (if (eq (following-char) ?<) - (c-parse-arglist (point) - (progn (c-forward-template-arglist) (point)))))) + (c-parse-arglist (point) + (progn (c-forward-template-arglist) (point)))))) (defun c-parse-arglist (start end) ;; parse arglist between START and END. The region between START end @@ -509,24 +509,24 @@ (save-excursion (goto-char start) (while (and (not (eobp)) - (< (point) end)) - (forward-char 1) - (c-forward-syntactic-ws) - (setq arg-start (point)) - (condition-case nil - (while (progn - (c-forward-extended-sexp) - (and (not (eobp)) - (< (point) end) - (not (eq (following-char) ?,))))) - (scan-error nil)) - (save-excursion - (c-backward-syntactic-ws) - (if (> (point) end) - (goto-char end)) - (if (> (point) arg-start) - (setq args (cons (cons arg-start (point)) - args)))))) + (< (point) end)) + (forward-char 1) + (c-forward-syntactic-ws) + (setq arg-start (point)) + (condition-case nil + (while (progn + (c-forward-extended-sexp) + (and (not (eobp)) + (< (point) end) + (not (eq (following-char) ?,))))) + (scan-error nil)) + (save-excursion + (c-backward-syntactic-ws) + (if (> (point) end) + (goto-char end)) + (if (> (point) arg-start) + (setq args (cons (cons arg-start (point)) + args)))))) (nreverse args))) (defun c-move-to-template-argument (start end) @@ -536,8 +536,8 @@ (forward-char -1) (goto-char end)) (while (and (>= (point) start) - (not (c-at-symbol-p)) - (not (bobp))) + (not (c-at-symbol-p)) + (not (bobp))) (c-backward-extended-sexp)) (c-at-symbol-p)) @@ -547,27 +547,27 @@ (save-excursion (c-move-to-template-argument start end) (buffer-substring-no-properties (point) - (progn - (c-forward-token-1) - (c-backward-syntactic-ws) - (point))))) + (progn + (c-forward-token-1) + (c-backward-syntactic-ws) + (point))))) (defun c-get-template-prefix (args) ;; return the template prefix for the template declared with ;; arguments ARGS (concat "<" - (mapconcat (function (lambda (x) - (c-get-template-argument-name (car x) (cdr x)))) - args - ",") - ">")) + (mapconcat (function (lambda (x) + (c-get-template-argument-name (car x) (cdr x)))) + args + ",") + ">")) (defun c-is-template-id (p) ;; return t if scoped name at P is a template_id (save-excursion (goto-char p) (if (looking-at c-scope-key) - (c-forward-token-1)) + (c-forward-token-1)) (c-forward-scoped-name) (c-backward-syntactic-ws) (eq (preceding-char) ?>))) @@ -582,13 +582,13 @@ (defun c-get-templates (scope) ;; return list of ranges of template specs in SCOPE (loop for level in scope - if (aref level 3) - collect (progn - (goto-char (aref level 3)) - (c-forward-token-1) - (c-forward-template-arglist) - (c-backward-syntactic-ws) - (cons (aref level 3) (point))))) + if (aref level 3) + collect (progn + (goto-char (aref level 3)) + (c-forward-token-1) + (c-forward-template-arglist) + (c-backward-syntactic-ws) + (cons (aref level 3) (point))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; functions to parse defuns @@ -598,24 +598,24 @@ ;; name of the current method, if any. (save-excursion (loop with last-p = (last scope) - for elem-p on scope - for elem = (car elem-p) - for next = nil then t - for last = (eq elem-p last-p) - if (and last strip (eq (aref elem 0) 'defun)) - concat (let ((name (c-scope-name (aref elem 1) 1))) - (if (> (length name) 0) - (concat (if next "::" "") name) "")) - else - concat (concat (if next "::" "") - (c-scope-name (aref elem 1)) - (if (and (aref elem 3) - (not (c-is-template-id (aref elem 1)))) - (progn - (goto-char (aref elem 3)) - (c-get-template-prefix - (c-parse-template-declaration))) - ""))))) + for elem-p on scope + for elem = (car elem-p) + for next = nil then t + for last = (eq elem-p last-p) + if (and last strip (eq (aref elem 0) 'defun)) + concat (let ((name (c-scope-name (aref elem 1) 1))) + (if (> (length name) 0) + (concat (if next "::" "") name) "")) + else + concat (concat (if next "::" "") + (c-scope-name (aref elem 1)) + (if (and (aref elem 3) + (not (c-is-template-id (aref elem 1)))) + (progn + (goto-char (aref elem 3)) + (c-get-template-prefix + (c-parse-template-declaration))) + ""))))) (defun c-parse-defun () ;; parse function definition or declaration at point. Returns a vector @@ -624,44 +624,44 @@ (c-beginning-of-defun-or-decl) (let (template type name arglist modifiers initializers body end) (if (looking-at c-template-key) - (progn - (setq template (point)) - (while (looking-at c-template-key) - (c-forward-token-1) - (c-forward-template-arglist) - (c-forward-syntactic-ws)))) + (progn + (setq template (point)) + (while (looking-at c-template-key) + (c-forward-token-1) + (c-forward-template-arglist) + (c-forward-syntactic-ws)))) (setq type (point)) (while (and (not (or (eq (following-char) ?\() - (c-crosses-statement-barrier-p type (point)))) - (let ((point (point))) - (> (progn (c-forward-balanced-token) (c-forward-syntactic-ws) (point)) point)))) + (c-crosses-statement-barrier-p type (point)))) + (let ((point (point))) + (> (progn (c-forward-balanced-token) (c-forward-syntactic-ws) (point)) point)))) (save-excursion - (c-backward-scoped-name) - (setq name (point)) - (if (eq name type) - (setq type nil))) + (c-backward-scoped-name) + (setq name (point)) + (if (eq name type) + (setq type nil))) (setq arglist (point)) (c-forward-sexp) (c-forward-syntactic-ws) (if (not (memq (following-char) '(?{ ?\; ?:))) - (progn - (setq modifiers (point)) - (while (not (or (memq (following-char) '(?{ ?\; ?:)) - (c-crosses-statement-barrier-p modifiers (point)) + (progn + (setq modifiers (point)) + (while (not (or (memq (following-char) '(?{ ?\; ?:)) + (c-crosses-statement-barrier-p modifiers (point)) (eobp))) - (c-forward-extended-sexp) - (c-forward-syntactic-ws)))) + (c-forward-extended-sexp) + (c-forward-syntactic-ws)))) (if (eq (following-char) ?:) - (progn - (setq initializers (point)) - (while (not (or (memq (following-char) '(?{ ?\;)) - (c-crosses-statement-barrier-p initializers (point)))) - (c-forward-extended-sexp) - (c-forward-syntactic-ws)))) + (progn + (setq initializers (point)) + (while (not (or (memq (following-char) '(?{ ?\;)) + (c-crosses-statement-barrier-p initializers (point)))) + (c-forward-extended-sexp) + (c-forward-syntactic-ws)))) (if (eq (following-char) ?{) - (progn - (setq body (point)) - (c-forward-sexp))) + (progn + (setq body (point)) + (c-forward-sexp))) (setq end (point)) (vector template type name arglist modifiers initializers body end)))) @@ -685,58 +685,58 @@ ;; o scope: the scope structure (as returned by c-get-block-scope) ;; for this function (save-excursion - (let ((defun (c-parse-defun)) - (scope (c-get-block-scope)) - templates type name args modifiers initializers body prototype) + (let ((defun (c-parse-defun)) + (scope (c-get-block-scope)) + templates type name args modifiers initializers body prototype) (setq templates (c-get-templates scope)) (if (aref defun 0) - (progn - (goto-char (aref defun 0)) - (while (looking-at c-template-key) - (setq templates (nconc templates - (list (cons (point) - (progn - (c-forward-token-1) - (c-forward-template-arglist) - (c-backward-syntactic-ws) - (point)))))) - (c-forward-syntactic-ws)))) + (progn + (goto-char (aref defun 0)) + (while (looking-at c-template-key) + (setq templates (nconc templates + (list (cons (point) + (progn + (c-forward-token-1) + (c-forward-template-arglist) + (c-backward-syntactic-ws) + (point)))))) + (c-forward-syntactic-ws)))) (if (aref defun 1) - (progn - (goto-char (aref defun 2)) - (c-backward-syntactic-ws) - (setq type (cons (aref defun 1) (point))))) + (progn + (goto-char (aref defun 2)) + (c-backward-syntactic-ws) + (setq type (cons (aref defun 1) (point))))) (goto-char (aref defun 3)) (c-backward-syntactic-ws) (setq name (cons (aref defun 2) (point))) (goto-char (aref defun 3)) (let ((start (point))) - (c-forward-sexp) - (setq args (c-parse-arglist start (point)))) + (c-forward-sexp) + (setq args (c-parse-arglist start (point)))) (if (aref defun 4) - (progn - (goto-char (or (aref defun 5) (aref defun 6) (aref defun 7))) - (c-backward-syntactic-ws) - (setq modifiers (cons (aref defun 4) (point))))) + (progn + (goto-char (or (aref defun 5) (aref defun 6) (aref defun 7))) + (c-backward-syntactic-ws) + (setq modifiers (cons (aref defun 4) (point))))) (if (aref defun 5) - (setq initializers (c-parse-arglist (aref defun 5) - (1+ (or (aref defun 6) - (aref defun 7)))))) + (setq initializers (c-parse-arglist (aref defun 5) + (1+ (or (aref defun 6) + (aref defun 7)))))) (if (aref defun 6) - (setq body (cons (aref defun 6) (aref defun 7)))) + (setq body (cons (aref defun 6) (aref defun 7)))) (if (not body) - (setq prototype (1+ (aref defun 7)))) - (vector templates type name args modifiers - initializers body prototype scope)))) + (setq prototype (1+ (aref defun 7)))) + (vector templates type name args modifiers + initializers body prototype scope)))) (defun c-defun-full-name (state) ;; return the full name of the defun in state - (string-replace "[ \t\n\r]+" "" - (concat (c-get-full-prefix (aref state 8)) - (if (aref state 8) "::" "") - (buffer-substring-no-properties (car (aref state 2)) - (cdr (aref state 2)))) - t)) + (string-replace "[ \t\n\r]+" "" + (concat (c-get-full-prefix (aref state 8)) + (if (aref state 8) "::" "") + (buffer-substring-no-properties (car (aref state 2)) + (cdr (aref state 2)))) + t)) (defun c-defun-short-name (state) ;; return the short name of the defun in state. This is the name of the defun @@ -745,30 +745,30 @@ (save-excursion (goto-char (cdr (aref state 2))) (if (and (eq (preceding-char) ?>) - (not (save-excursion - (re-search-backward (concat c-operator-word "\\=") nil t)))) - (c-backward-template-arglist)) + (not (save-excursion + (re-search-backward (concat c-operator-word "\\=") nil t)))) + (c-backward-template-arglist)) (c-backward-syntactic-ws) (setq p (point)) (if (re-search-backward (concat c-operator-word "\\=") nil t) - (goto-char (match-beginning 0)) - (c-backward-token-1) - (if (and (c-at-symbol-p) - (eq (preceding-char) ?~)) - (forward-char -1))) + (goto-char (match-beginning 0)) + (c-backward-token-1) + (if (and (c-at-symbol-p) + (eq (preceding-char) ?~)) + (forward-char -1))) (buffer-substring-no-properties p (point))))) (defun c-goto-beginning-of-defun (defun) (goto-char (or (car (aref defun 1)) - (car (aref defun 2)))) + (car (aref defun 2)))) (loop for point = (point) - for tmpl in (reverse (aref defun 0)) - do (c-backward-syntactic-ws) - while (= (cdr tmpl) (point)) - do (progn - (goto-char (car tmpl)) - (setq point (point))) - finally do (goto-char point))) + for tmpl in (reverse (aref defun 0)) + do (c-backward-syntactic-ws) + while (= (cdr tmpl) (point)) + do (progn + (goto-char (car tmpl)) + (setq point (point))) + finally do (goto-char point))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; functions to parse classes @@ -781,128 +781,131 @@ ;; variable declaration) (save-excursion (let ((scope (car (last scope))) - end template class bases start members) + end template class bases start members) (if (not (eq (aref scope 0) 'class)) - nil - (setq template (aref scope 3)) - (setq class (aref scope 1)) - (setq start (aref scope 2)) - (goto-char start) - (while (and (< (skip-chars-backward "^:" class) 0) - (or (progn - (forward-char -1) - (and (eq (char-before) ?:) (progn (forward-char -1) t))) - (c-in-literal)))) - (if (eq (following-char) ?:) - (progn - (forward-char 1) - (c-forward-syntactic-ws) - (setq bases (point)))) - (goto-char start) - (save-excursion - (c-forward-sexp) - (setq end (point))) - (forward-char 1) - (while (progn (c-end-of-statement) - (< (point) end)) - (let ((bc (char-before)) - (this (point))) - (if (eq bc ?{) - (save-excursion - (forward-char -1) - (c-forward-sexp) - (setq this (point)))) - (if (or (eq bc ?\;) (eq bc ?{)) - (progn - (forward-char -1) - (if (re-search-backward "=\\s-*0\\s-*\\=" start t) - (goto-char (match-beginning 0))) - (if (c-just-after-func-arglist-p) - ;; OK. It's a method (defn or decl) - (progn - (c-beginning-of-statement-1) - (setq members (cons (cons 'method (point)) - members))) - (if (eq bc ?{) - ;; this should be a class or struct decl. Maybe - ;; a variable. - (let (pos decl beg) - (setq pos (point)) - (c-beginning-of-statement-1) - (setq beg (point)) - (if (looking-at c-class-scope-key) - ;; it really IS a class/struct/union - (progn - (goto-char (match-end 0)) - (c-forward-syntactic-ws) - (setq decl (looking-at "[a-zA-Z_]")) - (goto-char pos) - (c-forward-sexp) - (c-forward-syntactic-ws) - (if (eq (following-char) ?\;) - ;; no variable defn - (if decl - (setq members (cons (cons 'class beg) - members))) - (save-excursion - (goto-char this) - (c-end-of-statement) - (setq this (point))) - (setq members (cons (cons (if decl 'combo 'variable) - beg) - members)))))) - ;; then it's a variable decl or typedef or friend - (c-beginning-of-statement-1) - (cond ((looking-at c-typedef-key) - (setq members (cons (cons 'typedef (point)) members))) - ((looking-at c-friend-key) - (setq members (cons (cons 'friend (point)) members))) - (t - (setq members (cons (cons 'variable (point)) members)))) - )))) - (goto-char this))) - (vector template class bases start (nreverse members)))))) + nil + (setq template (aref scope 3)) + (setq class (aref scope 1)) + (setq start (aref scope 2)) + (goto-char start) + (while (and (< (skip-chars-backward "^:" class) 0) + (or (progn + (forward-char -1) + (and (eq (char-before) ?:) (progn (forward-char -1) t))) + (c-in-literal)))) + (if (eq (following-char) ?:) + (progn + (forward-char 1) + (c-forward-syntactic-ws) + (setq bases (point)))) + (goto-char start) + (save-excursion + (c-forward-sexp) + (setq end (point))) + (forward-char 1) + (while (progn (c-end-of-statement) + (< (point) end)) + (let ((bc (char-before)) + (this (point))) + (if (eq bc ?{) + ;; ??? + (save-excursion + (forward-char -1) + (c-forward-sexp) + (setq this (point)))) + (if (or (eq bc ?\;) (eq bc ?{) (save-excursion (c-just-after-func-arglist-p))) + (progn + ;;(forward-char -1) + (if (re-search-backward "=\\s-*0\\s-*\\=" start t) + (goto-char (match-beginning 0))) + (if (save-excursion (c-just-after-func-arglist-p)) + ;; OK. It's a method (defn or decl) + (progn + (c-beginning-of-statement-1) + (setq members (cons (cons 'method (point)) + members))) + (if (eq bc ?{) + ;; this should be a class or struct decl. Maybe + ;; a variable. + (let (pos decl beg) + (setq pos (point)) + (c-beginning-of-statement-1) + (setq beg (point)) + (if (looking-at c-class-scope-key) + ;; it really IS a class/struct/union + (progn + (goto-char (match-end 0)) + (c-forward-syntactic-ws) + (setq decl (looking-at "[a-zA-Z_]")) + (goto-char pos) + (c-forward-sexp) + (c-forward-syntactic-ws) + (if (eq (following-char) ?\;) + ;; no variable defn + (if decl + (setq members (cons (cons 'class beg) + members))) + (save-excursion + (goto-char this) + (c-end-of-statement) + (setq this (point))) + (setq members (cons (cons (if decl 'combo 'variable) + beg) + members)))))) + ;; then it's a variable decl or typedef or friend + (c-beginning-of-statement-1) + (cond ((looking-at c-typedef-key) + (setq members (cons (cons 'typedef (point)) members))) + ((looking-at c-friend-key) + (setq members (cons (cons 'friend (point)) members))) + (t + (setq members (cons (cons 'variable (point)) members)))) )))) + (goto-char this) + (c-forward-syntactic-ws) + (if (looking-at "{") + (c-forward-sexp)))) + (vector template class bases start (nreverse members)))))) (defun c-current-access-level () ;; returm current access level: 'public, 'protected or 'private (save-excursion (let ((scope (car (last (c-get-block-scope))))) (while (and (re-search-backward c-access-key (aref scope 2) t) - (or (c-in-literal) - (not (eq (aref (car (c-get-block-scope)) 1) (aref scope 1)))))) + (or (c-in-literal) + (not (eq (aref (car (c-get-block-scope)) 1) (aref scope 1)))))) (loop for (re . sym) in c-access-keys - if (looking-at re) - return sym - finally return (progn - (goto-char (aref scope 1)) - (if (looking-at c-struct-scope-key) - 'public - 'private)))))) + if (looking-at re) + return sym + finally return (progn + (goto-char (aref scope 1)) + (if (looking-at c-struct-scope-key) + 'public + 'private)))))) (defun c-get-variable-members (class) ;; return list of names of all variables of CLASS (save-excursion (loop for (type . pos) in (aref class 4) - for end = (progn (goto-char pos) (c-end-of-statement) (1- (point))) - if (or (eq type 'variable) (eq type 'combo)) - collect (c-get-template-argument-name pos end)))) + for end = (progn (goto-char pos) (c-end-of-statement) (1- (point))) + if (or (eq type 'variable) (eq type 'combo)) + collect (c-get-template-argument-name pos end)))) (defun c-get-variable-members-with-type (class) ;; return list of conses of (name . type) of all variables of CLASS (save-excursion (loop for (type . pos) in (aref class 4) - for end = (progn (goto-char pos) (c-end-of-statement) (1- (point))) - if (eq type 'variable) - collect (c-get-variable-with-type pos end)))) + for end = (progn (goto-char pos) (c-end-of-statement) (1- (point))) + if (eq type 'variable) + collect (c-get-variable-with-type pos end)))) (defun c-get-variable-with-type (start end) (c-move-to-template-argument start end) (let ((arg (save-excursion - (buffer-substring-no-properties (point) - (progn - (c-forward-token-1) - (c-backward-syntactic-ws) - (point)))))) + (buffer-substring-no-properties (point) + (progn + (c-forward-token-1) + (c-backward-syntactic-ws) + (point)))))) (c-backward-syntactic-ws) (cons arg (buffer-substring-no-properties start (point))))) @@ -910,20 +913,20 @@ ;; return list of base class names (including template specs) (and (aref class 2) (save-excursion - (goto-char (aref class 2)) - (loop while (< (point) (aref class 3)) - do (progn (c-forward-syntactic-ws) - (while (looking-at c-inheritance-spec-key) - (c-forward-token-1) - (c-forward-syntactic-ws))) - for start = (point) - do (progn (c-forward-scoped-name) (c-backward-syntactic-ws)) - collect (buffer-substring-no-properties start (point)) - do (progn - (while (and (> (skip-chars-forward "^," (aref class 3)) 0) - (c-in-literal)) - (forward-char 1)) - (forward-char 1)))))) + (goto-char (aref class 2)) + (loop while (< (point) (aref class 3)) + do (progn (c-forward-syntactic-ws) + (while (looking-at c-inheritance-spec-key) + (c-forward-token-1) + (c-forward-syntactic-ws))) + for start = (point) + do (progn (c-forward-scoped-name) (c-backward-syntactic-ws)) + collect (buffer-substring-no-properties start (point)) + do (progn + (while (and (> (skip-chars-forward "^," (aref class 3)) 0) + (c-in-literal)) + (forward-char 1)) + (forward-char 1)))))) (provide 'cc-engine-2) diff --git a/cc-ide/cc-ide.el b/cc-ide/cc-ide.el index 3ba3b3c..6bf988a 100644 --- a/cc-ide/cc-ide.el +++ b/cc-ide/cc-ide.el @@ -51,18 +51,18 @@ correctly included.") (defvar ccide-gen-throw nil "*If non-nil, generate throw_ specs") -(defvar ccide-project-root) +(defvar ccide-project-root nil) -(defvar ccide-new-file-hook) +(defvar ccide-new-file-hook nil) (defconst c-user-prefix-re (regexp-opt c-user-prefixes t)) -(defconst ccide-doxy-tag-re +(defconst ccide-doxy-tag-re (concat "\\\\\\(group\\|defgroup\\|see\\|author\\|version\\|id\\|since" - "\\|returns?\\|throws?\\|exception\\|raises\\|param\\|li\\|brief" - "\\|internal\\|bug\\|fixme\\|todo\\|idea\\|implementation" - "\\|note\\|attention\\|warning\\|par\\|code\\|endcode" - "\\|post\\|pre\\|deprecated\\)\\b")) + "\\|returns?\\|throws?\\|exception\\|raises\\|param\\|li\\|brief" + "\\|internal\\|bug\\|fixme\\|todo\\|idea\\|implementation" + "\\|note\\|attention\\|warning\\|par\\|code\\|endcode" + "\\|post\\|pre\\|deprecated\\)\\b")) (defconst ccide-special-extensions '(".h" ".hh" ".mpp" ".ih" ".cc" ".cpp" ".ct" ".cti" ".cci" ".dox")) @@ -70,28 +70,28 @@ correctly included.") (defconst ccide-implementation-extensions '(".h" ".hh" ".ih" ".cc" ".cpp" ".ct" ".cti" ".cci")) -(defconst ccide-class-defaults-word +(defconst ccide-class-defaults-word "// \\(default\\|no\\|protected\\|private\\|disabled\\|my\\)") (defconst ccide-bindings '( ;; file level - ("fc" ccide-file-comment "File comment") - ("fs" ccide-syncronize-includes "Sync includes") - (nil nil separator) - - ;; class level - ("cc" ccide-class-comment "Class comment") - ("cg" ccide-gen-class "Generate class") - ("cd" ccide-gen-class-defaults "Generate class defaults") + ("fc" ccide-file-comment "File comment") + ("fs" ccide-syncronize-includes "Sync includes") + (nil nil separator) + + ;; class level + ("cc" ccide-class-comment "Class comment") + ("cg" ccide-gen-class "Generate class") + ("cd" ccide-gen-class-defaults "Generate class defaults") ("cD" ccide-gen-class-defaults-impl "Generate class defaults impl") ("csd" ccide-set-class-defaults-default "Set class defaults comment" "Default") - ("csn" ccide-set-class-defaults-no "Set class defaults comment" "No") + ("csn" ccide-set-class-defaults-no "Set class defaults comment" "No") ("csp" ccide-set-class-defaults-protected "Set class defaults comment" "Protected") ("csr" ccide-set-class-defaults-private "Set class defaults comment" "Private") ("csx" ccide-set-class-defaults-disabled "Set class defaults comment" "Disabled") - ("csm" ccide-set-class-defaults-my "Set class defaults comment" "My") + ("csm" ccide-set-class-defaults-my "Set class defaults comment" "My") ("cS" ccide-gen-struct-constructors "Generate structure constructors") @@ -99,39 +99,39 @@ correctly included.") ("ce" ccide-gen-exception "Generate an exception class") - (nil nil separator) - - ;; method level - ("mc" ccide-function-comment "Method comment") - ("mp" ccide-grab-prototype "Grab prototype") - ("mr" ccide-reformat-defun "Reformat defun") - ("mx" ccide-replace-defun "Replace defun") + (nil nil separator) + + ;; method level + ("mc" ccide-function-comment "Method comment") + ("mp" ccide-grab-prototype "Grab prototype") + ("mr" ccide-reformat-defun "Reformat defun") + ("mx" ccide-replace-defun "Replace defun") ("mt" ccide-prefix-defun-type-with-class "Prefix defun type with class") ("mn" ccide-prefix-defun-type-with-namespace "Prefix defun type with namespace") - ("mi" ccide-grab-inline-decl "Grab inline decl") + ("mi" ccide-grab-inline-decl "Grab inline decl") ("mA" ccide-grab-all-inlines "Grab ALL inline decls") ("mC" ccide-grab-create-constructor "Grab CREATE constructor") ("mI" ccide-grab-create-constructor-impl "Build CREATE cosntructor") ("mf" ccide-find-implementation "Find method implementation") ("mT" ccide-insert-defun-prefix "Insert current defun prefix at point") - (nil nil separator) - - ;; variable level - ("vc" ccide-variable-comment "Variable comment") - ("vf" ccide-grab-access-fn "Grab access methods") - (nil nil separator) + (nil nil separator) + + ;; variable level + ("vc" ccide-variable-comment "Variable comment") + ("vf" ccide-grab-access-fn "Grab access methods") + (nil nil separator) ;; documentation ("h" ccide-hide-all-doxy-comments "Hide all Doxygen comments") ("s" ccide-show-all-comments "Show all Doxygen comments") - -; ;; CORBA -; ("Cg" ccide-gen-corba-impl "Generate CORBA impl") + +; ;; CORBA +; ("Cg" ccide-gen-corba-impl "Generate CORBA impl") ; ("Cm" ccide-gen-corba-impl-methods "Generate CORBA impl methods") -; (nil nil separator) - - ;; templates -; ("ts" ccide-scan-mantemps "Scan mantemps") +; (nil nil separator) + + ;; templates +; ("ts" ccide-scan-mantemps "Scan mantemps") ; (nil nil separator) ; ;; other @@ -165,47 +165,47 @@ correctly included.") (defun ccide-file-macro-name (&optional file-name) (concat (upcase (file-name-extension (or file-name (buffer-file-name)))) - "_" - (if ccide-project-name (concat ccide-project-name "_") "") - (if ccide-project-root - (string-replace "/" "_" - (substring (file-name-directory - (expand-file-name (or file-name buffer-file-name))) - (length ccide-project-root)) - t) - "") - (string-replace "\\." "_" (file-name-sans-extension - (file-name-nondirectory + "_" + (if ccide-project-name (concat ccide-project-name "_") "") + (if ccide-project-root + (string-replace "/" "_" + (substring (file-name-directory + (expand-file-name (or file-name buffer-file-name))) + (length ccide-project-root)) + t) + "") + (string-replace "\\." "_" (file-name-sans-extension + (file-name-nondirectory (or file-name (buffer-file-name)))) t nil t t) "_")) (defun ccide-file-name (&optional extension file-name directory) (concat (if directory (file-name-as-directory directory) "") - (file-name-sans-extension - (file-name-nondirectory - (or file-name (buffer-file-name)))) - extension)) + (file-name-sans-extension + (file-name-nondirectory + (or file-name (buffer-file-name)))) + extension)) (defun ccide-in-doxy-comment () (save-excursion (back-to-indentation) (let ((lit (c-in-literal))) (when (and (memq lit '(c c++)) - (progn (goto-char (car (c-literal-limits))) - (looking-at "/\\(\\*\\*\\|///\\)\n" "#include \n\n" - "#define prefix_\n" - "///////////////////////////////cc.p////////////////////////////////////////\n\n") - (setq point (point)) - (goto-char (point-max)) - (insert "\n\n///////////////////////////////cc.e////////////////////////////////////////\n" - "#undef prefix_")) - - ((or (string-match "\\.cc$" (buffer-file-name)) - (string-match "\\.cpp$" (buffer-file-name))) - (insert "/** \\file\n" - " \\brief " (ccide-file-name) " non-inline non-template implementation */\n\n" - (if ccide-all-includes "" "//") - "#include \"" (or ccide-all-includes (ccide-file-name ".hh")) "\"\n" - "//#include \"" (ccide-file-name ".ih") "\"\n\n" + "#define prefix_\n" + "//-/////////////////////////////////////////////////////////////////////////////////////////////////\n\n") + (setq point (point)) + (goto-char (point-max)) + (insert "\n\n//-/////////////////////////////////////////////////////////////////////////////////////////////////\n" + "#undef prefix_")) + + ((or (string-match "\\.cc$" (buffer-file-name)) + (string-match "\\.cpp$" (buffer-file-name))) + (insert "/** \\file\n" + " \\brief " (ccide-file-name) " non-inline non-template implementation */\n\n" + (if ccide-all-includes "" "//") + "#include \"" (or ccide-all-includes (ccide-file-name ".hh")) "\"\n" + "//#include \"" (ccide-file-name ".ih") "\"\n\n" "// Custom includes\n\n" "//#include \"" (ccide-file-name ".mpp") "\"\n" - "#define prefix_\n" - "///////////////////////////////cc.p////////////////////////////////////////\n\n") - (setq point (point)) - (goto-char (point-max)) - (insert "\n\n///////////////////////////////cc.e////////////////////////////////////////\n" - "#undef prefix_\n" + "#define prefix_\n" + "//-/////////////////////////////////////////////////////////////////////////////////////////////////\n\n") + (setq point (point)) + (goto-char (point-max)) + (insert "\n\n//-/////////////////////////////////////////////////////////////////////////////////////////////////\n" + "#undef prefix_\n" "//#include \"" (ccide-file-name ".mpp") "\"")) - ((string-match "\\.cci$" (buffer-file-name)) - (insert "/** \\file\n" - " \\brief " (ccide-file-name) " inline non-template implementation */\n\n" - "//#include \"" (ccide-file-name ".ih") "\"\n\n" + ((string-match "\\.cci$" (buffer-file-name)) + (insert "/** \\file\n" + " \\brief " (ccide-file-name) " inline non-template implementation */\n\n" + "//#include \"" (ccide-file-name ".ih") "\"\n\n" "// Custom includes\n\n" - "#define prefix_ inline\n" - "///////////////////////////////cci.p///////////////////////////////////////\n\n") - (setq point (point)) - (goto-char (point-max)) - (insert "\n\n///////////////////////////////cci.e///////////////////////////////////////\n" - "#undef prefix_")) - - ((string-match "\\.ct$" (buffer-file-name)) - (insert "/** \\file\n" - " \\brief " (ccide-file-name) " non-inline template implementation */\n\n" - "//#include \"" (ccide-file-name ".ih") "\"\n\n" + "#define prefix_ inline\n" + "//-/////////////////////////////////////////////////////////////////////////////////////////////////\n\n") + (setq point (point)) + (goto-char (point-max)) + (insert "\n\n//-/////////////////////////////////////////////////////////////////////////////////////////////////\n" + "#undef prefix_")) + + ((string-match "\\.ct$" (buffer-file-name)) + (insert "/** \\file\n" + " \\brief " (ccide-file-name) " non-inline template implementation */\n\n" + "//#include \"" (ccide-file-name ".ih") "\"\n\n" "// Custom includes\n\n" - "#define prefix_\n" - "///////////////////////////////ct.p////////////////////////////////////////\n\n") - (setq point (point)) - (goto-char (point-max)) - (insert "\n\n///////////////////////////////ct.e////////////////////////////////////////\n" - "#undef prefix_")) - - ((string-match "\\.cti$" (buffer-file-name)) - (insert "/** \\file\n" - " \\brief " (ccide-file-name) " inline template implementation */\n\n" - "//#include \"" (ccide-file-name ".ih") "\"\n\n" + "#define prefix_\n" + "//-/////////////////////////////////////////////////////////////////////////////////////////////////\n\n") + (setq point (point)) + (goto-char (point-max)) + (insert "\n\n//-/////////////////////////////////////////////////////////////////////////////////////////////////\n" + "#undef prefix_")) + + ((string-match "\\.cti$" (buffer-file-name)) + (insert "/** \\file\n" + " \\brief " (ccide-file-name) " inline template implementation */\n\n" + "//#include \"" (ccide-file-name ".ih") "\"\n\n" "// Custom includes\n\n" - "#define prefix_ inline\n" - "///////////////////////////////cti.p///////////////////////////////////////\n\n") - (setq point (point)) - (goto-char (point-max)) - (insert "\n\n///////////////////////////////cti.e///////////////////////////////////////\n" - "#undef prefix_")) - - ((string-match "\\.dox$" (buffer-file-name)) - (insert "/** \\mainpage\n\n ") - (setq point (point)) - (insert "\n */") - (setq add-file-vars '(( mode . flyspell) - ( mode . auto-fill)))) - - ((string-match "\\.java$" (buffer-file-name)) - (setq mode "jde") - (setq point (point)) - (goto-char (point-max))) - - (t - (setq point (point)) - (goto-char (point-max)))) + "#define prefix_ inline\n" + "//-/////////////////////////////////////////////////////////////////////////////////////////////////\n\n") + (setq point (point)) + (goto-char (point-max)) + (insert "\n\n//-/////////////////////////////////////////////////////////////////////////////////////////////////\n" + "#undef prefix_")) + + ((string-match "\\.dox$" (buffer-file-name)) + (insert "/** \\mainpage\n\n ") + (setq point (point)) + (insert "\n */") + (setq add-file-vars '(( mode . flyspell) + ( mode . auto-fill)))) + + ((string-match "\\.java$" (buffer-file-name)) + (setq mode "jde") + (setq point (point)) + (goto-char (point-max))) + + (t + (setq point (point)) + (goto-char (point-max)))) (insert "\n\n \n" - "// Local Variables:\n" - "// mode: " mode "\n") + "// Local Variables:\n" + "// mode: " mode "\n") (loop for (var . value) in ccide-file-vars - do (insert "// " (symbol-name var) ": " (prin1-to-string value) "\n")) + do (insert "// " (symbol-name var) ": " (prin1-to-string value) "\n")) (loop for (var . value) in add-file-vars - do (insert "// " (symbol-name var) ": " (prin1-to-string value) "\n")) + do (insert "// " (symbol-name var) ": " (prin1-to-string value) "\n")) (insert "// End:\n") (if point - (goto-char point)) + (goto-char point)) (if (equal mode "jde") (let ((package (file-name-directory (buffer-file-name)))) (jdeap-initialize-setup) (if (not (equal jdeap-current-source-directory ".")) - (if (string-match + (if (string-match (concat "^" (regexp-quote jdeap-current-source-directory)) package) (progn - (setq package (substring package + (setq package (substring package (match-end 0) (1- (length package)))) (insert "package " (string-replace "/" "." package t) ";\n\n")))) (insert "class " (file-name-sans-extension - (file-name-nondirectory + (file-name-nondirectory (buffer-file-name))) "\n{}") (beginning-of-line)))) (run-hooks 'ccide-new-file-hooks)) @@ -413,70 +413,70 @@ correctly included.") (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) (let ((case-fold-search t)) (if (search-forward "Local Variables:" nil t) - (let (prefix suffix vars) - (skip-chars-forward " \t") - (or (eolp) - (setq suffix (buffer-substring (point) (progn (end-of-line) (point))))) - (goto-char (match-beginning 0)) - (or (bolp) - (setq prefix (buffer-substring (point) (progn (beginning-of-line) (point))))) - (loop do (progn - (forward-line 1) - (if (and prefix (looking-at prefix)) - (goto-char (match-end 0))) - (skip-chars-forward " \t")) - while (not (looking-at "end:")) - do (progn - (setq vars (cons (intern (buffer-substring - (point) - (progn (skip-chars-forward "^:\n") (point)))) - vars)))) - (beginning-of-line) - (loop for (var . value) in ccide-file-vars - do (if (not (memq var vars)) - (insert (or prefix "") - (symbol-name var) ": " (prin1-to-string value) - (or suffix "") "\n")))))))) + (let (prefix suffix vars) + (skip-chars-forward " \t") + (or (eolp) + (setq suffix (buffer-substring (point) (progn (end-of-line) (point))))) + (goto-char (match-beginning 0)) + (or (bolp) + (setq prefix (buffer-substring (point) (progn (beginning-of-line) (point))))) + (loop do (progn + (forward-line 1) + (if (and prefix (looking-at prefix)) + (goto-char (match-end 0))) + (skip-chars-forward " \t")) + while (not (looking-at "end:")) + do (progn + (setq vars (cons (intern (buffer-substring + (point) + (progn (skip-chars-forward "^:\n") (point)))) + vars)))) + (beginning-of-line) + (loop for (var . value) in ccide-file-vars + do (if (not (memq var vars)) + (insert (or prefix "") + (symbol-name var) ": " (prin1-to-string value) + (or suffix "") "\n")))))))) (defun ccide-syncronize-includes () "Syncronize include's in all other files" (interactive) (let (buffer-map) (loop for extension in ccide-special-extensions - for file-name = (ccide-file-name extension) - do (setq buffer-map - (cons (cons file-name - (or (find-buffer-visiting file-name) - (and (file-readable-p file-name) - (find-file-noselect file-name)))) - buffer-map))) + for file-name = (ccide-file-name extension) + do (setq buffer-map + (cons (cons file-name + (or (find-buffer-visiting file-name) + (and (file-readable-p file-name) + (find-file-noselect file-name)))) + buffer-map))) (save-excursion (loop for buffer in buffer-map - if (cdr buffer) - do (progn - (set-buffer (cdr buffer)) - (save-excursion - (loop for include in buffer-map - do (progn - (goto-char (point-min)) - (while (re-search-forward - (concat "^\\(//\\)?#\\s-*include \"" - (regexp-quote (car include)) - "\"\\s-*$") - nil t) - (goto-char (match-beginning 0)) - (if (looking-at "//") - (if (cdr include) - (delete-char 2)) - (if (not (cdr include)) - (insert "//"))) - (forward-line 1)))))))))) + if (cdr buffer) + do (progn + (set-buffer (cdr buffer)) + (save-excursion + (loop for include in buffer-map + do (progn + (goto-char (point-min)) + (while (re-search-forward + (concat "^\\(//\\)?#\\s-*include \"" + (regexp-quote (car include)) + "\"\\s-*$") + nil t) + (goto-char (match-beginning 0)) + (if (looking-at "//") + (if (cdr include) + (delete-char 2)) + (if (not (cdr include)) + (insert "//"))) + (forward-line 1)))))))))) (defun ccide-auto-decorate-new-files () (if (and (buffer-file-name) (= (point-min) (point-max))) (let ((status (buffer-modified-p))) - (ccide-file-comment) - (set-buffer-modified-p status)))) + (ccide-file-comment) + (set-buffer-modified-p status)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; class level @@ -486,21 +486,21 @@ correctly included.") (interactive) (let ((class (c-get-class-at-point))) (if (not class) - (error "No class found") + (error "No class found") (goto-char (or (aref (car class) 3) - (aref (car class) 1))) - (if (save-excursion - (forward-line -1) - (ccide-in-doxy-comment)) - (progn - (search-backward "/**" nil t) - (forward-char 4)) - (let ((indent (make-string (current-indentation) ? ))) - (insert "/** \\brief ") - (save-excursion - (insert "\n" - indent " */\n" - indent))))))) + (aref (car class) 1))) + (if (save-excursion + (forward-line -1) + (ccide-in-doxy-comment)) + (progn + (search-backward "/**" nil t) + (forward-char 4)) + (let ((indent (make-string (current-indentation) ? ))) + (insert "/** \\brief ") + (save-excursion + (insert "\n" + indent " */\n" + indent))))))) (defun ccide-gen-class (name &optional defns) "Generate class declaration template" @@ -511,7 +511,8 @@ correctly included.") (insert "class " name) (indent-according-to-mode) (let ((in (make-string c-basic-offset ? )) - (ofs (make-string (current-indentation) ? ))) + (ofs (make-string (current-indentation) ? )) + (sl (make-string (- 100 3 c-basic-offset (current-indentation)) ?/))) (save-excursion (beginning-of-line) (open-line 1) @@ -520,87 +521,87 @@ correctly included.") (insert "\n" ofs) (save-excursion (insert "{\n" - ofs "public:\n" - ofs in "///////////////////////////////////////////////////////////////////////////\n" + ofs "public:\n" + ofs in "//-" sl "\n" ofs in "// Types\n\n" - ofs in "///////////////////////////////////////////////////////////////////////////\n" + ofs in "//-" sl "\n" ofs in "///\\name Structors and default members\n" - ofs in "///@{\n\n" - ofs in "// default default constructor\n" - ofs in "// default copy constructor\n" - ofs in "// default copy assignment\n" - ofs in "// default destructor\n\n" + ofs in "//\\{\n\n" + ofs in "// default default constructor\n" + ofs in "// default copy constructor\n" + ofs in "// default copy assignment\n" + ofs in "// default destructor\n\n" ofs in "// no conversion constructors\n\n" - ofs in "///@}\n" - ofs in "///////////////////////////////////////////////////////////////////////////\n" + ofs in "//\\}\n" + ofs in "//-" sl "\n" ofs in "///\\name Accessors\n" - ofs in "///@{\n\n" - ofs in "///@}\n" - ofs in "///////////////////////////////////////////////////////////////////////////\n" + ofs in "//\\{\n\n" + ofs in "//\\}\n" + ofs in "//-" sl "\n" ofs in "///\\name Mutators\n" - ofs in "///@{\n\n" - ofs in "///@}\n\n") + ofs in "//\\{\n\n" + ofs in "//\\}\n\n") (loop for defn in defns - do (insert ofs in defn ";\n")) + do (insert ofs in defn ";\n")) (if defns - (insert "\n")) + (insert "\n")) (insert ofs "protected:\n\n" - ofs "private:\n\n" - ofs "};\n")))) + ofs "private:\n\n" + ofs "};\n")))) (defun ccide-gen-class-defaults () "Generate signatures of the default functions: default constructor, copy constructor, assignment operator and destructor." (indent-according-to-mode) (let* ((name (c-scope-name (aref (car (c-get-class-at-point)) 1))) - (in (make-string c-basic-offset ? )) - (ofs (make-string (current-indentation) ? )) - (tspec (if ccide-gen-throw (concat "\n" ofs in "throw_(());\n") ";\n")) - (colon 0)) + (in (make-string c-basic-offset ? )) + (ofs (make-string (current-indentation) ? )) + (tspec (if ccide-gen-throw (concat "\n" ofs in "throw_(());\n") ";\n")) + (colon 0)) (while (string-match "::" name colon) (setq colon (match-end 0))) (setq name (substring name colon)) (beginning-of-line) (delete-horizontal-space) (loop with exit = nil - do (message (concat "1-dflt constr, 2-destr, " - "3-copy constr, 4-copy assmnt, " - "c-all copy, d-all dflt, RET-all/done: ")) - for ch = (read-event) - for first = t then nil - do (cond ((eq ch 'return) - (if first - (insert ofs name "()" - tspec - ofs name "(const " name "& other)" - tspec - ofs "~" name "();\n" - ofs name "& operator=(const " name "& other)" - tspec)) - (setq exit t)) - ((eq ch ?1) - (insert ofs name "()" - tspec)) - ((eq ch ?2) - (insert ofs "~" name "();\n")) - ((eq ch ?3) - (insert ofs name "(const " name "& other)" - tspec)) - ((eq ch ?4) - (insert ofs name "& operator=(const " name "& other)" - tspec)) - ((eq ch ?c) - (insert ofs name "(const " name "& other)" - tspec - ofs name "& operator=(const " name "& other)" - tspec)) - ((eq ch ?d) - (insert ofs name "()" - tspec - ofs "~" name "();\n")) - (t (setq unread-command-events (cons ch unread-command-events)) - (setq exit t))) - while (not exit)))) + do (message (concat "1-dflt constr, 2-destr, " + "3-copy constr, 4-copy assmnt, " + "c-all copy, d-all dflt, RET-all/done: ")) + for ch = (read-event) + for first = t then nil + do (cond ((eq ch 'return) + (if first + (insert ofs name "()" + tspec + ofs name "(const " name "& other)" + tspec + ofs "~" name "();\n" + ofs name "& operator=(const " name "& other)" + tspec)) + (setq exit t)) + ((eq ch ?1) + (insert ofs name "()" + tspec)) + ((eq ch ?2) + (insert ofs "~" name "();\n")) + ((eq ch ?3) + (insert ofs name "(const " name "& other)" + tspec)) + ((eq ch ?4) + (insert ofs name "& operator=(const " name "& other)" + tspec)) + ((eq ch ?c) + (insert ofs name "(const " name "& other)" + tspec + ofs name "& operator=(const " name "& other)" + tspec)) + ((eq ch ?d) + (insert ofs name "()" + tspec + ofs "~" name "();\n")) + (t (setq unread-command-events (cons ch unread-command-events)) + (setq exit t))) + while (not exit)))) (defun ccide-gen-class-defaults-impl () "Generate default implementations for class default functions" @@ -613,12 +614,12 @@ copy constructor, assignment operator and destructor." (save-excursion (back-to-indentation) (if (not (looking-at ccide-class-defaults-word)) - (message "Not at class defaults commnet") + (message "Not at class defaults commnet") (replace-match word t t nil 1)))) (defmacro ccide-build-class-defaults-f (sym) - (let ((fn (intern (concat "ccide-set-class-defaults-" - (symbol-name sym))))) + (let ((fn (intern (concat "ccide-set-class-defaults-" + (symbol-name sym))))) `(defun ,fn () (interactive) (ccide-set-class-defaults-comment ,(symbol-name sym))))) @@ -636,28 +637,28 @@ copy constructor, assignment operator and destructor." (open-line 1) (indent-according-to-mode) (let* ((scope (c-get-block-scope)) - (class (c-parse-class scope)) - (variables (c-get-variable-members-with-type class)) - (name (c-scope-name (aref (car (last scope)) 1))) - (in (make-string (current-indentation) ? )) - (inin (make-string (+ (current-indentation) c-basic-offset) ? ))) + (class (c-parse-class scope)) + (variables (c-get-variable-members-with-type class)) + (name (c-scope-name (aref (car (last scope)) 1))) + (in (make-string (current-indentation) ? )) + (inin (make-string (+ (current-indentation) c-basic-offset) ? ))) (insert name "()\n" inin ": ") (indent-according-to-mode) (loop for var in variables - for first = t then nil - if (not first) do (insert ", ") - do (insert (car var) "()")) + for first = t then nil + if (not first) do (insert ", ") + do (insert (car var) "()")) (insert "\n" in "{}\n" - in name "(") + in name "(") (loop for var in variables - for first = t then nil - if (not first) do (insert ", ") - do (insert (cdr var) " " (car var) "_")) + for first = t then nil + if (not first) do (insert ", ") + do (insert (cdr var) " " (car var) "_")) (insert ")\n" inin ": ") (loop for var in variables - for first = t then nil - if (not first) do (insert ", ") - do (insert (car var) "(" (car var) "_)")) + for first = t then nil + if (not first) do (insert ", ") + do (insert (car var) "(" (car var) "_)")) (insert "\n" in "{}")))) (defun ccide-class-impl-comment () @@ -678,21 +679,21 @@ copy constructor, assignment operator and destructor." (indent-according-to-mode) (save-excursion (let ((in (make-string c-basic-offset ? )) - (ofs (make-string (current-indentation) ? )) - (prefix (c-get-full-prefix (c-get-block-scope))) - p) + (ofs (make-string (current-indentation) ? )) + (prefix (c-get-full-prefix (c-get-block-scope))) + p) (insert "struct " class " : public std::exception\n" - ofs "{ virtual char const * what() const throw() ") + ofs "{ virtual char const * what() const throw() ") (setq p (point)) - (insert "{ return \"" - (if (and description (> (length description) 0)) - description - (concat prefix "::" class)) - "\"; } };") + (insert "{ return \"" + (if (and description (> (length description) 0)) + description + (concat prefix "::" class)) + "\"; } };") (if (> (current-column) fill-column) - (save-excursion - (goto-char p) - (insert "\n" ofs in in)))))) + (save-excursion + (goto-char p) + (insert "\n" ofs in in)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; function/method level @@ -703,136 +704,136 @@ copy constructor, assignment operator and destructor." (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-forward-out-of-comment) + (c-backward-syntactic-ws) + (c-backward-sexp)) (beginning-of-line)) (c-beginning-of-defun-or-decl) (let ((defun (c-get-defun-state)) - (indent (make-string comment-column ? )) - place) + (indent (make-string comment-column ? )) + place) (goto-char (or (aref defun 7) (car (aref defun 6)))) (c-backward-syntactic-ws) (if (looking-at "[ \t\n\r]*///<") - (progn - (delete-region (point) (progn (skip-chars-forward " \t\n\r") (point))) - (if (> (current-column) comment-column) - (insert "\n")) - (indent-to-column comment-column) - (search-forward "*/") - (forward-char -2)) + (progn + (delete-region (point) (progn (skip-chars-forward " \t\n\r") (point))) + (if (> (current-column) comment-column) + (insert "\n")) + (indent-to-column comment-column) + (search-forward "*/") + (forward-char -2)) (if (> (current-column) comment-column) - (insert "\n")) + (insert "\n")) (indent-to-column comment-column) (insert "///< ") (setq place (point)) - (insert "\n" - indent "/**< ") + (insert "\n" + indent "/**< ") (insert "\\pre \n" - indent " \\post */") + indent " \\post */") (save-excursion - (goto-char (car (aref defun 2))) - (setq defun (c-get-defun-state))) + (goto-char (car (aref defun 2))) + (setq defun (c-get-defun-state))) (forward-char -2)) (ccide-function-comment-adjust defun (concat indent " ")) (if place (goto-char place)))) (defun ccide-function-comment-grab-args () (let ((limit (save-excursion - (search-backward "/**" nil t) - (point))) - (end (point)) - begin start args argend) + (search-backward "/**" nil t) + (point))) + (end (point)) + begin start args argend) (setq argend end) (while (or (search-backward "\\param" limit t) - (search-backward "\\return" limit t))) + (search-backward "\\return" limit t))) (beginning-of-line) (setq start (point)) (setq begin start) (while (search-forward "\\param" argend t) (or (search-forward "\\param" argend t) - (search-forward "\\return" argend t) - (goto-char argend)) + (search-forward "\\return" argend t) + (goto-char argend)) (beginning-of-line) (setq args (cons (ccide-function-comment-parse-arg start (point)) - args)) + args)) (setq start (point))) (prog1 - (if (not (search-forward "\return" argend t)) - (cons nil args) - (beginning-of-line) - (cons (buffer-substring (point) argend) args)) + (if (not (search-forward "\return" argend t)) + (cons nil args) + (beginning-of-line) + (cons (buffer-substring (point) argend) args)) (delete-region begin end)))) (defun ccide-function-comment-parse-arg (start end) (save-excursion (goto-char start) (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))))) - + (cons (match-string 2) + (cons (buffer-substring start (match-beginning 2)) + (buffer-substring (match-end 2) end))))) + (defun ccide-function-comment-get-throws (defun) (if (aref defun 4) (save-excursion - (goto-char (car (aref defun 4))) - (if (re-search-forward "\\(throw_\\|throw\\)((?\\s-*\\([^()]*\\))?)" - (cdr (aref defun 4)) t) - (let ((spec (match-string 2))) - (if (> (length spec) 0) - spec)))))) + (goto-char (car (aref defun 4))) + (if (re-search-forward "\\(throw_\\|throw\\)((?\\s-*\\([^()]*\\))?)" + (cdr (aref defun 4)) t) + (let ((spec (match-string 2))) + (if (> (length spec) 0) + spec)))))) (defun ccide-function-comment-adjust (defun indent) (insert "\n") (let* ((defargs (mapcar (function (lambda (x) - (c-get-template-argument-name (car x) (cdr x)))) - (aref defun 3))) - (defret (and (aref defun 1) - (not (string-match (concat "^\\(" - c-special-key - "\\s-*\\)*\\s-*void$") - (buffer-substring (car (aref defun 1)) - (cdr (aref defun 1))))))) - (throws (ccide-function-comment-get-throws defun)) - (xargs (ccide-function-comment-grab-args)) - (docargs (cdr xargs)) - (docret (car xargs)) - (def-in-doc (loop for defarg in defargs always (assoc defarg docargs))) - (doc-in-def (loop for docarg in docargs always (member (car docarg) defargs))) - (size-eq (= (length defargs) (length docargs)))) + (c-get-template-argument-name (car x) (cdr x)))) + (aref defun 3))) + (defret (and (aref defun 1) + (not (string-match (concat "^\\(" + c-special-key + "\\s-*\\)*\\s-*void$") + (buffer-substring (car (aref defun 1)) + (cdr (aref defun 1))))))) + (throws (ccide-function-comment-get-throws defun)) + (xargs (ccide-function-comment-grab-args)) + (docargs (cdr xargs)) + (docret (car xargs)) + (def-in-doc (loop for defarg in defargs always (assoc defarg docargs))) + (doc-in-def (loop for docarg in docargs always (member (car docarg) defargs))) + (size-eq (= (length defargs) (length docargs)))) ;; We differentiate four types changes ;; - new arguments ;; - removed arguments ;; - reordered arguments ;; - renamed arguments - ;; + ;; ;; If the change cannot be described by one of the above, it has ;; to be resolved manually (if throws - (insert indent "\\throws " throws "\n")) + (insert indent "\\throws " throws "\n")) (cond (doc-in-def - ;; reordered arguments or new arguments (or no change) - (loop for defarg in defargs - for docarg = (assoc defarg docargs) - do (if docarg - (insert (cadr docarg) (car docarg) (cddr docarg)) - (insert indent "\\param " defarg " \n")))) - (size-eq ; and (not doc-in-def) - ;; renamed arguments - (loop for defarg in defargs - for docarg in docargs - do (insert (cadr docarg) defarg (cddr docarg)))) - (def-in-doc - ;; removed arguments - (loop for defarg in defargs - for docarg = (assoc defarg docargs) - do (insert (cadr docarg) (car docarg) (cddr docarg)))) - (t (error "Arg change too complex. Resolve manualy."))) + ;; reordered arguments or new arguments (or no change) + (loop for defarg in defargs + for docarg = (assoc defarg docargs) + do (if docarg + (insert (cadr docarg) (car docarg) (cddr docarg)) + (insert indent "\\param " defarg " \n")))) + (size-eq ; and (not doc-in-def) + ;; renamed arguments + (loop for defarg in defargs + for docarg in docargs + do (insert (cadr docarg) defarg (cddr docarg)))) + (def-in-doc + ;; removed arguments + (loop for defarg in defargs + for docarg = (assoc defarg docargs) + do (insert (cadr docarg) (car docarg) (cddr docarg)))) + (t (error "Arg change too complex. Resolve manualy."))) ;; return value is simple (if defret - (if docret - (insert docret) - (insert indent "\\return \n")))) + (if docret + (insert docret) + (insert indent "\\return \n")))) (delete-char -1) (delete-horizontal-space) (insert " ")) @@ -844,12 +845,12 @@ arg, if given, specifies the kind of prefix (inline, static, ...) to use." (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))) + ccide-default-prefix)) + (defn (c-build-defun prfx))) (kill-new (concat (cadr defn) "\n{}\n")) (message (concat (or prfx "") - (if prfx " " "") - (car defn)))))) + (if prfx " " "") + (car defn)))))) (defun ccide-reformat-defun () "Reformat the defn of the current defun." @@ -858,10 +859,10 @@ arg, if given, specifies the kind of prefix (inline, static, ...) to use." (c-beginning-of-defun-or-decl) (let ((defn (c-build-defun nil t))) (delete-region (or (caar (aref (caddr defn) 0)) - (car (aref (caddr defn) 1)) - (car (aref (caddr defn) 2))) - (or (car (aref (caddr defn) 6)) - (aref (caddr defn) 7))) + (car (aref (caddr defn) 1)) + (car (aref (caddr defn) 2))) + (or (car (aref (caddr defn) 6)) + (aref (caddr defn) 7))) (insert (cadr defn) "\n")))) (defun ccide-replace-defun () @@ -872,11 +873,11 @@ ring (presumably placed there using c++-grab-prototype)." (c-beginning-of-defun-or-decl) (let ((parse (c-parse-defun))) (delete-region (or (aref parse 0) - (aref parse 1) - (aref parse 2)) - (or (aref parse 5) - (aref parse 6) - (aref parse 7))) + (aref parse 1) + (aref parse 2)) + (or (aref parse 5) + (aref parse 6) + (aref parse 7))) (yank) (delete-char -3)))) @@ -887,29 +888,29 @@ it will be prefixed with the current class prefix." (save-excursion (c-beginning-of-defun-or-decl) (let* ((parse (c-parse-defun)) - (prefix (c-scope-name (aref parse 2) (+ (or strip 0) 0)))) + (prefix (c-scope-name (aref parse 2) (+ (or strip 0) 0)))) (goto-char (aref parse 1)) (while (and (or (looking-at c-any-key) - (looking-at c-user-prefix-re) - (not (c-at-symbol-p))) - (< (point) (aref parse 2)) - (not (eobp))) - (c-forward-token-1) - (c-forward-syntactic-ws)) + (looking-at c-user-prefix-re) + (not (c-at-symbol-p))) + (< (point) (aref parse 2)) + (not (eobp))) + (c-forward-token-1) + (c-forward-syntactic-ws)) (if (and (c-at-symbol-p) - (< (point) (aref parse 2)) - (not (looking-at (regexp-quote prefix)))) - (let ((pos (string-match "<" prefix))) - (if pos - (insert "typename ")) - (if (and pos (looking-at (concat (substring prefix 0 pos) - "\\b[^_]"))) - (progn - (goto-char (match-end 0)) - (c-backward-syntactic-ws) - (insert (substring prefix pos))) - (insert prefix "::")) - (ccide-reformat-defun)))))) + (< (point) (aref parse 2)) + (not (looking-at (regexp-quote prefix)))) + (let ((pos (string-match "<" prefix))) + (if pos + (insert "typename ")) + (if (and pos (looking-at (concat (substring prefix 0 pos) + "\\b[^_]"))) + (progn + (goto-char (match-end 0)) + (c-backward-syntactic-ws) + (insert (substring prefix pos))) + (insert prefix "::")) + (ccide-reformat-defun)))))) (defun ccide-prefix-defun-type-with-namespace (&optional strip) (interactive "p") @@ -919,30 +920,30 @@ it will be prefixed with the current class prefix." "Insert the current defun prefix at point." (interactive "p") (let* ((parse (c-parse-defun)) - (prefix (c-scope-name (aref parse 2) (+ (or strip 0) 0)))) + (prefix (c-scope-name (aref parse 2) (+ (or strip 0) 0)))) (insert prefix "::"))) (defun ccide-kill-inline-decl (defn) (save-excursion (if (aref (caddr defn) 6) - (progn - (goto-char (cdr (aref (caddr defn) 6))) - (let ((end-mark (point-marker))) - (goto-char (car (aref (caddr defn) 6))) - (indent-rigidly (point) end-mark - (- (current-column))) - (prog1 - (concat (cadr defn) - "\n" - (buffer-substring-no-properties (point) end-mark) - "\n") - (when (aref (caddr defn) 5) - (goto-char (caar (aref (caddr defn) 5))) - (c-backward-syntactic-ws) - (skip-chars-backward ":")) - (c-backward-syntactic-ws) - (delete-region (point) end-mark) - (insert ";")))) + (progn + (goto-char (cdr (aref (caddr defn) 6))) + (let ((end-mark (point-marker))) + (goto-char (car (aref (caddr defn) 6))) + (indent-rigidly (point) end-mark + (- (current-column))) + (prog1 + (concat (cadr defn) + "\n" + (buffer-substring-no-properties (point) end-mark) + "\n") + (when (aref (caddr defn) 5) + (goto-char (caar (aref (caddr defn) 5))) + (c-backward-syntactic-ws) + (skip-chars-backward ":")) + (c-backward-syntactic-ws) + (delete-region (point) end-mark) + (insert ";")))) (concat (cadr defn) "\n{}\n")))) (defun ccide-grab-inline-decl () @@ -951,29 +952,29 @@ declaration at the top of the kill ring." (interactive) (let ((defn (c-build-defun (or ccide-default-prefix "inline")))) (kill-new (ccide-kill-inline-decl defn)) - (message (concat (or ccide-default-prefix "indline") - " " - (car defn))))) + (message (concat (or ccide-default-prefix "indline") + " " + (car defn))))) (defun ccide-grab-all-inlines () "Grab all inline decls in the current class" (interactive) (let ((class (c-parse-class (c-get-block-scope))) - defns) + defns) (when class (loop for method in (nreverse (aref class 4)) - do (when (eq (car method) 'method) - (let ((defn (save-excursion - (goto-char (cdr method)) - (c-build-defun (or ccide-default-prefix "inline"))))) - (if (aref (caddr defn) 6) - (setq defns (nconc defns (list (ccide-kill-inline-decl defn)))))))) - (kill-new (loop for defn in (nreverse defns) - for next = nil then t - if next concat "\n"; - concat defn)) + do (when (eq (car method) 'method) + (let ((defn (save-excursion + (goto-char (cdr method)) + (c-build-defun (or ccide-default-prefix "inline"))))) + (if (aref (caddr defn) 6) + (setq defns (nconc defns (list (ccide-kill-inline-decl defn)))))))) + (setq defns (nreverse defns)) + (kill-new (loop for defn in defns + for next = nil then t + if next concat "\n"; + concat defn)) (message (format "%d inlines grabed to kill ring" (length defns)))))) - (defun ccide-grab-create-constructor () (interactive) @@ -984,21 +985,21 @@ declaration at the top of the kill ring." (defun ccide-grab-create-constructor-impl (&optional prefix) (interactive "P") (let* ((prfx (or (and prefix (nth (prefix-numeric-value prefix) c-user-prefixes)) - ccide-default-prefix)) - (defn (c-build-create-constructor-impl prfx))) + ccide-default-prefix)) + (defn (c-build-create-constructor-impl prfx))) (kill-new (cadr defn)) (message (concat (or prfx "") - (if prfx " " "") - (car defn))))) + (if prfx " " "") + (car defn))))) (defun ccide-find-implementation (&optional other-window) "Find implementation of method declared at point." (interactive "P") (let* ((state (c-get-defun-state)) - (name (c-defun-short-name state)) - (scoped-name (c-defun-full-name state)) - (args (ccide-implementation-args state)) - (targs (ccide-implementation-template-args state)) + (name (c-defun-short-name state)) + (scoped-name (c-defun-full-name state)) + (args (ccide-implementation-args state)) + (targs (ccide-implementation-template-args state)) rv fallback) (loop for ext in ccide-implementation-extensions @@ -1012,7 +1013,7 @@ declaration at the top of the kill ring." (let ((found (save-excursion (set-buffer buf) (ccide-find-implementation-1 name scoped-name args targs - (not (aref state 6)) + (not (aref state 6)) (car (aref state 2)))))) (if found (if (cdr found) @@ -1023,7 +1024,7 @@ declaration at the top of the kill ring." (let* ((buf (car rv)) (pos (cadr rv)) (win (get-buffer-window buf))) - (if win + (if win (select-window win) (if other-window (switch-to-buffer-other-window buf) @@ -1035,31 +1036,31 @@ declaration at the top of the kill ring." (defun ccide-implementation-args (state) (string-replace "[ \t\n\r]+" "" - (loop for (start . end) in (aref state 3) - for sep = "" then "," - concat sep - concat (buffer-substring-no-properties - start (save-excursion - (goto-char start) - (if (search-forward "=" end 'move) (forward-char -1)) - (point)))) - - t)) + (loop for (start . end) in (aref state 3) + for sep = "" then "," + concat sep + concat (buffer-substring-no-properties + start (save-excursion + (goto-char start) + (if (search-forward "=" end 'move) (forward-char -1)) + (point)))) + + t)) (defun ccide-implementation-template-args (state) (and (aref state 0) (string-replace "[ \t\n\r]+" "" - (loop for (start . end) in (save-excursion - (goto-char (caar (last (aref state 0)))) - (c-parse-template-declaration)) - for sep = "" then "," - concat sep - concat (buffer-substring-no-properties - start (save-excursion - (goto-char start) - (if (search-forward "=" end 'move) (forward-char -1)) - (point)))) - t))) + (loop for (start . end) in (save-excursion + (goto-char (caar (last (aref state 0)))) + (c-parse-template-declaration)) + for sep = "" then "," + concat sep + concat (buffer-substring-no-properties + start (save-excursion + (goto-char start) + (if (search-forward "=" end 'move) (forward-char -1)) + (point)))) + t))) (defun ccide-find-implementation-1 (name scoped-name args targs with-body skip-def) ;; Within the current buffer, search for all implementations of the @@ -1069,27 +1070,27 @@ declaration at the top of the kill ring." (save-excursion (goto-char (point-min)) (let ((re (concat (if (eq (char-syntax (aref name 0)) ?w) "\\<" "") - (regexp-quote name) - (if (eq (char-syntax (aref name (1- (length name)))) ?w) "\\>" ""))) - fallback rv check-state) + (regexp-quote name) + (if (eq (char-syntax (aref name (1- (length name)))) ?w) "\\>" ""))) + fallback rv check-state) (while (and (not rv) (re-search-forward re nil t)) (if (c-save-buffer-state () - (and (c-at-toplevel-p) - (not (c-in-literal)) - (setq check-state (condition-case nil (c-get-defun-state) (error nil))) - (not (= (car (aref check-state 2)) skip-def)))) + (and (c-at-toplevel-p) + (not (c-in-literal)) + (setq check-state (condition-case nil (c-get-defun-state) (error nil))) + (not (= (car (aref check-state 2)) skip-def)))) (if (string= scoped-name (c-defun-full-name check-state)) (if (and (if with-body (aref check-state 6) (not (aref check-state 6))) - (string= args (ccide-implementation-args check-state)) - (string= targs (ccide-implementation-template-args check-state))) + (string= args (ccide-implementation-args check-state)) + (string= targs (ccide-implementation-template-args check-state))) (setq rv (cons (point) t)) - (if (not fallback) + (if (not fallback) (setq fallback (cons (point) nil))))))) (or rv fallback)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; variable/type level - + (defun ccide-variable-comment () "Add a comment to current variable declaration." (interactive) @@ -1109,36 +1110,36 @@ declaration at the top of the kill ring." (save-excursion (beginning-of-line) (if (looking-at (concat c++-simple-type-regexp "[ \t\n\r][a-zA-Z0-9_]+[ \t\n\r]*;")) - (let ((vardef (match-string 0)) - (in (make-string c-basic-offset ? )) - type reftype varname fnname argname ws) - (forward-line -1) - (back-to-indentation) - (string-match "^[ \t\n\r]*\\(.*\\)[ \t\n\r]\\([a-zA-Z0-9_]+\\)[ \t\n\r]*;$" - vardef) - (setq varname (match-string 2 vardef) - type (match-string 1 vardef) - ws (substring vardef 0 (match-beginning 1))) - (if (string-match "_$" varname) - (setq fnname (string-replace "_$" "" varname) - argname (concat "a_" fnname)) - (setq fnname (concat "q_" varname) - argname (concat "a_" varname))) - (if (string-match "^[ \t\n\r]*" type) - (setq type (substring type (match-end 0)))) - (if (string-match "^[A-Z]" type) - (setq reftype (concat type " const &")) - (setq reftype type)) - (kill-new (concat ws type " " fnname "(" reftype " " argname ")\n" - ws in "{\n" - ws in in type " old" varname " = " varname ";\n" - ws in in varname " = " argname ";\n" - ws in in "return old" varname ";\n" - ws in "}\n\n" - ws reftype " " fnname "() const\n" - ws in "{ return " varname "; }\n")) - - (message varname)) + (let ((vardef (match-string 0)) + (in (make-string c-basic-offset ? )) + type reftype varname fnname argname ws) + (forward-line -1) + (back-to-indentation) + (string-match "^[ \t\n\r]*\\(.*\\)[ \t\n\r]\\([a-zA-Z0-9_]+\\)[ \t\n\r]*;$" + vardef) + (setq varname (match-string 2 vardef) + type (match-string 1 vardef) + ws (substring vardef 0 (match-beginning 1))) + (if (string-match "_$" varname) + (setq fnname (string-replace "_$" "" varname) + argname (concat "a_" fnname)) + (setq fnname (concat "q_" varname) + argname (concat "a_" varname))) + (if (string-match "^[ \t\n\r]*" type) + (setq type (substring type (match-end 0)))) + (if (string-match "^[A-Z]" type) + (setq reftype (concat type " const &")) + (setq reftype type)) + (kill-new (concat ws type " " fnname "(" reftype " " argname ")\n" + ws in "{\n" + ws in in type " old" varname " = " varname ";\n" + ws in in varname " = " argname ";\n" + ws in in "return old" varname ";\n" + ws in "}\n\n" + ws reftype " " fnname "() const\n" + ws in "{ return " varname "; }\n")) + + (message varname)) (message "No variable found")))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1148,32 +1149,32 @@ declaration at the top of the kill ring." "Function to indent doxy comments correctly" (let ((indent (ccide-in-doxy-comment))) (if indent - (let ((lim (save-excursion - (back-to-indentation) - (c-literal-limits))) - (pos (- (point-max) (point)))) - (save-excursion - (back-to-indentation) - (if (looking-at "*/") - (incf indent -3) - (let ((para (or (save-excursion (re-search-backward "^\\s-*$" (car lim) t)) - (car lim)))) - (if (and (not (looking-at ccide-doxy-tag-re)) - (re-search-backward (concat "^\\s-*" - ccide-doxy-tag-re) - para t)) - (incf indent 4))))) - (delete-region (progn (beginning-of-line) (point)) - (progn (back-to-indentation) (point))) - (indent-to indent) - (if (> (- (point-max) pos) (point)) - (goto-char (- (point-max) pos))))))) - + (let ((lim (save-excursion + (back-to-indentation) + (c-literal-limits))) + (pos (- (point-max) (point)))) + (save-excursion + (back-to-indentation) + (if (looking-at "*/") + (incf indent -3) + (let ((para (or (save-excursion (re-search-backward "^\\s-*$" (car lim) t)) + (car lim)))) + (if (and (not (looking-at ccide-doxy-tag-re)) + (re-search-backward (concat "^\\s-*" + ccide-doxy-tag-re) + para t)) + (incf indent 4))))) + (delete-region (progn (beginning-of-line) (point)) + (progn (back-to-indentation) (point))) + (indent-to indent) + (if (> (- (point-max) pos) (point)) + (goto-char (- (point-max) pos))))))) + (defun ccide-fill-function () "auto-fill function for doxy comments" (if (do-auto-fill) (if (not fill-prefix) - (indent-according-to-mode)))) + (indent-according-to-mode)))) (defun ccide-hide-all-doxy-comments () "Hide all doxy comments" @@ -1184,13 +1185,13 @@ declaration at the top of the kill ring." (beginning-of-line) (forward-line -1) (if (not (looking-at "\\s-*$")) - (forward-line 1)) + (forward-line 1)) (forward-char -1) (let ((start (point))) - (if (re-search-forward "\\*/" nil t) - (progn - (if (looking-at "\\s-*\n") - (forward-line 1)) + (if (re-search-forward "\\*/" nil t) + (progn + (if (looking-at "\\s-*\n") + (forward-line 1)) (forward-char -1) (let ((overlay (make-overlay start (point)))) (overlay-put overlay 'intangible 'hs) @@ -1217,62 +1218,62 @@ declaration at the top of the kill ring." (save-excursion (goto-char (point-min)) (while (re-search-forward "#include\\s-*[\"<]\\([^\">]*\\)\\.hh[\">]" nil t) - (setq files (cons (ccide-match-string 1) files))) + (setq files (cons (ccide-match-string 1) files))) (nreverse files)))) (defun ccide-corba-maybe-build-hh (file) (let ((skel (ccide-file-name ".hh" file ccide-corba-skel-dir)) - (idl (ccide-file-name ".idl" file ccide-corba-idl-dir))) + (idl (ccide-file-name ".idl" file ccide-corba-idl-dir))) (if (and (file-readable-p idl) - (or (not (file-readable-p skel)) - (file-newer-than-file-p idl skel))) - (let ((buffer (find-buffer-visiting (ccide-file-name ".hh" file)))) + (or (not (file-readable-p skel)) + (file-newer-than-file-p idl skel))) + (let ((buffer (find-buffer-visiting (ccide-file-name ".hh" file)))) (if buffer (kill-buffer buffer)) - (message "Please wait ... building %s" (ccide-file-name ".hh" file)) - (if (ccide-shell-command (concat "cd " - (real-path-name ccide-corba-skel-dir) - " && " - ccide-corba-idl-command - (if (> (length ccide-corba-idl-dir) 0) - (concat " -I" ccide-corba-idl-dir)) - " " - idl)) - () - (display-buffer (get-buffer-create "*ccide shell command*")) - (error "Generation of %s failed" (ccide-file-name ".hh"))))) + (message "Please wait ... building %s" (ccide-file-name ".hh" file)) + (if (ccide-shell-command (concat "cd " + (real-path-name ccide-corba-skel-dir) + " && " + ccide-corba-idl-command + (if (> (length ccide-corba-idl-dir) 0) + (concat " -I" ccide-corba-idl-dir)) + " " + idl)) + () + (display-buffer (get-buffer-create "*ccide shell command*")) + (error "Generation of %s failed" (ccide-file-name ".hh"))))) (if (not (file-readable-p skel)) - (error "No file %s or %s" - (ccide-file-name ".hh" file) (ccide-file-name ".idl" file))))) + (error "No file %s or %s" + (ccide-file-name ".hh" file) (ccide-file-name ".idl" file))))) (defun ccide-corba-list-skeletons-1 (hh-file) (ccide-corba-maybe-build-hh hh-file) (let ((hh-buf (find-file-noselect (ccide-file-name ".hh" hh-file))) - skels) + skels) (save-excursion (set-buffer hh-buf) (save-excursion - (goto-char (point-min)) - (while (re-search-forward "^\\s-*class\\s-+_sk_\\([a-zA-Z0-9_]+\\)\\s-+:" - nil t) - (setq skels (cons (ccide-match-string 1) skels))))) + (goto-char (point-min)) + (while (re-search-forward "^\\s-*class\\s-+_sk_\\([a-zA-Z0-9_]+\\)\\s-+:" + nil t) + (setq skels (cons (ccide-match-string 1) skels))))) (mapcar (function (lambda (x) (cons x hh-file))) - (sort skels 'string-lessp)))) + (sort skels 'string-lessp)))) (defun ccide-corba-list-skeletons () (let ((files (ccide-get-corba-headers))) (loop for file in files - append (ccide-corba-list-skeletons-1 file)))) + append (ccide-corba-list-skeletons-1 file)))) (defun ccide-gen-corba-impl (class) (interactive (list (completing-read "Class name of skeleton: " - (ccide-corba-list-skeletons) - nil t))) + (ccide-corba-list-skeletons) + nil t))) (let* ((skels (ccide-corba-list-skeletons)) - (hh-file (ccide-file-name ".hh" (cdr (assoc class skels)) - ccide-corba-skel-dir)) - (hh-buf (find-file-noselect (ccide-file-name ".hh" hh-file - ccide-corba-skel-dir)))) + (hh-file (ccide-file-name ".hh" (cdr (assoc class skels)) + ccide-corba-skel-dir)) + (hh-buf (find-file-noselect (ccide-file-name ".hh" hh-file + ccide-corba-skel-dir)))) (ccide-gen-class (concat class "_i")) (insert (make-string c-basic-offset ? ) ": public virtual _sk_" class "\n") (save-excursion @@ -1283,47 +1284,47 @@ declaration at the top of the kill ring." (defun ccide-get-corba-defns (hh-file class) (let ((hh-buf (find-file-noselect hh-file)) - defns) + defns) (save-excursion (set-buffer hh-buf) (save-excursion - (goto-char (point-min)) - (if (not (re-search-forward (concat "^\\s-*class\\s-+_sk_" class "\\s-+:") - nil t)) - (error "CORBA skeleton class not found.") - (search-forward "{") - (forward-char -1) - (let ((end (save-excursion (forward-sexp) (point)))) - (while (and (< (point) end) - (< (forward-line 1) 1)) - (if (looking-at "\\s-+virtual\\s-+\\(.*)\\)\\s-*=\\s-*0;\\s-*$") - (setq defns (cons (match-string 1) defns)))))))) + (goto-char (point-min)) + (if (not (re-search-forward (concat "^\\s-*class\\s-+_sk_" class "\\s-+:") + nil t)) + (error "CORBA skeleton class not found.") + (search-forward "{") + (forward-char -1) + (let ((end (save-excursion (forward-sexp) (point)))) + (while (and (< (point) end) + (< (forward-line 1) 1)) + (if (looking-at "\\s-+virtual\\s-+\\(.*)\\)\\s-*=\\s-*0;\\s-*$") + (setq defns (cons (match-string 1) defns)))))))) (nreverse defns))) (defun ccide-gen-corba-impl-methods () (interactive) (let* ((class (c-get-class-at-point)) - (point (point))) + (point (point))) (if (not class) - (error "No class at point.")) + (error "No class at point.")) (save-excursion (goto-char (aref (car class) 1)) (if (not (re-search-forward ":\\s-*public\\s-*virtual\\s-*_sk_\\([^ \t\n\r{},:]*\\)" - nil t)) - (error "No CORBA impl at point.")) + nil t)) + (error "No CORBA impl at point.")) (let* ((name (ccide-match-string 1)) - (skels (ccide-corba-list-skeletons)) - (hh-file (ccide-file-name ".hh" (cdr (assoc name skels)) - ccide-corba-skel-dir)) - (defns (ccide-get-corba-defns hh-file name)) - end) - (goto-char (aref (car class) 2)) - (save-excursion - (c-forward-sexp) - (setq end (point))) - (if (re-search-forward "^\\s-*// CORBA$" end t) - (let ((start (match-beginning 0))) - (if (re-search-forward "^\\s-*// END-CORBA$" end t) + (skels (ccide-corba-list-skeletons)) + (hh-file (ccide-file-name ".hh" (cdr (assoc name skels)) + ccide-corba-skel-dir)) + (defns (ccide-get-corba-defns hh-file name)) + end) + (goto-char (aref (car class) 2)) + (save-excursion + (c-forward-sexp) + (setq end (point))) + (if (re-search-forward "^\\s-*// CORBA$" end t) + (let ((start (match-beginning 0))) + (if (re-search-forward "^\\s-*// END-CORBA$" end t) (let ((eend (match-end 0))) (goto-char start) (forward-line 1) @@ -1332,23 +1333,23 @@ declaration at the top of the kill ring." (delete-region start (1+ eend)) (goto-char eend) (beginning-of-line) - (delete-region (point) (progn + (delete-region (point) (progn (end-of-line) (1+ (point)))) (save-excursion (goto-char start) - (delete-region (point) (progn + (delete-region (point) (progn (end-of-line) (1+ (point))))) (insert "\n")) (delete-region start (1+ eend)))))) - (goto-char point)) - (indent-according-to-mode) - (insert "// CORBA\n") - (loop for defn in defns - do (progn - (save-excursion (insert defn ";")) - (indent-according-to-mode) + (goto-char point)) + (indent-according-to-mode) + (insert "// CORBA\n") + (loop for defn in defns + do (progn + (save-excursion (insert defn ";")) + (indent-according-to-mode) (let ((start (point)) end) (end-of-line) (setq end (point)) @@ -1373,8 +1374,8 @@ declaration at the top of the kill ring." (setq done t)) while (not done))) (insert "\n"))) - (indent-according-to-mode) - (insert "// END-CORBA\n"))))) + (indent-according-to-mode) + (insert "// END-CORBA\n"))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; template support @@ -1390,33 +1391,33 @@ instatiations at point." (set-buffer (get-buffer-create "*mantemps*")) (erase-buffer) (loop for temp = (ccide-get-mantemp) - while temp - do (insert temp "\n")) + while temp + do (insert temp "\n")) (mantemp-make-mantemps-buffer) (goto-char (point-min)) (while (progn - (ccide-fix-mantemp) - (< (forward-line 1) 1)))) + (ccide-fix-mantemp) + (< (forward-line 1) 1)))) (insert-buffer-substring "*mantemps*")) (defun ccide-get-mantemp () (save-excursion (set-buffer "*compilation*") (if (search-forward "undefined reference to `" nil t) - (let ((start (point))) - (end-of-line) - (search-backward "'" nil t) - (buffer-substring start (point)))))) + (let ((start (point))) + (end-of-line) + (search-backward "'" nil t) + (buffer-substring start (point)))))) (defun ccide-fix-mantemp () (let ((end (save-excursion - (end-of-line) (point)))) + (end-of-line) (point)))) (if (and (save-excursion (search-forward "(" end t)) - (search-forward " class" end t)) - (progn - (forward-char -6) - (delete-char 6))))) - + (search-forward " class" end t)) + (progn + (forward-char -6) + (delete-char 6))))) + (provide 'cc-ide) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1425,12 +1426,12 @@ instatiations at point." (defun ccide-open-compilation-frame () (interactive) (let ((c-frame (selected-frame)) - (compilation-frame (make-frame '((minibuffer . nil) - (unsplittable . t) - (menu-bar-lines . 0) - (top . -87) - (left . 36) - (width . 169) + (compilation-frame (make-frame '((minibuffer . nil) + (unsplittable . t) + (menu-bar-lines . 0) + (top . -87) + (left . 36) + (width . 169) (height . 9))))) (select-frame compilation-frame) (switch-to-buffer "*compilation*") @@ -1478,12 +1479,12 @@ instatiations at point." (defun ccide-bind-keys (prefix map) (loop for binding in ccide-bindings - do (apply 'vcmd-define-key - map - (concat prefix (car binding)) - (cadr binding) - "IDE" - (cddr binding)))) + do (apply 'vcmd-define-key + map + (concat prefix (car binding)) + (cadr binding) + "IDE" + (cddr binding)))) (defun ccide-install-it () (save-excursion @@ -1504,21 +1505,22 @@ instatiations at point." (defun ccide-project-load-config () (if (buffer-file-name) - (let ((conf (ccide-project-search-upwards "project.el" (file-name-directory (buffer-file-name))))) - (when conf - (set (make-local-variable 'ccide-project-root) (file-name-directory conf)) - (load-file conf))))) + (let ((conf (ccide-project-search-upwards '(".project.el" "project.el") + (file-name-directory (buffer-file-name))))) + (when conf + (set (make-local-variable 'ccide-project-root) (file-name-directory conf)) + (load-file conf))))) -(defun ccide-project-search-upwards (file &optional dir) +(defun ccide-project-search-upwards (names &optional base) "Search for FILE in all directories starting at DIR and going up the directory hierarchy. -DIR defaults to ccide-project-root" - (let (conf last-dir) - (setq dir (expand-file-name "x" (or dir ccide-project-root))) - (while (and (not (string= (setq last-dir dir - dir (directory-file-name (file-name-directory dir))) last-dir)) - (setq conf (expand-file-name file dir)) - (not (file-readable-p conf)))) - (and (file-readable-p conf) conf))) +DIR defaults to ccide-project-root. If FILE is a list, search for any file in list." + (if (not (consp names)) + (setq names (list names))) + (loop for dir = (or base ccide-project-root) then (directory-file-name (file-name-directory dir)) + while (not (string= dir "/")) + thereis (loop for name in names + for path = (expand-file-name name dir) + thereis (and (file-readable-p path) path)))) (defun ccide-directory-load-config () (if (file-readable-p ".dir.el") @@ -1532,38 +1534,38 @@ DIR defaults to ccide-project-root" for re = (concat (regexp-quote extension) "$") if (not (assoc re auto-mode-alist)) do (setq auto-mode-alist (append auto-mode-alist - (list (cons re 'c++-mode))))) + (list (cons re 'c++-mode))))) (defadvice c-indent-line (after c-indent-less compile disable) ;activate ;; new indent function for c-mode: do standard indentation first. If line ;; is to long using standard indentation, just indent by c-basic-indentation. (let ((cc (save-excursion (end-of-line) (current-column))) - indent) + indent) (if (> cc 85) - (let ((pos (- (point-max) (point)))) - (beginning-of-line) - (let ((point (point)) - (line (1+ (count-lines 1 (point)))) - indent) - (c-beginning-of-statement-2) - (if (and (not (c-crosses-statement-barrier-p (point) point)) - (not (eq (+ (count-lines 1 (point)) - (if (bolp) 1 0)) - line))) - (progn - (setq indent (+ (current-indentation) c-basic-offset)) - (goto-char point) - (if (< indent (current-indentation)) - (progn - (setq ad-return-value - (+ ad-return-value - (- (current-indentation) indent))) - (delete-region (c-point 'bol) (c-point 'boi)) - (indent-to indent)))))) - (if (< (point) (c-point 'boi)) - (back-to-indentation) - (if (> (- (point-max) pos) (point)) - (goto-char (- (point-max) pos)))))))) + (let ((pos (- (point-max) (point)))) + (beginning-of-line) + (let ((point (point)) + (line (1+ (count-lines 1 (point)))) + indent) + (c-beginning-of-statement-2) + (if (and (not (c-crosses-statement-barrier-p (point) point)) + (not (eq (+ (count-lines 1 (point)) + (if (bolp) 1 0)) + line))) + (progn + (setq indent (+ (current-indentation) c-basic-offset)) + (goto-char point) + (if (< indent (current-indentation)) + (progn + (setq ad-return-value + (+ ad-return-value + (- (current-indentation) indent))) + (delete-region (c-point 'bol) (c-point 'boi)) + (indent-to indent)))))) + (if (< (point) (c-point 'boi)) + (back-to-indentation) + (if (> (- (point-max) pos) (point)) + (goto-char (- (point-max) pos))))))))