From a367f13c72dfb2576012536de77869461209b7d0 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 10 Aug 2023 08:50:25 -0700 Subject: [PATCH] configs: use Notepad as default editor on Windows --- CHANGELOG.md | 2 ++ cli/src/commands/mod.rs | 2 +- cli/src/config.rs | 13 +++++++++---- cli/src/config/misc.toml | 1 - cli/src/config/unix.toml | 2 ++ cli/src/config/windows.toml | 2 ++ docs/config.md | 4 ++-- docs/config.toml | 2 +- docs/tutorial.md | 5 +++-- 9 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 cli/src/config/unix.toml create mode 100644 cli/src/config/windows.toml diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f4cd1a43..8304f8ced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * The `push.branch-prefix` option was renamed to `git.push-branch-prefix`. +* The default editor on Windows is now `Notepad` instead of `pico`. + ### New features * `jj init --git-repo` now works with bare repositories. diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 920d9a489..0d22c65c4 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -433,7 +433,7 @@ struct InterdiffArgs { /// Update the change description or other metadata /// /// Starts an editor to let you edit the description of a change. The editor -/// will be $EDITOR, or `pico` if that's not defined. +/// will be $EDITOR, or `pico` if that's not defined (`Notepad` on Windows). #[derive(clap::Args, Clone, Debug)] struct DescribeArgs { /// The revision whose description to edit diff --git a/cli/src/config.rs b/cli/src/config.rs index 11451b817..51d336613 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -343,13 +343,18 @@ pub fn default_config() -> config::Config { config::File::from_str(include_str!($file), config::FileFormat::Toml) }; } - config::Config::builder() + let mut builder = config::Config::builder() .add_source(from_toml!("config/colors.toml")) .add_source(from_toml!("config/merge_tools.toml")) .add_source(from_toml!("config/misc.toml")) - .add_source(from_toml!("config/templates.toml")) - .build() - .unwrap() + .add_source(from_toml!("config/templates.toml")); + if cfg!(unix) { + builder = builder.add_source(from_toml!("config/unix.toml")) + } + if cfg!(windows) { + builder = builder.add_source(from_toml!("config/windows.toml")) + } + builder.build().unwrap() } /// Environment variables that override config values diff --git a/cli/src/config/misc.toml b/cli/src/config/misc.toml index d480c9f54..fd395c2df 100644 --- a/cli/src/config/misc.toml +++ b/cli/src/config/misc.toml @@ -5,6 +5,5 @@ # Placeholder: added by user [ui] -editor = "pico" pager = { command = ["less", "-FRX"], env = { LESSCHARSET = "utf-8" } } log-word-wrap = false diff --git a/cli/src/config/unix.toml b/cli/src/config/unix.toml new file mode 100644 index 000000000..2022aa8ae --- /dev/null +++ b/cli/src/config/unix.toml @@ -0,0 +1,2 @@ +[ui] +editor = "pico" diff --git a/cli/src/config/windows.toml b/cli/src/config/windows.toml new file mode 100644 index 000000000..7d5e76f5c --- /dev/null +++ b/cli/src/config/windows.toml @@ -0,0 +1,2 @@ +[ui] +editor = "Notepad" diff --git a/docs/config.md b/docs/config.md index 03f8c52cf..58a2673e0 100644 --- a/docs/config.md +++ b/docs/config.md @@ -294,8 +294,8 @@ a `$`): `$JJ_EDITOR` > `ui.editor` > `$VISUAL` > `$EDITOR` -Pico is the default editor in the absence of any other setting, but you could -set it explicitly too. +Pico is the default editor (Notepad on Windows) in the absence of any other +setting, but you could set it explicitly too. ```toml ui.editor = "pico" diff --git a/docs/config.toml b/docs/config.toml index 697fe8212..e468ed53d 100644 --- a/docs/config.toml +++ b/docs/config.toml @@ -7,7 +7,7 @@ user.email = "YOUR_EMAIL@example.com" ui.color = "auto" # the default # ui.color = never # no color -ui.editor = "pico" # the default +ui.editor = "pico" # the default on Unix # ui.editor = "vim" ui.diff-editor = "meld" # default, requires meld to be installed diff --git a/docs/tutorial.md b/docs/tutorial.md index 6d7b5ec97..ff0063e99 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -39,8 +39,9 @@ Now let's say we want to edit the `README` file in the repo to say "Goodbye" instead of "Hello". Let's start by describing the change (adding a commit message) so we don't forget what we're working on: ```shell script -# This will bring up $EDITOR (or `pico` by default). Enter something like -# "Say goodbye" in the editor and then save the file and close the editor. +# This will bring up $EDITOR (or `pico` or `Notepad` by default). Enter +# something like "Say goodbye" in the editor and then save the file and close +# the editor. $ jj describe Working copy now at: e427edcfd0ba Say goodbye ```