Class: VER::Executor::ExGrepBuffers

Inherits:
ExGrep show all
Defined in:
lib/ver/executor/grep.rb

Overview

Grep the open buffers interactively

Constant Summary

Constants inherited from VER::Entry

VER::Entry::BACKWARD_WORD, VER::Entry::FORWARD_WORD

Instance Method Summary collapse

Methods inherited from ExGrep

#action, #after_update, #grep_with, #setup, #sync_value_with_tree_selection

Methods inherited from VER::Entry

#accept_line, #beginning_of_history, #cursor=, #delete, #delete_next_char, #delete_next_word, #delete_prev_char, #delete_prev_word, #deleting, #end_of_history, #end_of_line, #error, #event, #events, #insert, #insert_selection, #insert_string, #insert_tab, #kill, #kill_end_of_line, #killing, #message, #next_char, #next_history, #next_word, #paste, #prev_char, #prev_word, #previous_history, #sel_end_of_line, #sel_next_char, #sel_next_word, #sel_prev_char, #sel_prev_word, #sel_start_of_line, #start_of_line, #style, #transpose_chars, #value=, #virtual_movement

Instance Method Details

#choices(needle) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/ver/executor/grep.rb', line 84

def choices(needle)
  choices = []
  return choices if needle =~ /^\s*$/

  files = VER.buffers.map{|name, buffer| buffer.filename }
  glob = Pathname("{#{files.join(',')}}")

  begin
    regexp = Regexp.new(needle)
  rescue RegexpError, SyntaxError
    regexp = Regexp.new(Regexp.escape(needle))
  end

  grep_with(glob, regexp, false)
end