ctags tweaking

Sun, 12 Apr 2015 00:40:35 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 12 Apr 2015 00:40:35 -0400
changeset 180
96dbe6a6008d
parent 179
fe7e8d6d1853
child 181
83459cf3d815

ctags tweaking

.git_helpers/ctags file | annotate | diff | comparison | revisions
.git_helpers/hooks/post-checkout file | annotate | diff | comparison | revisions
.git_helpers/hooks/post-commit file | annotate | diff | comparison | revisions
.git_helpers/hooks/post-merge file | annotate | diff | comparison | revisions
.git_helpers/hooks/post-rewrite file | annotate | diff | comparison | revisions
.gitconfig file | annotate | diff | comparison | revisions
.vimrc file | annotate | diff | comparison | revisions
new file mode 100755
--- /dev/null
+++ b/.git_helpers/ctags
@@ -0,0 +1,39 @@
+#!/usr/bin/env ruby
+
+# Meant for use as a git hook:
+#   CTAGS_HOOK=1 .git/hooks/ctags &>/dev/null </dev/null &
+# or an aliased cmd on demand:
+#   git config alias.ctags '!.git/hooks/ctags'
+# or disable when you wish:
+#   CTAGS_SKIP=1 git rebase
+
+exit if ENV['CTAGS_SKIP']
+
+ctags  = "/opt/local/bin/ctags"
+ctags  = 'ctags' if !File.exists?(ctags)
+
+dir    = `git rev-parse --show-toplevel`.chomp
+
+conf   = "#{dir}/.git/ctags.conf"
+target = "#{dir}/.tags"
+tmp    = "#{dir}/#{$$}.tags"
+
+opts   = File.exists?(conf) ? "--options=#{conf}" : ''
+
+sleep 10 if ENV['CTAGS_HOOK']
+
+open( target, File::RDONLY|File::CREAT, 0644 ) do |f|
+  if ENV['CTAGS_HOOK']
+    exit unless f.flock( File::LOCK_EX|File::LOCK_NB )
+    exit unless ( Time.now - f.mtime ) > 60
+  end
+
+  system( <<-CMD ) or exit $?.exitstatus
+    git ls-files \
+     | #{ctags} --tag-relative -L - -f"#{tmp}" #{opts} \
+    && mv #{tmp} #{target}
+  CMD
+end
+
+
+
new file mode 100755
--- /dev/null
+++ b/.git_helpers/hooks/post-checkout
@@ -0,0 +1,5 @@
+#!/bin/sh
+export PATH=/opt/local/bin:${PATH}
+export CTAGS_HOOK=1
+
+~/.git_helpers/ctags >/dev/null 2>&1 </dev/null &
new file mode 100755
--- /dev/null
+++ b/.git_helpers/hooks/post-commit
@@ -0,0 +1,5 @@
+#!/bin/sh
+export PATH=/opt/local/bin:${PATH}
+export CTAGS_HOOK=1
+
+~/.git_helpers/ctags >/dev/null 2>&1 </dev/null &
new file mode 100755
--- /dev/null
+++ b/.git_helpers/hooks/post-merge
@@ -0,0 +1,5 @@
+#!/bin/sh
+export PATH=/opt/local/bin:${PATH}
+export CTAGS_HOOK=1
+
+~/.git_helpers/ctags >/dev/null 2>&1 </dev/null &
new file mode 100755
--- /dev/null
+++ b/.git_helpers/hooks/post-rewrite
@@ -0,0 +1,4 @@
+#!/bin/sh
+case "$1" in
+  rebase) exec .git/hooks/post-merge ;;
+esac
--- a/.gitconfig
+++ b/.gitconfig
@@ -16,6 +16,7 @@
 	outgoing  = log @{u}..
 	glog      = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
 	cleanup   = "!git branch --merged | grep  -v '\\*\\|master\\|develop' | xargs -n 1 echo git branch -d"
+	ctags     = !~/.git_helpers/ctags
 
 [branch]
 	autosetuprebase = always
--- a/.vimrc
+++ b/.vimrc
@@ -186,6 +186,8 @@ set ruler
 set showcmd
 set wildmenu
 
+set tags+=.tags
+
 " Ignore compiled files and repositories
 set wildignore=*.o,*~,*.pyc
 if on_windows == 1
@@ -293,6 +295,7 @@ function! PerlSettings ()
   " that's just noisy with intentional no-warnings blocks out there
 
   setlocal makeprg=perl\ -c\ %\ $*
+  setlocal iskeyword+=:
 endfunction
 
 " perl fold scanning is slow

mercurial