Skip to content

Instantly share code, notes, and snippets.

@rgieseke
Created December 19, 2010 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgieseke/747232 to your computer and use it in GitHub Desktop.
Save rgieseke/747232 to your computer and use it in GitHub Desktop.
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