Permalink
Browse files

Command: got it working.

  • Loading branch information...
1 parent 4d21dc3 commit f5b27ed46ef322327b2b18455c5b22a0e459602b @trogdoro committed Jul 13, 2012
View
@@ -2,24 +2,34 @@
#
# > Summary
-# This is aliased to /usr/local/bin/xiki so it can be called from the command
-# line to open a xiki menu in a shrunk-down window.
+# This file is aliased to /usr/local/bin/xiki, so it can be
+# called from the command line. It exposes xiki menus.
+#
+# > Example
+# $ xiki ip
+# 111.1.1.111
#
# To create the alias, see:
# @xiki/setup/install command/
#
-# require "/projects/xiki/ol"
+require 'rubygems'
+
+# Generate with correct path (see below)
+xiki_dir = "/projects/xiki/"
+
+require "#{xiki_dir}/ol"
+
+$:.unshift xiki_dir.sub(/\/$/, '')
+$:.unshift '/projects/xiki/etc/stubs/'
-# Bring emacs to front
+load "xiki_command.rb"
+result = XikiCommand.run
-`open "/Applications/Aquamacs Emacs.app"`
-# `open "/Applications/emacs.app"` # If you're not using Aquamacs
+exit 0
-menu = ARGV.join(' ')
+# TODO: Start with template, and when installing, change:
+ # - #!.. line to: result of: `which ruby`
+ # - xiki_dir to: Xiki.dir
-ruby = %`Menu.external \\"#{menu}\\"`
-ruby << %`, :dir=>\\"#{Dir.pwd}\\"` if menu =~ /^@/
-command = %`emacsclient -n -e '(el4r-ruby-eval "#{ruby}")'`
-`#{command}`
View
@@ -228,7 +228,7 @@ def self.do_keys
# Use D prefix for: things that modify text or execute code
# Keys.D { insert "Apparently this is necessary to remap C-d" }
- Keys.DD { delete_char $el.elvar.current_prefix_arg || 1 } # DD - delete character (D's default)
+ Keys.DD { $el.delete_char $el.elvar.current_prefix_arg || 1 } # DD - delete character (D's default)
# Keys.do_as_camelcase { Clipboard.do_as_camel_case } # change word to camel case (LikeThat)
Keys.do_as_execute { Console.do_as_execute } # Run shell command on tree
Keys.do_as_html { Firefox.do_as_html }
@@ -323,7 +323,7 @@ def self.do_keys
Keys.do_viewing { Buffers.open_viewing } # Not great fit here
Keys.do_whitespace { Deletes.delete_whitespace } # delete blank lines
# X
- Keys.do_you { delete_char $el.elvar.current_prefix_arg || 1 } # Delete character
+ Keys.do_you { $el.delete_char $el.elvar.current_prefix_arg || 1 } # Delete character
Keys.do_zip_next { Files.zip }
Keys.set("C-d C-.") { # Do .: Go to point/bookmark starting with "." and run it (like pressing C-. on that line)
input = Keys.input(:timed => true)
View
@@ -1,14 +1,12 @@
require 'effects'
-
require 'requirer'
+require 'xiki'
-# require 'xiki'
-Requirer.require_gem 'httparty' # Not super-important
+Requirer.require_gem 'httparty', :optional=>1 # Not super-important
Requirer.require_gem 'activesupport', :name2=>'active_support/ordered_hash'
Requirer.require_gem 'haml', :optional=>1
class Launcher
- extend ElMixin
CLEAR_CONSOLES = [
"*ol",
@@ -248,7 +246,7 @@ def self.launch options={}
rescue RelinquishException
next # They didn't want to handle it, keep going
rescue Exception=>e
- Tree.<< CodeTree.draw_exception(e, block.to_ruby), :no_slash=>ENV['no_slash']
+ Tree.<< CodeTree.draw_exception(e, block.to_ruby), :no_slash=>true
end
end
@@ -1179,7 +1177,6 @@ def self.wrapper_rakefile dir, file, path
end
def self.reload_menu_dirs
-
MENU_DIRS.each do |dir|
next unless File.directory? dir
@@ -1244,6 +1241,11 @@ def self.enter_outline
end
def self.set_env_vars path
+
+ return if ! $el
+
+ # TODO: I guess they'll need to be set from somewhere else as well?
+
ENV['prefix'] = Keys.prefix.to_s
args = path.is_a?(Array) ?
View
@@ -33,7 +33,7 @@ def initialize *args
if args[0] && args[0].class == Hash
options = args.shift
if options[:save_scroll_position]
- @scroll_position = (line_number_at_pos point) - (line_number_at_pos window_start)
+ @scroll_position = ($el.line_number_at_pos $el.point) - ($el.line_number_at_pos $el.window_start)
end
end
@@ -123,7 +123,6 @@ def self.save name=nil
# Save location in corresponding register
# @@hash[name] = Location.new
$el.bookmark_set(name)
-
end
def self.jump path=nil
@@ -155,7 +154,7 @@ def self.as_spot key='0'
end
# Must be a buffer
- @@spots[key] = [$el.buffer_name(View.buffer), point]
+ @@spots[key] = [$el.buffer_name(View.buffer), $el.point]
end
def self.to_spot key='0'
View
121 menu.rb
@@ -437,66 +437,6 @@ def self.external menu, options={}
end
end
-end
-
-Menu.init # Define mode
-
-
-
-# Below is a different use of the "Menu" class - the "Xiki" menu at the top of emacs
-
-# TODO move into menu_bar.rb
-
-
-
-class Menu
- def self.add_menu *name
- menu_spaces = name.join(' ').downcase
- menu_dashes = name.join('-').downcase
- name = name[-1]
-
- lisp = %Q<
- (define-key global-map
- [menu-bar #{menu_spaces}]
- (cons "#{name}" (make-sparse-keymap "#{menu_dashes}")))
- >
- $el.el4r_lisp_eval lisp
-
- menu = $el.elvar.menu_bar_final_items.to_a
- $el.elvar.menu_bar_final_items = menu.push(name.downcase.to_sym)
- end
-
- def self.add_item menu, name, function
-
- menu_spaces = menu.join(' ').downcase
- lisp = "
- (define-key global-map
- [menu-bar #{menu_spaces} #{function}]
- '(\"#{name}\" . #{function}))
- "
- $el.el4r_lisp_eval lisp
- end
-
- ROOT_MENU = 'Keys'
-
- def self.init
-
- add_menu ROOT_MENU
-
- menus = [
- [ROOT_MENU, 'To'],
- [ROOT_MENU, 'Open'],
- [ROOT_MENU, 'Layout'],
- [ROOT_MENU, 'As'],
- [ROOT_MENU, 'Enter'],
- [ROOT_MENU, 'Do'],
- [ROOT_MENU, 'Search']
- ]
- menus.reverse.each do |tuple|
- add_menu tuple[0], tuple[1]
- end
- end
-
def self.as_menu
orig = View.cursor
@@ -712,4 +652,65 @@ def self.do_as_menu
Launcher.launch
end
+
+
+
+ # The following 3 methods are for the menu bar
+ # - a different use of the "Menu" class
+ # TODO move them into menu_bar.rb ?
+
+ def self.add_menu *name
+ menu_spaces = name.join(' ').downcase
+ menu_dashes = name.join('-').downcase
+ name = name[-1]
+
+ lisp = %Q<
+ (define-key global-map
+ [menu-bar #{menu_spaces}]
+ (cons "#{name}" (make-sparse-keymap "#{menu_dashes}")))
+ >
+ $el.el4r_lisp_eval lisp
+
+ menu = $el.elvar.menu_bar_final_items.to_a
+ $el.elvar.menu_bar_final_items = menu.push(name.downcase.to_sym)
+ end
+
+ def self.add_item menu, name, function
+
+ menu_spaces = menu.join(' ').downcase
+ lisp = "
+ (define-key global-map
+ [menu-bar #{menu_spaces} #{function}]
+ '(\"#{name}\" . #{function}))
+ "
+ $el.el4r_lisp_eval lisp
+ end
+
+ ROOT_MENU = 'Keys'
+
+ def self.init
+
+ return if ! $el
+
+ add_menu ROOT_MENU
+
+ menus = [
+ [ROOT_MENU, 'To'],
+ [ROOT_MENU, 'Open'],
+ [ROOT_MENU, 'Layout'],
+ [ROOT_MENU, 'As'],
+ [ROOT_MENU, 'Enter'],
+ [ROOT_MENU, 'Do'],
+ [ROOT_MENU, 'Search']
+ ]
+ menus.reverse.each do |tuple|
+ add_menu tuple[0], tuple[1]
+ end
+ end
+
+
end
+
+Menu.init # Define mode
+
+
View
@@ -216,13 +216,13 @@ def self.menu
@piano/
| reset()
| repeat(8)
- | tempo(40)
+ | tempo(45)
| mode(rand 100)
| variation()
+ | consistency(50)
| melodic()
- | consistency(25)
- | probability(85)
- | aaaaaaaa
+ | probability(80)
+ | aaaaaaa
| AAAAAAAA
| H H
|
@@ -576,6 +576,13 @@ def self.reset
".flash - success!"
end
+ #
+ # Low level call to configure midi.
+ #
+ def self.control_change a, b, c
+ self.driver.control_change a, b, c
+ end
+
def self.connect
@@midi = MIDIator::Interface.new
@@midi.use :dls_synth
View
@@ -1,5 +1,4 @@
$:.unshift "spec/"
-require 'el_mixin'
require 'line'
require 'ol'
require 'diff_log'
View
@@ -1,18 +0,0 @@
-class Elvar
- def method_missing(func, *args, &block)
- # Do nothing
- end
-end
-
-$el = Elvar.new
-
-module ElMixin
- def elvar
- Elvar.new
- end
- def method_missing(func, *args, &block)
- # Do nothing
- end
-end
-
-
View
@@ -1,5 +1,4 @@
$:.unshift "spec/"
-require 'el_mixin'
require 'file_tree'
require 'core_ext'
View
@@ -1,5 +1,4 @@
# $:.unshift "spec/"
-# require 'el_mixin'
# require 'keys'
# require 'ol'
View
@@ -1,5 +1,4 @@
$:.unshift "spec/"
-require 'el_mixin'
require 'line'
require 'core_ext'
View
@@ -1,5 +1,4 @@
$:.unshift "spec/"
-require 'el_mixin'
require 'ol'
require 'tree'
require 'core_ext'
View
@@ -1,5 +1,4 @@
$:.unshift "spec/"
-require 'el_mixin'
require 'line'
require 'ol'
require 'core_ext'
View
@@ -1,6 +1,5 @@
$:.unshift "spec/"
require 'rubygems'
-require 'el_mixin'
class Keys
def self.method_missing(meth, *args, &block); end
end
View
@@ -1,5 +1,4 @@
$:.unshift "spec/"
-require 'el_mixin'
require 'search'
require 'core_ext'
View
@@ -1,5 +1,4 @@
$:.unshift "spec/"
-require 'el_mixin'
require 'text_util'
describe TextUtil, "#unindent" do
View
@@ -1,6 +1,4 @@
$:.unshift "spec/"
-# require 'el_mixin'
-require 'el_mixin'
require 'core_ext'
require 'tree_cursor'
require 'ol'
View
@@ -1,5 +1,4 @@
require 'test/unit'
-require 'el_mixin'
$:.unshift File.expand_path("..")
require 'console'
require 'ol'
View
@@ -1,5 +1,4 @@
require 'test/unit'
-require 'el_mixin'
$:.unshift "../"
require 'diff_log'
View
@@ -1,5 +1,4 @@
require 'test/unit'
-require 'el_mixin'
$:.unshift "../"
require 'ol'
require 'core_ext'
Oops, something went wrong.

0 comments on commit f5b27ed

Please sign in to comment.