trogdoro / xiki

A shell console with GUI features
http://xiki.org
Other
3.76k stars 208 forks source link

Sublime Xiki #45

Open edubkendo opened 11 years ago

edubkendo commented 11 years ago

As mentioned here , despite the fact that the Sublime Text plugin does as its supposed to, and calls to the xiki shell command, many of xiki's features still don't work. I'm assuming this means these specific features will need integration on the xiki end. Some pointers on how I could help make sublime text integration better would be much appreciated.

mrjoshuak commented 10 years ago

I'm very interested in this too. I truly believe xiki is a game changer!

I've just cracked open xiki code to try and understand / fix things. For example one gets lost pretty fast in sublime if you just follow what seems like the obvious steps. The sublimeXiki Readme says:

Useful Xiki commands:

Open xiki buffer and type 'docs', then unfold to see what happens. We get an exception right away:

docs
  > Menu doesn't exist yet
  | Create it?  Make your menu by creating one of these...
  + text file/
  - items/
    | You can type out items literally.
    @~/menu/docs.menu
      @open file//Users/joshua/menu/docs.menu
        undefined local variable or method `dir' for Xiki::DirHandler:Class
        /usr/local/xiki/lib/xiki/handlers/dir_handler.rb:12:in `handle'
        /usr/local/xiki/lib/xiki/core/menu.rb:1170:in `block in handle'
        /usr/local/xiki/lib/xiki/core/menu.rb:1167:in `each'
        /usr/local/xiki/lib/xiki/core/menu.rb:1167:in `handle'
        /usr/local/xiki/lib/xiki/core/menu.rb:1066:in `expand_menufied'
        /usr/local/xiki/lib/xiki/core/menu.rb:1002:in `expand'
        /usr/local/xiki/lib/xiki/core/expander.rb:238:in `block in expand'
        /usr/local/xiki/lib/xiki/core/expander.rb:236:in `each'
        /usr/local/xiki/lib/xiki/core/expander.rb:236:in `expand'
        /usr/local/xiki/lib/xiki/core/menu_suggester.rb:100:in `expand'
        /usr/local/xiki/lib/xiki/core/expander.rb:238:in `block in expand'
        /usr/local/xiki/lib/xiki/core/expander.rb:236:in `each'
        /usr/local/xiki/lib/xiki/core/expander.rb:236:in `expand'
        /usr/local/xiki/lib/xiki.rb:446:in `[]'
        /usr/local/xiki/etc/command/xiki_process.rb:45:in `block (3 levels) in run'
        /usr/local/xiki/etc/command/xiki_process.rb:20:in `loop'
        /usr/local/xiki/etc/command/xiki_process.rb:20:in `block (2 levels) in run'
        /usr/local/xiki/etc/command/xiki_process.rb:19:in `open'
        /usr/local/xiki/etc/command/xiki_process.rb:19:in `block in run'
        /usr/local/xiki/etc/command/xiki_process.rb:18:in `open'
        /usr/local/xiki/etc/command/xiki_process.rb:18:in `run'
        /usr/local/xiki/etc/command/xiki_process.rb:68:in `<top (required)>'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/application.rb:203:in `load'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/application.rb:203:in `start_load'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/application.rb:298:in `start'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/application_group.rb:159:in `block (2 levels) in start_all'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/application_group.rb:158:in `fork'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/application_group.rb:158:in `block in start_all'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/application_group.rb:157:in `each'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/application_group.rb:157:in `start_all'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/controller.rb:80:in `run'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons.rb:147:in `block in run'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `call'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `catch_exceptions'
        /Users/joshua/.rvm/gems/ruby-2.0.0-p353@c4Assets/gems/daemons-1.1.9/lib/daemons.rb:146:in `run'
        /usr/local/xiki/etc/command/xiki_command.rb:236:in `ctrl'
        /usr/local/xiki/etc/command/xiki_command.rb:32:in `run'
        /usr/local/xiki/bin/xiki:34:in `<top (required)>'
        /usr/bin/xiki:2:in `load'
        /usr/bin/xiki:2:in `<main>'

    + with wiki elements/
    + directions/
    + creating inline/

  + notes/
  + code/
  + more/

So I dig into that and find this code in the DirHandler:

   def self.handle options
      # Does one of these amount to non-existing dir?

      source = options[:ex]['/']
      # This will soon be refactored to be called by hash

      return if ! source || options[:output] || options[:halt]

      items = Dir.new(dir).entries.grep /^[^.]/

      items.delete "default.conf"   # ignore default conf

      items.map!{|o| File.basename(o, ".*")}   # no extensions

      items.uniq!   # no dups
      items.delete "index"   # no indexes
      items.map!{|o| "+ #{o}/\n"}   # make + foo/\n

      return if items.empty?

      items = items.join("")
      options[:output] = items

    end

Right off I don't see dir being assigned anywhere, but then I also don't know (yet) if it's being inherited somehow either. This is even broken just on the command line:

$ xiki docs/items/@~/menu/docs.menu/@open file//Users/joshua/menu/docs.menu

Same output as above. So it's not particular to Sublime text that this is happening. This kind of problem in such an early stage of using xiki, is keeping it from gaining momentum. I know I put it away for 5 months on seeing this, and only just now looking into it again.

I'll keep digging and see if I can learn enough to make a useful patch. It looks like this is code that isn't even covered by a test yet.

(And of course I would have expected the docs command to be something more special then just the typical 'unknown' menu output)