[TxMt] sbenhaim - tm-ctags author - an extension to this bundle

Dave Baldwin dave.baldwin at 3dlabs.com
Thu Jun 17 09:43:00 UTC 2010


Hi,

I have added a command to allow you to retrace your steps so you can easily get back to where you came from.  You may want to include it.

The modified goto method and two new methods in tm_ctags.rb are:

  def historyFile
	File.join(ENV['TM_PROJECT_DIRECTORY'] || ENV['TM_CTAGS_EXT_LIB'], ".etag_history")
  end

  def goto( hit )
	# Record where we are before we jump.
	File.open(historyFile, "a") {|f| f.puts ENV['TM_FILEPATH'] + '%%' + ENV['TM_LINE_NUMBER']}
    TextMate.go_to :file => File.join(hit['f'], hit['path']), :line => hit['line']
  end
  
  def goback
	history = File.readlines(historyFile) if File.exists?(historyFile)
	goto = history.pop if history
	
	if goto && goto =~ /(.*)%%(.*)/
		File.open(historyFile, "w") {|f| f.puts history.join("\n")}
		TextMate.go_to :file => $1, :line => $2 
	end
  end


and the only change to tmctags.rb is to extend the action case to include a new one:
when 'goback'
	TM_Ctags::goback
  	exit

I added a new command to call this function and tied it to ^[

Dave.







More information about the textmate mailing list