ack3
ack3 copied to clipboard
Filetype request: .txt filetype
I would like to request for txt to be added as a known filetype. I didnt find any previous requests for it on the issue tracker.
The name of the filetype
text
, or alternatively, plain
(based on the MIME type for it, text/plain
).
What the definition of the filetype would be, taken from the .ackrc file that you've been using.
--type-add=text:ext:txt
URL of a web page that discusses what the filetype is
https://en.wikipedia.org/wiki/Text_file
What the file contains, and why it should be a filetype
The file contains plain, usually unformatted, text. It's widely used as a file format to save text.
RETRACTED
~~The reason there is no previous issue for txt
as a new filetype for Ack 3.x is that it's been provided since beginning of --type=
type with old Ack1.x .~~
~~While using the MIME names plain
and text
might have made some sense, the built-in type for .txt
files is --type=txt
, abbreviated --txt
. This is basically for historical reasons (e.g., ack is about code source files that mostly have extensions, not about Email/HTML MIME types carried by Internet protocols).~~
~~While there might be some minor DWIM value in allowing --text
and --type=text
as aliases (heck i've typed that expecting it to work!), there's clearly a simple workaround of using --txt
.~~
That's strange.
Using ack --help-types
I don't see anything in the output resembling txt, except for CMakeList.txt
, and searching the man page doesn't reveal anything to me either.
When I run ack --txt
or ack --type=txt
I get
ack: Unknown type 'txt'
ack: Invalid option on command line
version:
ack v3.7.0 (standard build)
Running under Perl v5.36.1 at /usr/bin/perl
Copyright 2005-2023 Andy Lester.
Taken from arch repos here: https://archlinux.org/packages/extra/any/ack/
In this context, "text" refers to the content of the file, vs "binary".
For example, a file of Python code may have a .py
extension and can be referenced with the --python
option, but it's also contains plain text.
By default, if you give ack no filenames to search and no type option, like ack whatever
, it will go search for all files that contain text and search those for the string whatever
, regardless of if it matches .txt
or any other extension. ack looks at the content of the file, says "this looks like text and not binary data" and uses that to make its determination. These might be XML files or Markdown files or maybe files with no extension.
My concern is that --text
mapping to .txt
would be confused with the current behavior described above.
Can you tell us more about your use case? Do you use .txt
as an extension for just any file that contains plain text but that isn't something like source code or a formatted data file like JSON or XML?
Do you use .txt as an extension for just any file that contains plain text but that isn't something like source code or a formatted data file like JSON or XML?
Yeah pretty much just this.
My mistake, i did not remember i had added the following to my .ackrc
years ago !
# add TEXT, CSV, etc.
--type-set=txt:ext:txt
--type-set=csv:ext:csv,tdf
which caused ack --help-types
to report txt
I have this in my ~/.ackrc
:
--type-add=txt=.txt
I can't add a text filetype. There's no way that it could be meaningful. Someone else would think that text would include any number of things.
Sorry, it just doesn't make sense.