简体   繁体   English

如何修改 ack 中的类型?

[英]How can I modify a type in ack?

I know how to set a new type.我知道如何设置新类型。 What I want to do is modify an existing type.我想要做的是修改现有类型。 I want to add haml files to the ruby type.我想将 haml 文件添加到 ruby 类型。 I could probably use --set-type and redefine the ruby type but I don't know how to redefine it and still include files called 'Rakefile' and files where the first line indicates that it is an executable Ruby script (First line matches /^#..*\bruby/)我可能会使用 --set-type 并重新定义 ruby 类型,但我不知道如何重新定义它并仍然包含名为“Rakefile”的文件以及第一行表明它是可执行 Ruby 脚本的文件(第一行匹配/^#..*\bruby/)

Here is the existing documentation for the ruby type:以下是 ruby 类型的现有文档:

ruby         .rb .rhtml .rjs .rxml .erb .rake .spec; Rakefile; First line matches /^#!.*\bruby/

There are three arguments that let you work with type definitions.共有三个 arguments 可让您使用类型定义。 From ack --help :ack --help

File type specification:
  --type-set=TYPE:FILTER:ARGS   Files with the given ARGS applied to the given
                                FILTER are recognized as being of type TYPE.
                                This replaces an existing definition for TYPE.
  --type-add=TYPE:FILTER:ARGS   Files with the given ARGS applied to the given
                                FILTER are recognized as being type TYPE.
  --type-del=TYPE               Removes all filters associated with TYPE.

If all you want to do is add .haml files to the existing Ruby spec, use如果您只想将.haml文件添加到现有的 Ruby 规范,请使用

--type-add=ruby:ext:haml

If you want to see how existing types are defined, use --dump .如果您想查看现有类型是如何定义的,请使用--dump

$ ack --dump | ack ruby
  --type-add=ruby:ext:rb,rhtml,rjs,rxml,erb,rake,spec
  --type-add=ruby:firstlinematch:/^#!.*\bruby/
  --type-add=ruby:is:Rakefile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM