diff options
author | defanor <defanor@uberspace.net> | 2017-11-28 07:07:58 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2017-11-28 07:07:58 +0300 |
commit | 51146403e0e7b9d49efe8592ac8380f785ce9cf3 (patch) | |
tree | 380666e46e05906c586db0b5090ff360235d3b7c /Pancake.hs | |
parent | 6d6696fc45013f88c63decab3e53b8ee26dde1b4 (diff) |
Introduce initial image support
Pancake reports saved files to Emacs, Emacs inserts them into
appropriate positions if they are images; `pancake-load-images' just
sends "save" commands for all the images.
`pancake-display-hook' was added as well, so that image loading can be
requested automatically, among other things.
There is a few things to improve: currently the images don't get
sliced, there's no caching or parallelization, and no tracking of
explicitly requested images.
Diffstat (limited to 'Pancake.hs')
-rw-r--r-- | Pancake.hs | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -179,6 +179,7 @@ goTo t u' = do command :: MonadIO m => Command -> StateT LoopState m () command (Save (RURI uri') p) = do (uri, mraw) <- loadRaw uri' + st <- get case mraw of Nothing -> pure () Just (raw, euri, _) -> liftIO $ do @@ -202,10 +203,15 @@ command (Save (RURI uri') p) = do targetFileName = fromMaybe remoteFileName mTargetName targetPath = targetDir </> targetFileName e <- try $ BS.writeFile targetPath raw - putErrLn $ unwords $ case e of + case e of Left (err :: SomeException) -> - ["Failed to write", targetPath ++ ":", show err] - Right _ -> ["Saved", remoteURIStr, "as", targetPath] + putErrLn $ unwords ["Failed to write", targetPath ++ ":", show err] + Right () -> do + when (embedded st) $ + putSexpLn [ "saved" + , encodeSexpStr $ uriToString id uri' "" + , encodeSexpStr targetPath] + putErrLn $ unwords ["Saved", remoteURIStr, "as", targetPath] where escapeURI c | isPathSeparator c = '-' |