2016-06-08 03:10:27 -04:00
|
|
|
;;; custom-tags.el
|
2016-05-08 18:29:07 -04:00
|
|
|
|
2016-09-19 17:48:12 +02:00
|
|
|
;; TODO Finish me!
|
2016-05-08 18:29:07 -04:00
|
|
|
|
2016-05-20 22:37:30 -04:00
|
|
|
(defvar doom-ctags-alist
|
2016-05-08 18:29:07 -04:00
|
|
|
'((ruby-mode :exec "ripper-tags -R -f %t --emacs")
|
|
|
|
(c++-mode :ext "cpp")
|
|
|
|
(c-mode :ext "c")
|
|
|
|
(all :exec "find . -type f -iname \"*.%e\" | ctags -e -f %t -")
|
|
|
|
;; TODO add c-mode/c++-mode ctags
|
|
|
|
))
|
|
|
|
|
|
|
|
|
2016-05-20 22:37:30 -04:00
|
|
|
(add-hook 'find-file-hook 'doom|init-tags)
|
|
|
|
(defun doom|init-tags ()
|
|
|
|
(awhen (doom/tags-p)
|
2016-05-08 18:29:07 -04:00
|
|
|
(setq tags-table-list (list it))))
|
|
|
|
|
|
|
|
;; TODO
|
2016-05-20 22:37:30 -04:00
|
|
|
;; (defun doom/tags-generate ()
|
2016-05-08 18:29:07 -04:00
|
|
|
;; (interactive)
|
2016-05-20 22:37:30 -04:00
|
|
|
;; (let ((command (assoc major-mode doom-ctags-alist))
|
|
|
|
;; (default-directory (doom/project-root)))
|
2016-05-08 18:29:07 -04:00
|
|
|
;; (unless command
|
|
|
|
;; (user-error "No tag generator for %s" major-mode))
|
2016-05-20 22:37:30 -04:00
|
|
|
;; (async-shell-command command "*doom:generate-tags*")))
|
2016-05-08 18:29:07 -04:00
|
|
|
|
|
|
|
;;;###autoload
|
2016-05-20 22:37:30 -04:00
|
|
|
(defun doom/find-def ()
|
2016-06-08 03:10:27 -04:00
|
|
|
"Find definition using tags, falling back to dumb-jump otherwise."
|
2016-05-08 18:29:07 -04:00
|
|
|
(interactive)
|
|
|
|
(let ((orig-pt (point))
|
|
|
|
(orig-file (buffer-file-name)))
|
2016-05-20 22:37:30 -04:00
|
|
|
(cond ((and (doom/tags-p)
|
2016-09-07 12:19:50 +02:00
|
|
|
;; TODO
|
|
|
|
;; (progn (call-interactively 'helm-etags-select)
|
|
|
|
;; (and (/= orig-pt (point))
|
|
|
|
;; (f-same? orig-file buffer-file-name)))
|
|
|
|
))
|
2016-05-08 18:29:07 -04:00
|
|
|
((progn (dumb-jump-go)
|
|
|
|
(and (/= orig-pt (point))
|
|
|
|
(f-same? orig-file buffer-file-name))))
|
|
|
|
(t (call-interactively 'evil-goto-definition)))))
|
|
|
|
|
|
|
|
;;;###autoload
|
2016-05-20 22:37:30 -04:00
|
|
|
(defun doom/tags-p ()
|
|
|
|
(let ((path (expand-file-name ".tags" (doom/project-root))))
|
2016-05-08 18:29:07 -04:00
|
|
|
(and (f-exists? path) path)))
|
|
|
|
|
2016-06-08 03:10:27 -04:00
|
|
|
(provide 'custom-tags)
|
|
|
|
;;; custom-tags.el ends here
|