2012-02-29 13 views
4

나를 위해 ack는 필수 키트입니다 (그 앨리어스와 나는 하루에 백만 번 사용합니다). 대부분은 내가 필요로하는 모든 것을 가지고 있으므로이 행동이 다루어지고 있으며 나는 그것을 찾을 수 없다고 생각하고 있습니다.ack - 실제 파일 이름을 파일 유형에 바인딩

형식을 사용하여 특정 종류의 파일로 제한 할 수 있기를 바랍니다. 문제는 이러한 파일의 확장자가 아닌 전체 파일 이름입니다. 예를 들어 buildr 용 파일을 빌드하도록 제한하고 싶습니다. 그래서 --buildr (mvn poms와 비슷하게 적용 할 수 있습니다)으로 검색 할 수 있습니다. 나는 내 .ackrc

--type-set=buildr=buildfile,.rake 

문제는 '빌드 파일'이 전체 파일 이름이 아닌 확장 점이다에 정의 된 다음 한 나는이 이름에 완전히 일치하도록 ACK를하고 싶습니다. 그러나 'buildr'에 바인딩 된 유형을 보면 .buildfile이 전체 파일 이름이 아니라 확장자임을 나타냅니다.

--[no]buildr  .buildfile .rake 

수많은 XML의 쓰임새 (예를 들어, 개미 build.xml 또는 MVN pom.xml)이 있기 때문에 그것은 완벽한 될 것이라고 나에게 정말 유용 할 특정 파일 이름에 제한 할 수있는 기능. 필자는 바이너리 인 Makefiles와 Rakefiles가 특수한 형태의 설정을 가지고 있는지를 알고 있습니다. 나는 커스텀 기능을 사용하기 전에 가능하다면 그것을 수행 할 수 있어야한다. 이것이 가능한지 누구나 아십니까?

답변

4

아니요, 할 수 없습니다. ack 1.x는 파일 형식을 탐지하는 확장명 만 사용합니다. 당신이 좋아하는 물건을 할 수 있습니다 훨씬 더 유연한 기능을해야합니다 2.0 ACK :


# There are four different ways to match 
# is: Match the filename exactly 
# ext: Match the extension of the filename exactly 
# match: Match the filename against a Perl regular expression 
# firstlinematch: Match the first 80 characters of the first line 
# of text against a Perl regular expression. This is only for 
# the --type-add option. 


--type-add=make:ext:mk 
--type-add=make:ext:mak 
--type-add=make:is:makefile 
--type-add=make:is:gnumakefile 


# Rakefiles http://rake.rubyforge.org/ 
--type-add=rake:is:Rakefile 

# CMake http://www.cmake.org/ 
--type-add=cmake:is:CMakeLists.txt 
--type-add=cmake:ext:cmake 

# Perl http://perl.org/ 
--type-add=perl:ext:pod 
--type-add=perl:ext:pl 
--type-add=perl:ext:pm 
--type-add=perl:firstlinematch:/perl($|\s)/ 

당신은 https://github.com/petdance/ack2에서하고있는 ACK 2.0에 무엇을 개발 볼 수 있습니다. 나는 너의 도움을 받고 싶다.

+0

cryopost에 사과드립니다.하지만 .ackrc :'--type-add = mvn, is, pom.xml'에 넣으면'%> ack --mvn org 필터 설정이 잘못되었습니다 'mvn, is, pom.xml 'at /System/Library/Perl/5.18/Getopt/Long.pm line 589. 알 수없는 옵션 : mvn' –

+1

당신은'--type-add = mvn : is : pom.xml'을 원합니다. 예제는'ack --dump'를보십시오. –