-;; Time-stamp: <2014-03-08 16:13:14 kmodi>
+;; Time-stamp: <2014-03-09 04:57:01 kmodi>
 
 ;; ctags, etags
 

;;  1 -> (etags-select-by-tag-number "1")
;;  ..                               ..
;;  9 -> (etags-select-by-tag-number "9")

;; (defun my-find-tag ()
;;   (interactive)
;;   (if (file-exists-p (concat user-emacs-directory "/TAGS"))
;;       (update-ctags)
;;     (build-ctags))
;;   (when (boundp 'setup-sos-loaded)
;;     (if (file-exists-p (concat project-root "TAGS"))
;;         (update-ctags)
;;       (build-ctags)))
;;   (etags-select-find-tag-at-point))

;; ;; Source: http://www.emacswiki.org/EtagsSelect
;; ;; Use ido to list tags, but then select via etags-select (best of both worlds!)
;; (defun my-ido-find-tag ()
;;   "Find a tag using ido"
;;   (interactive)
;;   (tags-completion-table)
;;   (let (tag-names)
;;     (mapatoms (lambda (x)
;;                 (push (prin1-to-string x t) tag-names))
;;               tags-completion-table)
;;     (etags-select-find (ido-completing-read "Tag: " tag-names))))
;; ;; (global-set-key (kbd "M-.") 'my-ido-find-tag)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Don't warn when TAGS files are large
(setq large-file-warning-threshold nil)

;; List all directories from which you want to read the TAGS files
(setq tags-table-list '("~/.emacs.d"))

(if (boundp 'setup-sos-loaded)
    (add-to-list 'tags-table-list project-root t))

(defun build-ctags ()
  (interactive)
  (loop for dir in tags-table-list do
        (message (concat "building tags in " dir))
        (shell-command (concat "ctags -Re -f " dir "/TAGS " dir)))
  (message "tags built successfully"))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
