@@ -34,7 +34,6 @@ use movement::Movement;
35use crate::{
35use crate::{
36 compositor::{self, Component, Compositor},
36 compositor::{self, Component, Compositor},
38 ui::{self, Picker, Popup, Prompt, PromptEvent},
37 ui::{self, Picker, Popup, Prompt, PromptEvent},
@@ -48,7 +47,7 @@ use std::{
48 path::{Path, PathBuf},
47 path::{Path, PathBuf},
51−use once_cell::sync::Lazy;
50+use once_cell::sync::{Lazy, OnceCell};
52use serde::de::{self, Deserialize, Deserializer};
51use serde::de::{self, Deserialize, Deserializer};
54pub struct Context<'a> {
53pub struct Context<'a> {
@@ -3414,13 +3413,11 @@ fn select_register(cx: &mut Context) {
3416macro_rules! mode_info {
3415macro_rules! mode_info {
3417− // TODO: how to use one expr for both pat and expr?
3416+ // TODO: reuse $mode for $stat
3418− // TODO: how to use replaced function name as str at compile time?
3419− // TODO: extend to support multiple keys, but first solve the other two
3420 (@join $first:expr $(,$rest:expr)*) => {
3417 (@join $first:expr $(,$rest:expr)*) => {
3421 concat!($first, $(", ", $rest),*)
3418 concat!($first, $(", ", $rest),*)
3423− {$mode:ident, $name:literal, $(#[doc = $desc:literal] $($key:expr),+ => $func:expr),+,} => {
3420+ {$mode:ident, $stat:ident, $name:literal, $(#[doc = $desc:literal] $($key:tt)|+ => $func:expr),+,} => {
3424 #[doc = $name]
3421 #[doc = $name]
3425 #[doc = ""]
3422 #[doc = ""]
3426 #[doc = "<table><tr><th>key</th><th>desc</th></tr><tbody>"]
3423 #[doc = "<table><tr><th>key</th><th>desc</th></tr><tbody>"]
@@ -3439,12 +3436,14 @@ macro_rules! mode_info {
3440 #[doc = "</tbody></table>"]
3437 #[doc = "</tbody></table>"]
3441 pub fn $mode(cx: &mut Context) {
3438 pub fn $mode(cx: &mut Context) {
3439+ static $stat: OnceCell<Info> = OnceCell::new();
3442− cx.editor.autoinfo = Some(Info::key(
3440+ cx.editor.autoinfo = Some($stat.get_or_init(|| Info::key(
3444− vec![$((vec![$($key.parse().unwrap()),+], $desc)),+],
3442+ vec![$((&[$($key.parse().unwrap()),+], $desc)),+],
3446 use helix_core::hashmap;
3444 use helix_core::hashmap;
3445+ // TODO: try and convert this to match later
3447− let mut map = hashmap! {
3446+ let map = hashmap! {
3448 $($($key.parse::<KeyEvent>().unwrap() => $func as for<'r, 's> fn(&'r mut Context<'s>)),+),*
3447 $($($key.parse::<KeyEvent>().unwrap() => $func as for<'r, 's> fn(&'r mut Context<'s>)),+),*
3450 cx.on_next_key_mode(map);
3449 cx.on_next_key_mode(map);
@@ -3453,7 +3452,7 @@ macro_rules! mode_info {
3455mode_info! {
3454mode_info! {
3456− space_mode, "space mode",
3455+ space_mode, SPACE_MODE, "space mode",
3457 /// file picker
3456 /// file picker
3458 "f" => file_picker,
3457 "f" => file_picker,
3459 /// buffer picker
3458 /// buffer picker