feat: add notepad as default editor for windows

This commit is contained in:
ShrykeWindgrace 2023-11-27 17:51:14 +01:00 committed by Simon Michael
parent fcda6bfb35
commit 03808552ff

View File

@ -16,6 +16,7 @@ import Safe
import System.Environment import System.Environment
import System.Exit import System.Exit
import System.FilePath import System.FilePath
import System.Info (os)
import System.Process import System.Process
import Hledger import Hledger
@ -123,13 +124,17 @@ editFileAtPositionCommand mpos f = do
return $ unwords $ cmd:args return $ unwords $ cmd:args
-- | Get the user's preferred edit command. This is the value of the -- | Get the user's preferred edit command. This is the value of the
-- $HLEDGER_UI_EDITOR environment variable, or of $EDITOR, or a -- $HLEDGER_UI_EDITOR environment variable, or of $EDITOR, or an OS-specific default.
-- default ("emacsclient -a '' -nw", which starts/connects to an emacs --
-- daemon in terminal mode). -- For non-windows machines that would be "emacsclient -a '' -nw",
-- which starts/connects to an emacs daemon in terminal mode.
--
-- For windows the default is a plain "notepad.exe"
getEditCommand :: IO String getEditCommand :: IO String
getEditCommand = do getEditCommand = do
hledger_ui_editor_env <- lookupEnv "HLEDGER_UI_EDITOR" hledger_ui_editor_env <- lookupEnv "HLEDGER_UI_EDITOR"
editor_env <- lookupEnv "EDITOR" editor_env <- lookupEnv "EDITOR"
let Just cmd = hledger_ui_editor_env <|> editor_env <|> Just "emacsclient -a '' -nw" let defaultEditor = Just $ if os == "mingw32" then "notepad.exe" else "emacsclient -a '' -nw"
let Just cmd = hledger_ui_editor_env <|> editor_env <|> defaultEditor
return cmd return cmd