 
 (defun ectags-scan-external ()
   "Search the `ectags--file-name' for the `ectags--regexp'.
-
 Calls `ectags-match' for each line that matches."
   ;; vlf-re-search-forward - too slow
   ;; binary search - too slow and the tags file has to be sorted

(defvar ectags--fn-name nil
  "Holds the current function name (from where the tag search was initiated).")


(defun ectags-table-list ()
  "Return a list of available tag tables."
  (let (tags-table-list)
    (dolist (buffer (buffer-list) tags-table-list)
      (when (assoc 'is-ectag-table (buffer-local-variables buffer))
        (push buffer tags-table-list)))
    tags-table-list))

(defun ectags-expand-tag-file-name (file)
  "Expand the given FILE to full path if needed."
  (setq file (expand-file-name file))
  (if (file-directory-p file)
      (expand-file-name "tags" file)
    file))

(defun ectags-verify-tags-file (file)
  "Validate that the FILE is a valid ctags table."
  (string-prefix-p
   "!_TAG_FILE_FORMAT"
   (shell-command-to-string (format "head -n1 %s" file))))

;;;###autoload
(defun ectags-visit-tags-table ()
  "Visit an exuberant ctags file and add it to the current list of tags tables."
  (interactive
   (list (read-file-name "Visit tags table (default tags): "
                         default-directory
                         (expand-file-name "tags"
                                           default-directory)
                         t)))
  (let ((current-dir default-directory)
        (local-tags-filename (ectags-expand-tag-file-name default-directory))
        (checked-dirs 5))
    (while (and (not (file-exists-p local-tags-filename))
                (not (ectags-verify-tags-file local-tags-filename))
                (> checked-dirs 0))
      (setq current-dir (file-name-directory (directory-file-name current-dir)))
      (setq local-tags-filename (ectags-expand-tag-file-name current-dir))
      (setq checked-dirs (1- checked-dirs)))

    (if (and (> checked-dirs 0)
             (ectags-verify-tags-file local-tags-filename))
        (progn
          (setq ectags--file-name local-tags-filename)
          t)
      (error "Not a valid tags table")
      nil)))

(defun ectags-match-tagname (tag-match)
  "Return the tag name from the TAG-MATCH."

        (setq tag-info (replace-regexp-in-string "typeref:typename:" "type:" tag-info))
        tag-info))))

(defvar ectags-mode-map
  (let ((map (make-keymap)))
    (define-key map (kbd "<return>") #'ectags-goto-tag)
