summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-10-30 11:53:09 +0300
committerdefanor <defanor@uberspace.net>2017-10-30 11:53:09 +0300
commitbdd98f68eb0134be586a44235364d12b192f32aa (patch)
treed5e118c673957111f061848d907555a79096df5f
parentb6f4091a1c2f6e39548a9228594a4f677855cd29 (diff)
Invoke external viewers properly
Set an environment variable for file name.
-rw-r--r--Pancake.hs16
-rw-r--r--README.org4
2 files changed, 13 insertions, 7 deletions
diff --git a/Pancake.hs b/Pancake.hs
index 9338ddc..014462c 100644
--- a/Pancake.hs
+++ b/Pancake.hs
@@ -397,10 +397,11 @@ instance Default Config where
, ("gopher", "curl \"${URI}\"")]
, defaultCommand = "curl -4 -L \"${URI}\""
, externalViewers = M.fromList $
- map (flip (,) "emacsclient -n") ["hs", "cabal", "c", "h", "el", "scm", "idr"]
- ++ map (flip (,) "xdg-open") [ "svg", "png", "jpg", "jpeg", "gif", "pdf"
- , "ogg", "ogv", "webm", "mp3", "mp4", "mkv"
- , "mpeg", "wav" ]
+ map (flip (,) "emacsclient -n \"${FILE}\"")
+ ["hs", "cabal", "c", "h", "el", "scm", "idr"]
+ ++ map (flip (,) "xdg-open \"${FILE}\"")
+ [ "svg", "png", "jpg", "jpeg", "gif", "pdf", "ogg", "ogv"
+ , "webm", "mp3", "mp4", "mkv", "mpeg", "wav" ]
, shortcuts = M.fromList
[ ("ddg", "https://duckduckgo.com/lite/?q=")
, ("wp", "https://en.m.wikipedia.org/wiki/Special:Search?search=")
@@ -539,7 +540,12 @@ command (GoTo u') = do
, cmd, "`: ", show e])) $ do
createDirectoryIfMissing True dir
BS.writeFile tmpPath d
- callCommand $ concat [ev, " ", tmpPath]
+ curEnv <- getEnvironment
+ ec <- withCreateProcess
+ ((shell ev) { env = Just (("FILE", tmpPath) : curEnv) }) $
+ \_ _ _ p -> waitForProcess p
+ when (ec /= ExitSuccess) $
+ putErrLn $ concat ["An error occured. Exit code: ", show ec]
pure mzero
case d of
Nothing -> pure ()
diff --git a/README.org b/README.org
index 77e1e26..da42cac 100644
--- a/README.org
+++ b/README.org
@@ -38,8 +38,8 @@ documentation (~C-h m~) for those.
#+BEGIN_SRC yaml
externalViewers:
- png: xdg-open
- hs: emacsclient -n
+ png: xdg-open "${FILE}"
+ hs: emacsclient -n "${FILE}"
commands:
gopher: torify curl "${URI}"
ssh: scp "${URI_REGNAME}:${URI_PATH}" /dev/stdout