Skip to content

Latest commit

 

History

History
76 lines (52 loc) · 2.23 KB

README.org

File metadata and controls

76 lines (52 loc) · 2.23 KB

occurx-mode

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.

Teaser

./screenshot.png

How to

  1. Open a log file
  2. Run M-x occurx-mode
  3. Type o to open a new buffer and enter search patterns there
  4. Type C-c C-c to run the patterns

Search patterns

Pattern buffer is parsed as an ELisp file, producing a list of sexps. Examples:

Literal strings

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.

Regular expressions

((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

Multiple matches

("foo" (or "bar" "baz")) ; Entry must contain both "foo" and "bar|baz" in any order

Negation

:not keyword allows to inverse patterns:

(:not "foo" (or "bar" "baz")) ; Entry must contain "bar|baz", but not "foo"

Sub-matches

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

Entry delimiter

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)

RX amendments

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.