Giter Site home page Giter Site logo

horg's Introduction

description

Horg is program, that reads an aribtrary number of org-mode files, and parses it contents into an internal data structure. Various filters can be applied to that structure, and two (there will be a third one) output formats can be produced: Org-mode and Dot (later: JSON).

basic usage

Horg is a command line tool. You can either compile it with a haskell compiler like GHC, or run it with the runhaskell utility. In the latter case, the trivial usage is

runhaskell Horg.hs -- my.org

which will generate (hopefully) valid org-mode output to standard out, that should contain the exact same content as my.org. Save the output into a file via output redirection, that is provided by your favorite shell.

runhaskell Horg.hs -- my.org > tmp.org

The two minus signs are important, because everything before that delimiter is interpreted as an option.

output formats

Horg always prints to standard output. To control the output format, use the -output option.

runhaskell Horg.hs -output=org -- my.org > tmp.org
runhaskell Horg.hs -output=dot -- README.org > tmp.dot

The first one of the two commands above, does the exact same thing, as the previous command, but explicitly stated, that org-mode output is created. The second command produces the file tmp.dot, that can further be processed by the graphviz suite for creating graphs, or mind maps. Those graphs contain three kinds of nodes: tags, headings, and contents. When exporting data to a dot file, it is often useful, to print the title only, and hide the details of an item. This can be done, by the nocontent option:

runhaskell Horg.hs -output=dot -nocontent -- my.org > tmp.dot

filtering

basic filtering

The data of several org-mode files can nicely be filtered by different criteria. So far four filters are supported, that can be combined in a sufficiently arbitrary manner. All the filter options must be enclosed in (single or double) quotes. The filters for the title and the content, consist of one single word, if it is contained in the title or content of a heading, it is returned (printed to standard output). There are also matching filters for the state and tags.

runhaskell Horg.hs "content=hedgehog title=animal state=TODO tag=hunting" -- my.org > tmp.org

This command leads to a file tmp.org, containing only headings, that, … I think, it’s quite readable. All filter options are combined by a logical AND. A logical OR can be inserted between arbitrary filter statements, with the rule, that AND binds tighter than OR.

runhaskell Horg.hs "state=TODO OR tag=neverending title=study" -- my.org > tmp.org

lists all TODO headings and those, tagged by neverending with study in the title.

filter structure

In an org-mode heading structure, a filter can have different meanings. What should be returned, when a filter returns a heading. The heading and all its subheadings could be returned, or only the heading without its subheadings, or all parent headings could be shown as well. In Horg, there are four filtering structures provided.

runhaskell Horg.hs "tag=filter" -filter=deep -- my.org > tmp.org    # this one is the default
runhaskell Horg.hs "tag=filter" -filter=surface -- my.org > tmp.org
runhaskell Horg.hs "tag=filter" -filter=conserve -- my.org > tmp.org
runhaskell Horg.hs "tag=filter" -filter=preserve -- my.org > tmp.org

conserve filter

If an arbitrary subheading or the heading itself of a heading matches the filter, the whole heading with all its subheadings is returned.

preserve filter

When a heading matches, no subheadings are shown (except if they match), but all its parent headings. This one is great for finding where this heading is from (after a complicated search)

surface filter

When a heading matches, it is returned with all its subheadings

deep filter

Only matching heading are returned without their children or parents, except their children or parent are matching, too. If subheadings, more than one level deeper than their matching ancestors, match, the returned heading tree is compressed, leaving out the non matching uncles and aunts.

horg's People

Watchers

James Cloos avatar Spiehr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.