Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello! I've added autoflushing on filesystem changes! #13

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .bundle/config
@@ -1,3 +1,2 @@
--- ---
BUNDLE_BIN: bin BUNDLE_BIN: bin
BUNDLE_DISABLE_SHARED_GEMS: "1"
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
.release-notes.txt .release-notes.txt
command-t.recipe command-t.recipe
.DS_Store
1 change: 1 addition & 0 deletions .rvmrc
@@ -0,0 +1 @@
rvm use ruby-1.8.7-p334@commandt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing you didn't mean to include this in the pull request.

1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -3,3 +3,4 @@ gem 'mechanize'
gem 'rake' gem 'rake'
gem 'rr' gem 'rr'
gem 'rspec', '>= 2.0.0.rc' gem 'rspec', '>= 2.0.0.rc'
gem 'rb-fsevent'
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -6,6 +6,7 @@ GEM
nokogiri (>= 1.2.1) nokogiri (>= 1.2.1)
nokogiri (1.4.4) nokogiri (1.4.4)
rake (0.8.7) rake (0.8.7)
rb-fsevent (0.4.0)
rr (1.0.2) rr (1.0.2)
rspec (2.5.0) rspec (2.5.0)
rspec-core (~> 2.5.0) rspec-core (~> 2.5.0)
Expand All @@ -22,5 +23,6 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
mechanize mechanize
rake rake
rb-fsevent
rr rr
rspec (>= 2.0.0.rc) rspec (>= 2.0.0.rc)
1 change: 1 addition & 0 deletions command-t
2 changes: 2 additions & 0 deletions doc/command-t.txt
Expand Up @@ -146,6 +146,8 @@ you can build the extension with:
cd ~/.vim/ruby/command-t cd ~/.vim/ruby/command-t
ruby extconf.rb ruby extconf.rb
make make
cd ../rb-fsevent/ext
ruby extconf.rb


Note: If you are an RVM user, you must perform the build using the same Note: If you are an RVM user, you must perform the build using the same
version of Ruby that Vim itself is linked against. This will often be the version of Ruby that Vim itself is linked against. This will often be the
Expand Down
4 changes: 2 additions & 2 deletions plugin/command-t.vim
Expand Up @@ -145,7 +145,7 @@ ruby << EOF
require 'command-t/vim' require 'command-t/vim'
require 'command-t/controller' require 'command-t/controller'
$command_t = CommandT::Controller.new $command_t = CommandT::Controller.new
rescue LoadError rescue LoadError => e
load_path_modified = false load_path_modified = false
::VIM::evaluate('&runtimepath').to_s.split(',').each do |path| ::VIM::evaluate('&runtimepath').to_s.split(',').each do |path|
lib = "#{path}/ruby" lib = "#{path}/ruby"
Expand All @@ -159,6 +159,6 @@ ruby << EOF
# could get here if C extension was not compiled, or was compiled # could get here if C extension was not compiled, or was compiled
# for the wrong architecture or Ruby version # for the wrong architecture or Ruby version
require 'command-t/stub' require 'command-t/stub'
$command_t = CommandT::Stub.new $command_t = CommandT::Stub.new(e)
end end
EOF EOF
6 changes: 6 additions & 0 deletions ruby/command-t/finder/file_finder.rb
Expand Up @@ -24,12 +24,18 @@
require 'command-t/ext' # CommandT::Matcher require 'command-t/ext' # CommandT::Matcher
require 'command-t/finder' require 'command-t/finder'
require 'command-t/scanner/file_scanner' require 'command-t/scanner/file_scanner'
require 'rb-fsevent/lib/rb-fsevent'


module CommandT module CommandT
class FileFinder < Finder class FileFinder < Finder
def initialize path = Dir.pwd, options = {} def initialize path = Dir.pwd, options = {}
@scanner = FileScanner.new path, options @scanner = FileScanner.new path, options
@matcher = Matcher.new @scanner, options @matcher = Matcher.new @scanner, options
fsevent = FSEvent.new
fsevent.watch Dir.pwd, { :latency => 1 } do |directories|
flush
end
Thread.new { fsevent.run }
end end
end # class FileFinder end # class FileFinder
end # CommandT end # CommandT
10 changes: 8 additions & 2 deletions ruby/command-t/stub.rb
Expand Up @@ -28,11 +28,17 @@ class Stub
'For more information type: :help command-t'] 'For more information type: :help command-t']


def show_file_finder def show_file_finder
warn *@@load_error warn *error_message
end end


def flush def flush
warn *@@load_error warn *error_message
end
def initialize(e)
@e = e
end
def error_message
[@e.message] + @e.backtrace
end end


private private
Expand Down
20 changes: 20 additions & 0 deletions ruby/rb-fsevent/LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2011 Thibaud Guillaume-Gentil

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file added ruby/rb-fsevent/bin/fsevent_watch
Binary file not shown.
128 changes: 128 additions & 0 deletions ruby/rb-fsevent/ext/Makefile
@@ -0,0 +1,128 @@

SHELL = /bin/sh

#### Start of system configuration section. ####

