Skip to content

redguardtoo/find-and-ctags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 

Repository files navigation

find-and-ctags (v0.0.8)

This project is obsolete. You could consider using counsel-etags instead. counsel-etags is more powerful and easier to setup.

Create TAGS by combining Find and Ctags on Windows/Linux/OSX.

Why

  • Enough tools provided. You can set up any project in 1 minute
  • The TAGS file created is portable. You can use it anywhere
  • Easy to manage. All your projects settings is in your “.emacs”
  • Powerful and versatile. Power of Find/Ctags/Lisp is at your hand

Install

Place find-and-ctags.el somewhere (say ~/.emacs/lisp), add below code into “.emacs”:

(add-to-list 'load-path "~/.emacs.d/lisp/")
(require 'find-and-ctags)

Usage

Here is sample setup for project named “MYPROJ”:

(defun my-setup-develop-environment ()
  (interactive)

  (if (find-and-ctags-current-path-match-pattern-p "/MYPROJ")
      (visit-tags-table (find-and-ctags-generate-tags "~/workspace/MYPROJ" ; project directory
                                                      '(("-not -size +64k" "--exclude=*.min.js") ; (find-opts ctags-opts)
                                                        ;; you may add more find-opts ctags-opts pair HERE to run find&ctags again to APPEND to same TAGS file
                                                        ;; ctags-opts must contain "-a" to append
                                                        ;; (find-opts "-a")
                                                        ))
                        t)))
(add-hook 'prog-mode-hook 'my-setup-develop-environment) ; prog-mode require emacs24+
(add-hook 'lua-mode-hook 'my-setup-develop-environment) ; lua-mode does NOT inherit from prog-mode

;; OPTIONAL
(add-hook 'after-save-hook 'find-and-ctags-auto-update-tags)

In above setup, TAGS is updated automatically every 5 minutes. But you can alway manually update the TAGS by M-x find-and-ctags-update-all-tags-force.

Advanced Tips (OPTIONAL)

Filter files passed to Ctags

find-and-ctags-run-ctags-if-needed actually only execute the below command line in shell:

find . -type f -not -name 'TAGS' find-opts | ctags -e ctags-opts -L -

So you can insert extra command chain into find-opts.

For example, if you assign find-opts to ” | grep ‘test.*’”, the actual command to execute will be:

find . -type f -not -name 'TAGS' | grep 'test.*' | ctags -e ctags-opts -L -

Detect hostname of computer

Use API find-and-ctags-get-hostname

;; I do Javascript/HTML/Java in office and C++ at home.
;; My home PC hostname is like `AU0247589'
(if (string-match "^HOMEPC.*" (find-and-ctags-get-hostname))
  (setq my-default-ctags-options "--I IMPLEMENT_ABSTRACT_CLASS"))

Time interval to update TAGS

(setq find-and-ctags-auto-update-tags-interval 300) ; 300 seconds

Ctags setup

Google “filetype:ctags site:github.com”. Here is mine.

You may need configure environment variable “HOME” on Windows because ctags looks for “%HOME%/.ctags” by default.

Bug Report

Check https://github.com/redguardtoo/find-and-ctags.

License

Copyright (C) 2015 Chen Bin

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

About

Use `find' and `ctags' for code navigation

Resources

Stars

Watchers

Forks

Packages

No packages published