Traverse and explicate grid structures using emacs.
Just. Because.
- Ever found yourself lost and adrift in a sprawling .csv file? Would it have helped if a kind stranger had drawn you a map of where you were?
- Ever been trolling around a FIX log file and wondered what tag that was?
- Amaze onlookers with your effortless aplomb.
- Inspire envy from other would-be studiers of structured data pathetically frustrated by inscrutable formats.
Stop depending on the niceness of strangers. Empower yourself with gridlock-mode
. csv-mode
is nice and all, and csv-align-fields
is a perfectly cromulent method of aligning columns. But it doesn't help when the length or number of fields exceeds the size of your window. Then you are, if you will permit me to be technical, SOL. Let gridlock-mode
guide you through the fog. With it, you are able to:
- move between fields on the same line (forward and backward, jumping to start and end of line, or straight to a particular field, by content or heading)
- jump to the next or previous line
- all the while showing a helpful heading detailing where you are.
Not since sliced bread, I tell ya.
There are different methods built-in to gridlock to help display where you are. It comes with:
- popup
- pos-tip
- quick-peek
- minibuffer echo
You are able to interactively select your desired display scheme. The set of available schemes is automatically updated based on whatever libraries you have installed. Worry not, gridlock
also works in a terminal, through regrettably one of the display schemes, pos-tip
, is not available there as it requires (display-graphic-p)
to be true.
You'd like that, wouldn't you.
Oh, OK, here you go:
Gridlock is also intended to be used in file formats other than csv. Anything that has a structure than can be described by regular expressions can be attuned to the splendor of Gridlock's capabilities. Gridlock comes in two flavors right out of the box:
- Gridlock-csv
gridlock-csv-mode
is your CSV SAK (Swiss Army Knife).
Tag metadata comes from the first line. That is, the headings shown when you alight on a column are sourced by the first line in the file, which is often a list of headings, possibly preceded by a comment character #
.
- Gridlock-fix
gridlock-fix-mode
can help you trawl through log files of your favorite FIX application. Currently it knows about FIX 4.2 tags.
Ensure the gridlock .el files are in your load-path. Then craft something like the following use-package
stanzas:
(use-package gridlock-csv
:after csv-mode
:bind (:map csv-mode-map ("C-c C-l" . gridlock-csv-mode)))
Then literally, just, like, open a csv file, man.
(use-package gridlock-fix :bind ("C-c M-f" . gridlock-fix-mode))
Note that gridlock-fix-mode
also requires "fix4.2.hash" be in load-path
.
Here, authors of unforetold minor-modes of data exploration, are the variables with which gridlock's capabilities can be unleashed:
This regex identifies lines of interest. Lines without a match will be ignored. Is every line interesting, like in a typical csv file? Then set this to its default, "^". Otherwise, if this regex is missing on a line, gridlock ignores that line. In addition, if gridlock-field-regex-begin
is empty (the default), the anchor point is treated as the point at which further field processing begins.
Once you've identified lines of interest, you need to split them up into any fields that may be present. This regex describes the delimiter that splits fields. For the typical csv format, the default value is ",".
Jewels may lie among cruft. Even on lines of interest, there may be text before or after the fields: preambles or such. This regex, if non-empty, describes the point on the line at which the first field begins. If this regex is left empty, its default, then the fields are presumed to begin immediately after the anchor point.
If this regex includes a capture group, then that capture group is presumed to be important and will be included in field parsing, that is, field parsing will begin at the beginning of the match. This can be helpful if it's more convenient to demarcate the beginning of field matching by the first field itself, rather than a preamble that precedes it. With no capture group, the regex is presumed to be unimportant and field parsing will begin at the end of the match.
Wheat shines among chaff. This regex identifies the ending of the fields on lines of interest. If left empty, its default, the field processing extends to the end of the line.
If this regex includes a capture group, then that capture group is presumed to be important and will be included in field parsing, that is, field parsing will continue up to the end of the match. This can be helpful if it's more convenient to demarcate the end of field matching by the last field itself, rather than an epilog that follows it. With no capture group, the regex is presumed to be unimportant and field parsing will continue up to the beginning of the match.
Moves the cursor to the next valid line. Attempts to maintain the current column.
Moves the cursor to the previous valid line. Attempts to maintain the current column.
Moves the cursor to the next field on the current line.
Moves the cursor to the prior field on the current line.
Moves the cursor to the first field on the current line.
Moves the cursor to the last field on the current line.
Shows the current grid title, in case it is not currently displayed.
(Note that some display schemes, like pos-tip
, may have a timeout.
Interactively choose the display scheme in use. It is updated immediately.
Interactively choose a field to jump to, by index.
Interactively choose a field to jump to, by heading/title.
Interactively choose a field to jump to, by content.