Commits

seydar committed cde6735 Draft

all i really did was add ^f as a keystroke to automatically do *f(...)

  • Participants
  • Parent commits 0695341

Comments (0)

Files changed (3)

 
 require File.join(File.dirname(follow_link(__FILE__)), "..", "lib", "chitin")
 
-if ARGV[0]
-  rc = ARGV[0]
-else
-  FileUtils.touch File.expand_path('~/.chitinrc')
-  rc = File.expand_path('~/.chitinrc')
-end
+rc = ARGV[0] || File.expand_path('~/.chitinrc')
+FileUtils.touch rc
 
 Chitin::Builtins.class_eval File.read(rc)
 

File lib/chitin/commands/builtins.rb

       end
     end
 
+    # Automatically add *f(..) around something
+    bind ?\C-f do |c|
+      if beg = c.word_beginning_before(c.pos) and last = c.word_end_before(c.pos)
+        c.line[beg..last] = '*f(' + c.line[beg..last] + ')'
+        c.pos = last + 5 # 4 for the characters and 1 for the cursor
+      end
+    end
+
     # Clear the line, don't add it to history
     bind ?\C-g do |c|
       c.line.clear

File lib/chitin/commands/executable.rb

             [key, val]
           end
         else
-          #a = arg.is_a?(FSObject) ? arg.to_a : arg
-          #pp a.map(&:to_s) if arg.is_a? FSObject
+          # I'm leaving this here so that I know what went down in this
+          # battlefield. I tried automatically expanding globs, but that
+          # in conjunction with * means things get expanded twice, resulting
+          # in a lot of duplicates.
+          #
+          # Maybe an answer is to get rid of * and only do automatic expansion
+          # for executables.
+          #
+          # NO YOU CAN'T! What if you want to pass a directory to program that
+          # you have save as a Chitin::Directory? It would end up being globbed
+          # open which is NOT what you wanted. Globbing must be done explicitly.
+          #
+          # a = arg.is_a?(FSObject) ? arg.to_a : arg
+          # pp a.map(&:to_s) if arg.is_a? FSObject
+          # a
           arg
         end
       end