summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/users_guide/9.2.1-notes.rst8
-rw-r--r--docs/users_guide/ghci.rst14
-rw-r--r--ghc/GHCi/UI.hs11
3 files changed, 25 insertions, 8 deletions
diff --git a/docs/users_guide/9.2.1-notes.rst b/docs/users_guide/9.2.1-notes.rst
index a38e334cd6..1e73770c5d 100644
--- a/docs/users_guide/9.2.1-notes.rst
+++ b/docs/users_guide/9.2.1-notes.rst
@@ -79,6 +79,14 @@ Compiler
that the compiler automatically insert cost-centres on all call-sites of
the named function.
+GHCi
+~~~~
+
+- GHCi's :ghci-cmd:`:edit` command now looks for an editor in
+ the :envvar:`VISUAL` environment variable before
+ :envvar:`EDITOR`, following UNIX convention.
+ (:ghc-ticket:`19030`)
+
Runtime system
~~~~~~~~~~~~~~
diff --git a/docs/users_guide/ghci.rst b/docs/users_guide/ghci.rst
index 93b72979b8..78c74c5dc3 100644
--- a/docs/users_guide/ghci.rst
+++ b/docs/users_guide/ghci.rst
@@ -2443,9 +2443,17 @@ commonly used commands.
Opens an editor to edit the file ⟨file⟩, or the most recently loaded
module if ⟨file⟩ is omitted. If there were errors during the last
loading, the cursor will be positioned at the line of the first
- error. The editor to invoke is taken from the :envvar:`EDITOR` environment
- variable, or a default editor on your system if :envvar:`EDITOR` is not
- set. You can change the editor using :ghci-cmd:`:set editor`.
+ error. The editor to invoke is taken from the :envvar:`VISUAL` or
+ :envvar:`EDITOR` environment variables, or a default editor on your system
+ if neither is not set. You can change the editor using :ghci-cmd:`:set
+ editor`.
+
+.. envvar:: VISUAL
+
+ :hidden:
+
+ .. This declaration simply avoids undefined reference warnings as Sphinx
+ doesn't know about VISUAL
.. ghci-cmd:: :enable; * | ⟨num⟩ ...
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index b2909c2441..77801019ee 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -427,13 +427,14 @@ defFullHelpText =
findEditor :: IO String
findEditor = do
- getEnv "EDITOR"
- `catchIO` \_ -> do
+ getEnv "VISUAL" <|> getEnv "EDITOR" <|> defaultEditor
+ where
+ defaultEditor = do
#if defined(mingw32_HOST_OS)
- win <- System.Win32.getWindowsDirectory
- return (win </> "notepad.exe")
+ win <- System.Win32.getWindowsDirectory
+ return (win </> "notepad.exe")
#else
- return ""
+ return ""
#endif
default_progname, default_stop :: String