]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/cedet-idutils.el
Spelling fixes.
[gnu-emacs] / lisp / cedet / cedet-idutils.el
index e3cbf0d9ff3c303f42a0b03c3769b1210ce4b54f..e071265c1434ed3fabda7c25fd11673829e85f09 100644 (file)
@@ -1,10 +1,11 @@
 ;;; cedet-idutils.el --- ID Utils support for CEDET.
 
-;; Copyright (C) 2009  Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011  Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
 ;; Version: 0.2
 ;; Keywords: OO, lisp
+;; Package: cedet
 
 ;; This file is part of GNU Emacs.
 
   :type 'string
   :group 'cedet)
 
+(defcustom cedet-idutils-make-command "mkid"
+  "Command name for the ID Utils executable for creating token databases."
+  :type 'string
+  :group 'cedet)
+
 (defun cedet-idutils-search (searchtext texttype type scope)
   "Perform a search with ID Utils, return the created buffer.
 SEARCHTEXT is text to find.
@@ -82,8 +88,7 @@ Return the created buffer with with program output."
   (let ((b (get-buffer-create "*CEDET fnid*"))
        (cd default-directory)
        )
-    (save-excursion
-      (set-buffer b)
+    (with-current-buffer b
       (setq default-directory cd)
       (erase-buffer))
     (apply 'call-process cedet-idutils-file-command
@@ -97,8 +102,7 @@ Return the created buffer with with program output."
   (let ((b (get-buffer-create "*CEDET lid*"))
        (cd default-directory)
        )
-    (save-excursion
-      (set-buffer b)
+    (with-current-buffer b
       (setq default-directory cd)
       (erase-buffer))
     (apply 'call-process cedet-idutils-token-command
@@ -106,20 +110,33 @@ Return the created buffer with with program output."
           flags)
     b))
 
+(defun cedet-idutils-mkid-call (flags)
+  "Call ID Utils mkid with the list of FLAGS.
+Return the created buffer with with program output."
+  (let ((b (get-buffer-create "*CEDET mkid*"))
+       (cd default-directory)
+       )
+    (with-current-buffer b
+      (setq default-directory cd)
+      (erase-buffer))
+    (apply 'call-process cedet-idutils-make-command
+          nil b nil
+          flags)
+    b))
+
 ;;; UTIL CALLS
 ;;
 (defun cedet-idutils-expand-filename (filename)
   "Expand the FILENAME with ID Utils.
 Return a filename relative to the default directory."
   (interactive "sFile: ")
-  (let ((ans (save-excursion
-              (set-buffer (cedet-idutils-fnid-call (list filename)))
+  (let ((ans (with-current-buffer (cedet-idutils-fnid-call (list filename))
               (goto-char (point-min))
               (if (looking-at "[^ \n]*fnid: ")
                   (error "ID Utils not available")
                 (split-string (buffer-string) "\n" t)))))
     (setq ans (mapcar 'expand-file-name ans))
-    (when (interactive-p)
+    (when (called-interactively-p 'interactive)
       (if ans
          (if (= (length ans) 1)
              (message "%s" (car ans))
@@ -157,11 +174,10 @@ return nil."
        (rev nil))
     (if (not b)
        (progn
-         (when (interactive-p)
+         (when (called-interactively-p 'interactive)
            (message "ID Utils not found."))
          nil)
-      (save-excursion
-       (set-buffer b)
+      (with-current-buffer b
        (goto-char (point-min))
        (re-search-forward "fnid - \\([0-9.]+\\)" nil t)
        (setq rev (match-string 1))
@@ -171,12 +187,17 @@ return nil."
              (error "Version of ID Utils is %s.  Need at least %s"
                     rev cedet-idutils-min-version))
          ;; Else, return TRUE, as in good enough.
-         (when (interactive-p)
+         (when (called-interactively-p 'interactive)
            (message "ID Utils %s  - Good enough for CEDET." rev))
          t)))))
 
+(defun cedet-idutils-create/update-database (&optional dir)
+  "Create an IDUtils database in DIR.
+IDUtils must start from scratch when updating a database."
+  (interactive "DDirectory: ")
+  (let ((default-directory dir))
+    (cedet-idutils-mkid-call nil)))
 
 (provide 'cedet-idutils)
 
-;; arch-tag: 663ca082-5b3d-4384-8710-cc74f990b501
 ;;; cedet-idutils.el ends here