An Emacs plugin for filtering large log files.
Improvements over the built-in occur
:
- Patterns are specified using rx notation in a regular buffer rather than the minibuffer.
- Patterns can be easily saved and restored.
- It is possible to specify multiple patterns, and
occurx
will highlight them with different colors. - Searches are not limited to a single line; it is possible to use a custom delimiter.
- It is possible to match multiple regular expressions for each entry and to negate regular expressions.
- Open a log file
- Run
M-x occurx-mode
- Type
o
to open a new buffer and enter search patterns there - Type
C-c C-c
to run the patterns
Pattern buffer is parsed as an ELisp file, producing a list of sexps. Examples:
Strings are treated literally rather than as regexps:
"String"
"[a-b]"
The above example will search for entries containing text String
or [a-b]
and highlight them with different colors.
((or "foo" "bar")) ; Search for regexp "foo|bar" and choose a random face to highlight the pattern
(:face hi-yellow (seq "foo" "bar")) ; Highlight pattern with a specific face
("foo" (or "bar" "baz")) ; Entry must contain both "foo" and "bar|baz" in any order
:not
keyword allows to inverse patterns:
(:not "foo" (or "bar" "baz")) ; Entry must contain "bar|baz", but not "foo"
It’s possible to highlight only a specific sub-match of the regexp using :sub N
construction:
(:sub 1 (seq "foo" (group "bar"))) ; Entry must contain "foobar", but only "bar" is highlighted
By default entries are delimited by \n, but it’s possible to override the delimiter by adding the following expression to the search buffer:
(delimiter RX-expression)
Behavior of (and X Y Z)
construct is changed so it inserts “.*” between sub-expressions.
Use (seq X Y Z)
if you need old behavior.