]> code.delx.au - gnu-emacs-elpa/blobdiff - ggtags.el
Fix #59: detect missing tag files and remove project cache
[gnu-emacs-elpa] / ggtags.el
index fa538438f176c318361d2080d11a4423ba5803d5..15b0b0ed17aa34afb9a12aa69585309ee6b7e15f 100644 (file)
--- a/ggtags.el
+++ b/ggtags.el
 
 (defcustom ggtags-oversize-limit (* 10 1024 1024)
   "The over size limit for the  GTAGS file.
-For large source trees, running 'global -u' can be expensive.
-Thus when GTAGS file is larger than this limit, ggtags
-automatically switches to 'global --single-update'."
+When the size of the GTAGS file is below this limit, ggtags
+always maintains up-to-date tags for the whole source tree by
+running `global -u'. For projects with GTAGS larger than this
+limit, only files edited in Ggtags mode are updated (via `global
+--single-update')."
   :safe 'numberp
   :type '(choice (const :tag "None" nil)
                  (const :tag "Always" t)
@@ -286,6 +288,13 @@ properly update `ggtags-mode-map'."
   :type 'key-sequence
   :group 'ggtags)
 
+(defcustom ggtags-completing-read-function nil
+  "Ggtags specific `completing-read-function' (which see).
+Nil means using the value of `completing-read-function'."
+  :type '(choice (const :tag "Use completing-read-function" nil)
+                 function)
+  :group 'ggtags)
+
 (defcustom ggtags-highlight-tag-delay 0.25
   "Time in seconds before highlighting tag at point."
   :set (lambda (sym value)
@@ -769,9 +778,12 @@ Do nothing if GTAGS exceeds the oversize limit unless FORCE."
     (setq ggtags-current-tag-name
           (cond (confirm
                  (ggtags-update-tags)
-                 (completing-read
-                  (format (if default "%s (default %s): " "%s: ") prompt default)
-                  ggtags-completion-table nil require-match nil nil default))
+                 (let ((completing-read-function
+                        (or ggtags-completing-read-function
+                            completing-read-function)))
+                   (completing-read
+                    (format (if default "%s (default %s): " "%s: ") prompt default)
+                    ggtags-completion-table nil require-match nil nil default)))
                 (default (substring-no-properties default))
                 (t (ggtags-read-tag type t prompt require-match default))))))
 
@@ -882,7 +894,7 @@ definition tags."
         (not buffer-file-name)
         (not (ggtags-project-has-refs (ggtags-find-project)))
         (not (ggtags-project-file-p buffer-file-name)))
-    (ggtags-find-tag 'definition (shell-quote-argument name)))
+    (ggtags-find-definition name))
    (t (ggtags-find-tag (format "--from-here=%d:%s"
                                (line-number-at-pos)
                                (shell-quote-argument
@@ -898,6 +910,11 @@ definition tags."
       (goto-char (posn-point (event-start event)))
       (call-interactively #'ggtags-find-tag-dwim))))
 
+;; Another option for `M-.'.
+(defun ggtags-find-definition (name)
+  (interactive (list (ggtags-read-tag 'definition current-prefix-arg)))
+  (ggtags-find-tag 'definition (shell-quote-argument name)))
+
 (defun ggtags-setup-libpath-search (type name)
   (pcase (and ggtags-global-search-libpath-for-reference
               (ggtags-get-libpath))
@@ -1451,7 +1468,17 @@ commands `next-error' and `previous-error'.
       (funcall cont buf how)))
    ((string-prefix-p "exited abnormally" how)
     ;; If exit abnormally display the buffer for inspection.
-    (ggtags-global--display-buffer))
+    (ggtags-global--display-buffer)
+    (when (save-excursion
+            (goto-char (point-max))
+            (re-search-backward
+             (eval-when-compile
+               (format "^global: %s not found.$"
+                       (regexp-opt '("GTAGS" "GRTAGS" "GSYMS" "GPATH"))))
+             nil t))
+      (ggtags-echo "WARNING: Global tag files missing in `%s'"
+                   ggtags-project-root)
+      (remhash ggtags-project-root ggtags-projects)))
    (ggtags-auto-jump-to-match
     (if (pcase (compilation-next-single-property-change
                 (point-min) 'compilation-message)
@@ -1480,6 +1507,10 @@ commands `next-error' and `previous-error'.
   ;; Note: Place `ggtags-global-output-format' as first element for
   ;; `ggtags-abbreviate-files'.
   (setq-local compilation-error-regexp-alist (list ggtags-global-output-format))
+  (when (markerp ggtags-global-start-marker)
+    (setq ggtags-project-root
+          (buffer-local-value 'ggtags-project-root
+                              (marker-buffer ggtags-global-start-marker))))
   (pcase ggtags-auto-jump-to-match
     (`history (make-local-variable 'ggtags-auto-jump-to-match-target)
               (setq-local compilation-auto-jump-to-first-error