Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding customisable strategies (with one default) for determining whi…

…ch backend to use (ie, gtags, etc. Warning: backends not implemented yet :))
  • Loading branch information...
commit acfeffbdf62320a41b5d51206e3ac061585f9222 1 parent 04f77e8
Mark Hepburn authored

Showing 1 changed file with 38 additions and 0 deletions. Show diff stats Hide diff stats

  1. 38  tags-view.el
38  tags-view.el
@@ -66,7 +66,45 @@
66 66
   '((t (:foreground "gray" :weight 'light)))
67 67
   "Face used to display the header of each tag entry.")
68 68
 
  69
+(defvar tv-determine-backend-function 'tv-determine-backend-directory-search
  70
+  "Value should be a function of no arguments that returns a
  71
+  symbol indicating which backend should be used, or 'none if not
  72
+  applicable.")
  73
+
  74
+(defun tv-determine-backend ()
  75
+  "Returns a symbol indicating which backend should be used (eg,
  76
+  'etags, 'gtags, etc)."
  77
+  (funcall tv-determine-backend-function))
  78
+
  79
+(defun tv-determine-backend-directory-search ()
  80
+  "Determine which of gtags, etags, etc we should be assuming by
  81
+recursively searching parent directories looking for TAGS, GTAGS,
  82
+etc."
  83
+  ;; Try just looking through parent directories for tell-tale files:
  84
+  (let ((working-dir (or (and (buffer-file-name)
  85
+                              (file-name-directory (buffer-file-name)))
  86
+                         (pwd))))
  87
+    (labels
  88
+        ((rec (dir)
  89
+              (cond
  90
+               ((file-exists-p (concat dir "GTAGS"))
  91
+                (throw 'exit 'gtags))
  92
+               ((file-exists-p (concat dir "TAGS"))
  93
+                (throw 'exit 'etags))
  94
+               ;; if we've reached the end of the road, we're done:
  95
+               ((string= dir (file-name-directory (directory-file-name dir)))
  96
+                (throw 'exit 'none))
  97
+               ;; else, keep recursing:
  98
+               (t (rec (file-name-directory (directory-file-name dir)))))))
  99
+      (catch 'exit (rec working-dir)))))
  100
+
69 101
 (defun tv-view-history ()
  102
+  "The main entry point; pops open a buffer with the list of
  103
+locations on the tag stack that can then optionally be operated
  104
+on (eg, jumping to that location, deleting it from the list,
  105
+etc).  The following options will be available:
  106
+
  107
+\\{tags-history-mode-map}"
70 108
   (interactive)
71 109
   (let ((buf (get-buffer-create "*tags history*")))
72 110
     (pop-to-buffer buf)

0 notes on commit acfeffb

Please sign in to comment.
Something went wrong with that request. Please try again.