yi-0.12.4: The Haskell-Scriptable Editor

Safe HaskellNone
  • TemplateHaskell
  • OverloadedStrings
  • DeriveDataTypeable
  • NondecreasingIndentation
  • LambdaCase






File-based actions

editFile :: FilePath -> YiM (Either Text BufferRef) Source

If file exists, read contents of file into a new buffer, otherwise creating a new empty buffer. Replace the current window with a new window onto the new buffer.

If the file is already open, just switch to the corresponding buffer.

Need to clean up semantics for when buffers exist, and how to attach windows to buffers.

Yi.File module re-exports this, you probably want to import that instead.

In case of a decoding failure, failure message is returned instead of the BufferRef.

openingNewFile :: FilePath -> BufferM a -> YiM () Source

Tries to open a new buffer with editFile and runs the given action on the buffer handle if it succeeds.

If the editFile fails, just the failure message is printed.

openNewFile :: FilePath -> YiM () Source

Same as openingNewFile with no action to run after.

viWrite :: YiM () Source

Try to write a file in the manner of vi/vim Need to catch any exception to avoid losing bindings

viWriteTo :: Text -> YiM () Source

Try to write to a named file in the manner of vi/vim

viSafeWriteTo :: Text -> YiM () Source

Try to write to a named file if it doesn't exist. Error out if it does.

fwriteE :: YiM Bool Source

Write current buffer to disk, if this buffer is associated with a file

fwriteBufferE :: BufferRef -> YiM Bool Source

Write a given buffer to disk if it is associated with a file.

fwriteAllY :: YiM Bool Source

Write all open buffers

fwriteToE :: Text -> YiM Bool Source

Write current buffer to disk as f. The file is also set to f.

backupE :: FilePath -> YiM () Source

Make a backup copy of file

revertE :: YiM () Source

Revert to the contents of the file on disk

Helper functions

setFileName :: BufferRef -> FilePath -> YiM () Source

Associate buffer with file; canonicalize the given path name.

deservesSave :: FBuffer -> YiM Bool Source

Checks if the given buffer deserves a save: whether it's a file buffer and whether it's pointing at a file rather than a directory.