Skip to content

Instantly share code, notes, and snippets.

@rgieseke rgieseke/ack.lua
Created Dec 19, 2010

Embed
What would you like to do?
Textadept: Ack plugin
module('_m.common.ack', package.seeall)
-- load with
-- require 'common.ack'
-- in init.lua
options = '--nocolor --nogroup '
local L = _G.locale.localize
local sep = '/'
local buffer_type = L('[Files Found Buffer]')
function ack()
ack_search = true
gui.command_entry.entry_text = ''
gui.command_entry.focus()
end
events.connect('command_entry_command',
function(text) -- ack search
if ack_search then
local current_dir = buffer.filename:match('(.+)/')
gui.command_entry.focus()
local command = 'ack '..options..text
local p = io.popen(command..' '..current_dir..' 2>&1')
local out = p:read('*all')
p:close()
gui._print(buffer_type, out)
ack_search = false
buffer:goto_pos(0)
buffer.read_only = 1
return true
end
end, 1)
keys.caf = {
function()
if buffer.filename then ack() end
end }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.