yi-0.12.0: The Haskell-Scriptable Editor

Safe HaskellNone
  • ScopedTypeVariables
  • OverloadedStrings
  • DeriveDataTypeable
  • GeneralizedNewtypeDeriving
  • ExplicitForAll
  • NondecreasingIndentation



This module defines a list type and operations on it; it further provides functions which write in and out the list. The goal is to make it easy for the user to store a large number of text buffers and cycle among them, making edits as she goes. The idea is inspired by "incremental reading", see http://en.wikipedia.org/wiki/Incremental_reading.



split :: ArticleDB -> (Article, ArticleDB) Source

Take an ArticleDB, and return the first Article and an ArticleDB - *without* that article.

getLatestArticle :: ArticleDB -> Article Source

Get the first article in the list. We use the list to express relative priority; the first is the most, the last least. We then just cycle through - every article gets equal time.

removeSetLast :: ArticleDB -> Article -> ArticleDB Source

We remove the old first article, and we stick it on the end of the list using the presumably modified version.

insertArticle :: ArticleDB -> Article -> ArticleDB Source

Insert a new article with top priority (that is, at the front of the list).

writeDB :: ArticleDB -> YiM () Source

Serialize given ArticleDB out.

readDB :: YiM ArticleDB Source

Read in database from getArticleDbFilename and then parse it into an ArticleDB.

oldDbNewArticle :: YiM (ArticleDB, Article) Source

Returns the database as it exists on the disk, and the current Yi buffer contents. Note that the Default typeclass gives us an empty Seq. So first we try the buffer state in the hope we can avoid a very expensive read from disk, and if we find nothing (that is, if we get an empty Seq), only then do we call readDB.

setDisplayedArticle :: ArticleDB -> YiM () Source

Given an ArticleDB, dump the scheduled article into the buffer (replacing previous contents).

nextArticle :: YiM () Source

Go to next one. This ignores the buffer, but it doesn't remove anything from the database. However, the ordering does change.

deleteAndNextArticle :: YiM () Source

Delete current article (the article as in the database), and go to next one.

saveAndNextArticle :: Int -> YiM () Source

The main action. We fetch the old database, we fetch the modified article from the buffer, then we call the function updateSetLast which removes the first article and pushes our modified article to the end of the list.

saveAsNewArticle :: YiM () Source

Assume the buffer is an entirely new article just imported this second, and save it. We don't want to use updateSetLast since that will erase an article.