From a3be819fed1a0e0572dd0cfbd4123c47db07190d Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 2 Feb 2016 16:55:26 +0330 Subject: [PATCH] ctag code for ruby added --- lib/extensions/ruby/init.el | 2 ++ lib/extensions/ruby/setup.el | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/extensions/ruby/init.el b/lib/extensions/ruby/init.el index 4a8037f..db746a1 100644 --- a/lib/extensions/ruby/init.el +++ b/lib/extensions/ruby/init.el @@ -8,6 +8,8 @@ (setup-inf-ruby) (setup-bundler) + (global-set-key (kbd "M-.") 'my-find-tag) + (with-ability rbenv (require 'rbenv) (global-rbenv-mode)) diff --git a/lib/extensions/ruby/setup.el b/lib/extensions/ruby/setup.el index eabe7fd..dfa9316 100644 --- a/lib/extensions/ruby/setup.el +++ b/lib/extensions/ruby/setup.el @@ -61,4 +61,30 @@ ;; Hack autocomplete so it treat :symbole and symbole the same way (modify-syntax-entry ?: ".")) + +;;;###autoload +(defun visit-project-tags () + (interactive) + (let ((tags-file (concat (projectile-project-root) "TAGS"))) + (visit-tags-table tags-file) + (message (concat "Loaded " tags-file)))) + +;;;###autoload +(defun build-ctag-file () + "Create the ctag of the ruby project" + (interactive) + (message "building project tags") + (let ((root (projectile-project-root))) + (shell-command (concat "ctags -e -R . $(bundle list --paths) --extra=+fq --exclude=db --exclude=test --exclude=.git --exclude=public -f " root "TAGS " root))) + (visit-project-tags) + (message "tags built successfully")) + +;;;###autoload +(defun my-find-tag () + (interactive) + (if (file-exists-p (concat (projectile-project-root) "TAGS")) + (visit-project-tags) + (build-ctags)) + (etags-select-find-tag-at-point)) + (provide 'extensions/ruby/setup)