]> code.delx.au - gnu-emacs-elpa/commitdiff
New command ggtags-delete-tag-files
authorLeo Liu <sdl.web@gmail.com>
Mon, 3 Jun 2013 14:01:18 +0000 (22:01 +0800)
committerLeo Liu <sdl.web@gmail.com>
Mon, 3 Jun 2013 16:05:51 +0000 (00:05 +0800)
ggtags.el

index a37edcbcfde1f7e14b0404e972d2264174fc4f43..3fa79d0930748610a64b577c228b8f4e17c03d5a 100644 (file)
--- a/ggtags.el
+++ b/ggtags.el
       (list 'progn (list 'defvar var val docstring)
             (list 'make-variable-buffer-local (list 'quote var))))))
 
+(eval-and-compile
+  (unless (fboundp 'user-error)
+    (defalias 'user-error 'error)))
+
 (defgroup ggtags nil
   "GNU Global source code tagging system."
   :group 'tools)
@@ -305,6 +309,27 @@ When called with prefix, ask the name and kind of tag."
       (setq-local compilation-auto-jump-to-first-error nil)
       (remove-hook 'compilation-finish-functions 'ggtags-handle-single-match t))))
 
+(defun ggtags-delete-tag-files ()
+  "Delete the tag files generated by gtags."
+  (interactive)
+  (when (ggtags-root-directory)
+    (let ((files (directory-files (ggtags-root-directory) t
+                                  (regexp-opt '("GPATH" "GRTAGS" "GTAGS" "ID"))))
+          (buffer "*GTags File List*"))
+      (or files (user-error "No tag files found"))
+      (with-output-to-temp-buffer buffer
+        (dolist (file files)
+          (princ file)
+          (princ "\n")))
+      (let ((win (get-buffer-window buffer)))
+        (unwind-protect
+            (progn
+              (fit-window-to-buffer win)
+              (when (yes-or-no-p "Remove GNU Global tag files? ")
+                (mapc 'delete-file files)))
+          (when (window-live-p win)
+            (quit-window t win)))))))
+
 (defvar-local ggtags-global-exit-status nil)
 
 (defun ggtags-global-exit-message-function (_process-status exit-status msg)