srcdir = .
topdir = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0
hdrdir = $(topdir)
VPATH = $(srcdir):$(topdir):$(hdrdir)
exec_prefix = $(prefix)
prefix = $(DESTDIR)/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr
sharedstatedir = $(prefix)/com
mandir = $(DESTDIR)/usr/share/man
psdir = $(docdir)
oldincludedir = $(DESTDIR)/usr/include
localedir = $(datarootdir)/locale
bindir = $(exec_prefix)/bin
libexecdir = $(exec_prefix)/libexec
sitedir = $(DESTDIR)/Library/Ruby/Site
htmldir = $(docdir)
vendorarchdir = $(vendorlibdir)/$(sitearch)
includedir = $(prefix)/include
infodir = $(DESTDIR)/usr/share/info
vendorlibdir = $(vendordir)/$(ruby_version)
sysconfdir = $(prefix)/etc
libdir = $(exec_prefix)/lib
sbindir = $(exec_prefix)/sbin
rubylibdir = $(libdir)/ruby/$(ruby_version)
docdir = $(datarootdir)/doc/$(PACKAGE)
dvidir = $(docdir)
vendordir = $(libdir)/ruby/vendor_ruby
datarootdir = $(prefix)/share
pdfdir = $(docdir)
archdir = $(rubylibdir)/$(arch)
sitearchdir = $(sitelibdir)/$(sitearch)
datadir = $(datarootdir)
localstatedir = $(prefix)/var
sitelibdir = $(sitedir)/$(ruby_version)

CC = gcc
LIBRUBY = $(LIBRUBY_SO)
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)

RUBY_EXTCONF_H =
CFLAGS = -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common $(cflags)
INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
DEFS =
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
CXXFLAGS = $(CFLAGS)
ldflags = -L. -arch i386 -arch x86_64
dldflags =
archflag =
DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
LDSHARED = cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup
AR = ar
EXEEXT =

RUBY_INSTALL_NAME = ruby
RUBY_SO_NAME = ruby
arch = universal-darwin10.0
sitearch = universal-darwin10.0
ruby_version = 1.8
ruby = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
RUBY = $(ruby)
RM = rm -f
MAKEDIRS = mkdir -p
INSTALL = /usr/bin/install -c
INSTALL_PROG = $(INSTALL) -m 0755
INSTALL_DATA = $(INSTALL) -m 644
COPY = cp

#### End of system configuration section. ####

preload =

libpath = . $(libdir)
LIBPATH = -L. -L$(libdir)
DEFFILE =

CLEANFILES = mkmf.log
DISTCLEANFILES =

extout =
extout_prefix =
target_prefix =
LOCAL_LIBS =
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl
SRCS =
OBJS =
TARGET =
DLLIB =
EXTSTATIC =
STATIC_LIB =

BINDIR = $(bindir)
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
RUBYARCHDIR = $(sitearchdir)$(target_prefix)

TARGET_SO = $(DLLIB)
CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak

all: Makefile
static: $(STATIC_LIB)

clean:
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)

distclean: clean
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)

realclean: distclean
install: install-so install-rb

install-so: Makefile
install-rb: pre-install-rb install-rb-default
install-rb-default: pre-install-rb-default
pre-install-rb: Makefile
pre-install-rb-default: Makefile

site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb

50 changes: 50 additions & 0 deletions ruby/rb-fsevent/ext/extconf.rb
@@ -0,0 +1,50 @@
# Workaround to make Rubygems believe it builds a native gem
require 'mkmf'
create_makefile('none')

if `uname -s`.chomp != 'Darwin'
puts "Warning! Only Darwin (Mac OS X) systems are supported, nothing will be compiled"
else
gem_root = File.expand_path(File.join('..'))
darwin_version = `uname -r`.to_i
sdk_version = { 9 => '10.5', 10 => '10.6', 11 => '10.7' }[darwin_version]

raise "Only Darwin systems greater than 8 (Mac OS X 10.5+) are supported" unless sdk_version

core_flags = %W{
-isysroot /Developer/SDKs/MacOSX#{sdk_version}.sdk
-mmacosx-version-min=#{sdk_version} -mdynamic-no-pic -std=gnu99
}

cflags = core_flags + %w{-Os -pipe}

wflags = %w{
-Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch
-Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable
-Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow
-Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion
-Wshorten-64-to-32 -Wglobal-constructors -pedantic
}

ldflags = %w{
-dead_strip -framework CoreServices
}

gcc_opts = core_flags + ldflags

gcc_opts += %w{
-D DEBUG=true
} if ENV['FWDEBUG'] == "true"

compile_command = "CFLAGS='#{cflags.join(' ')} #{wflags.join(' ')}' /usr/bin/gcc #{gcc_opts.join(' ')} -o '#{gem_root}/bin/fsevent_watch' fsevent/fsevent_watch.c"

STDERR.puts(compile_command)

# Compile the actual fsevent_watch binary
system "mkdir -p #{File.join(gem_root, 'bin')}"
system compile_command

unless File.executable?("#{gem_root}/bin/fsevent_watch")
raise "Compilation of fsevent_watch failed (see README)"
end
end