]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/cedet-idutils.el
lisp/startup.el (argi): Declare as global variable (bug#9275).
[gnu-emacs] / lisp / cedet / cedet-idutils.el
index f550e2af5060754306bfec9d6d9cd24352067964..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.
 
@@ -28,6 +29,8 @@
 
 ;;; Code:
 
+(declare-function inversion-check-version "inversion")
+
 (defvar cedet-idutils-min-version "4.0"
   "Minimum version of ID Utils required.")
 
   :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 IDUtils, return the created buffer.
+  "Perform a search with ID Utils, return the created buffer.
 SEARCHTEXT is text to find.
 TEXTTYPE is the type of text, such as 'regexp, 'string, 'tagname,
 'tagregexp, or 'tagcompletions.
@@ -71,8 +79,8 @@ Note: Scope is not yet supported."
                         ;; t means 'symbol
                         (t (list "-l" "-w"))))
           )
-      (cedet-idutils-lid-call (append resultflg scopeflgs stflag (list searchtext))))
-    ))
+      (cedet-idutils-lid-call (append resultflg scopeflgs stflag
+                                     (list searchtext))))))
 
 (defun cedet-idutils-fnid-call (flags)
   "Call ID Utils fnid with the list of FLAGS.
@@ -80,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
@@ -95,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
@@ -104,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 IDUtils.
+  "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))
@@ -127,7 +146,7 @@ Return a filename relative to the default directory."
     ans))
 
 (defun cedet-idutils-support-for-directory (&optional dir)
-  "Return non-nil if IDUtils has a support file for DIR.
+  "Return non-nil if ID Utils has a support file for DIR.
 If DIR is not supplied, use the current default directory.
 This works by running lid on a bogus symbol, and looking for
 the error code."
@@ -142,8 +161,6 @@ the error code."
              t))
        (error nil)))))
 
-(declare-function inversion-check-version "inversion")
-
 (defun cedet-idutils-version-check (&optional noerror)
   "Check the version of the installed ID Utils command.
 If optional programatic argument NOERROR is non-nil, then
@@ -157,24 +174,29 @@ 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))
        (if (inversion-check-version rev nil cedet-idutils-min-version)
            (if noerror
                nil
-             (error "Version of ID Utis is %s.  Need at least %s"
+             (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)