]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/cedet-cscope.el
Merge changes from emacs-23 branch
[gnu-emacs] / lisp / cedet / cedet-cscope.el
index 6bb7508fd6013a04c5c1f1fce5a27c90d4e7973f..211c7fb4b018b67f4f4a90807ff7b61f0967adb1 100644 (file)
@@ -1,8 +1,9 @@
 ;;; cedet-cscope.el --- CScope support for CEDET
 
-;;; Copyright (C) 2009 Free Software Foundation, Inc.
+;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
+;; Package: cedet
 
 ;; This file is part of GNU Emacs.
 
@@ -72,13 +73,18 @@ SCOPE is the scope of the search, such as 'project or 'subdirs."
        )
     (cedet-cscope-call (list "-d" "-L" idx searchtext))))
 
+(defun cedet-cscope-create (flags)
+  "Create a CScope database at the current directory.
+FLAGS are additional flags to pass to cscope beyond the
+options -cR."
+  (cedet-cscope-call (append (list "-cR") flags)))
+
 (defun cedet-cscope-call (flags)
   "Call CScope with the list of FLAGS."
   (let ((b (get-buffer-create "*CEDET CScope*"))
        (cd default-directory)
        )
-    (save-excursion
-      (set-buffer b)
+    (with-current-buffer b
       (setq default-directory cd)
       (erase-buffer))
     (apply 'call-process cedet-cscope-command
@@ -90,8 +96,8 @@ SCOPE is the scope of the search, such as 'project or 'subdirs."
   "Expand the FILENAME with CScope.
 Return a fully qualified filename."
   (interactive "sFile: ")
-  (let* ((ans1 (save-excursion
-                (set-buffer (cedet-cscope-call (list "-d" "-L" "-7" filename)))
+  (let* ((ans1 (with-current-buffer
+                   (cedet-cscope-call (list "-d" "-L" "-7" filename))
                 (goto-char (point-min))
                 (if (looking-at "[^ \n]*cscope: ")
                     (error "CScope not available")
@@ -99,7 +105,7 @@ Return a fully qualified filename."
         (ans2 (mapcar (lambda (hit)
                         (expand-file-name (car (split-string hit " "))))
                       ans1)))
-    (when (interactive-p)
+    (when (called-interactively-p 'interactive)
       (if ans2
          (if (= (length ans2) 1)
              (message "%s" (car ans2))
@@ -113,13 +119,19 @@ Return a fully qualified filename."
 If DIR is not supplied, use the current default directory.
 This works by running cscope on a bogus symbol, and looking for
 the error code."
+  (interactive "DDirectory: ")
   (save-excursion
     (let ((default-directory (or dir default-directory)))
       (set-buffer (cedet-cscope-call (list "-d" "-L" "-7" "moose")))
       (goto-char (point-min))
-      (if (looking-at "[^ \n]*cscope: ")
-         nil
-       t))))
+      (let ((ans (looking-at "[^ \n]*cscope: ")))
+       (if (called-interactively-p 'interactive)
+           (if ans
+               (message "No support for CScope in %s" default-directory)
+             (message "CScope is supported in %s" default-directory))
+         (if ans
+             nil
+           t))))))
 
 (defun cedet-cscope-version-check (&optional noerror)
   "Check the version of the installed CScope command.
@@ -134,11 +146,10 @@ return nil."
        (rev nil))
     (if (not b)
        (progn
-         (when (interactive-p)
+         (when (called-interactively-p 'interactive)
            (message "CScope not found."))
          nil)
-      (save-excursion
-       (set-buffer b)
+      (with-current-buffer b
        (goto-char (point-min))
        (re-search-forward "cscope: version \\([0-9.]+\\)" nil t)
        (setq rev (match-string 1))
@@ -148,10 +159,18 @@ return nil."
              (error "Version of CScope is %s.  Need at least %s"
                     rev cedet-cscope-min-version))
          ;; Else, return TRUE, as in good enough.
-         (when (interactive-p)
+         (when (called-interactively-p 'interactive)
            (message "CScope %s  - Good enough for CEDET." rev))
          t)))))
 
+(defun cedet-cscope-create/update-database (&optional dir)
+  "Create a CScope database in DIR.
+CScope will automatically choose incremental rebuild if
+there is already a database in DIR."
+  (interactive "DDirectory: ")
+  (let ((default-directory dir))
+    (cedet-cscope-create nil)))
+
 (provide 'cedet-cscope)
 
 ;; arch-tag: 9973f1ad-f13b-4399-bc67-7f488478d78d