From be0fce32fc99b26a3ae4e208fb2a244f441f3212 Mon Sep 17 00:00:00 2001 From: defanor Date: Fri, 15 Dec 2017 17:17:57 +0300 Subject: Add the "redisplay" command --- Pancake.hs | 6 ++++++ Pancake/Command.hs | 2 ++ README | 1 + pancake.1 | 2 ++ pancake.el | 5 +++++ 5 files changed, 16 insertions(+) diff --git a/Pancake.hs b/Pancake.hs index 5d49b1a..e854d13 100644 --- a/Pancake.hs +++ b/Pancake.hs @@ -317,6 +317,12 @@ command Quit = liftIO $ do command Interrupt = putErrLn "Received SIGINT. Interrupt twice in a row to quit." command (SetWidth w) = modify $ \s -> s { columns = w } +command Redisplay = do + st <- get + case history st of + ((uri, doc):_, _) -> printDoc uri doc + _ -> putErrLn "There's nothing to redisplay" + -- | Reads commands, runs them. eventLoop :: MonadIO m => StateT LoopState m () diff --git a/Pancake/Command.hs b/Pancake/Command.hs index 5126146..4c34a19 100644 --- a/Pancake/Command.hs +++ b/Pancake/Command.hs @@ -61,6 +61,7 @@ data Command = Quit | Shortcut String String | ReloadConfig | SetWidth (Maybe Int) + | Redisplay deriving (Show, Eq) -- | Parses a user command. @@ -77,6 +78,7 @@ basicCommand = choice . map (\(s, c) -> try (string s <* eof) *> pure c) $ , ("reload config", ReloadConfig) , ("help", Help) , ("?", ShowCurrent) + , ("redisplay", Redisplay) , ("", More)] -- | Link number parser. diff --git a/README b/README index 7cabedf..5105c09 100644 --- a/README +++ b/README @@ -74,6 +74,7 @@ Commands : : run a query using a shortcut defined in the configuration (e.g., search) :set width[ ]: set terminal/window width manually +:redisplay: redisplay current document pancake-mode provides additional aliases and commands, see built-in emacs documentation (``C-h m``) for those. diff --git a/pancake.1 b/pancake.1 index f5daeaf..3467e09 100644 --- a/pancake.1 +++ b/pancake.1 @@ -59,6 +59,8 @@ run a query using a shortcut defined in the configuration (e.g., search) .IP "\fBset width\fR[ \fIcolumns\fR]" set terminal/window width manually +.IP "\fBredisplay\fR" +redisplay current document .SH DEFAULT SHORTCUTS .IP "\fBg\fR" diff --git a/pancake.el b/pancake.el index 52021cf..c799eef 100644 --- a/pancake.el +++ b/pancake.el @@ -403,6 +403,11 @@ use. Current window width is used if none is provided." (interactive) (pancake-process-send ",")) +(defun pancake-redisplay () + "Redisplay the current document." + (interactive) + (pancake-process-send "redisplay")) + (defun pancake-display-current-uri () "Display current URI and put it into the kill ring." (interactive) -- cgit v1.2.3