diff options
author | Blaž Hrastnik | 2021-11-21 11:06:45 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-11-21 11:06:45 +0000 |
commit | d1854d8e6af07cd78ab6c24c859a4471afb3514e (patch) | |
tree | 301e4212e7fc88dd5f626f884bd78b700cf3e4a6 /helix-view/src/macros.rs | |
parent | 8b85903116fdfdc177bf2ca171831674144de70a (diff) | |
parent | b95c9470de9f9199f109fdbfb6ec9a951fbe8866 (diff) |
Merge remote-tracking branch 'origin/master' into debug
Diffstat (limited to 'helix-view/src/macros.rs')
-rw-r--r-- | helix-view/src/macros.rs | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/helix-view/src/macros.rs b/helix-view/src/macros.rs index 63d76a42..04f8df94 100644 --- a/helix-view/src/macros.rs +++ b/helix-view/src/macros.rs @@ -11,10 +11,19 @@ /// Returns `(&mut View, &mut Document)` #[macro_export] macro_rules! current { - ( $( $editor:ident ).+ ) => {{ - let view = $crate::view_mut!( $( $editor ).+ ); + ($editor:expr) => {{ + let view = $crate::view_mut!($editor); let id = view.doc; - let doc = $( $editor ).+ .documents.get_mut(&id).unwrap(); + let doc = $editor.documents.get_mut(&id).unwrap(); + (view, doc) + }}; +} + +#[macro_export] +macro_rules! current_ref { + ($editor:expr) => {{ + let view = $editor.tree.get($editor.tree.focus); + let doc = &$editor.documents[&view.doc]; (view, doc) }}; } @@ -23,8 +32,8 @@ macro_rules! current { /// Returns `&mut Document` #[macro_export] macro_rules! doc_mut { - ( $( $editor:ident ).+ ) => {{ - $crate::current!( $( $editor ).+ ).1 + ($editor:expr) => {{ + $crate::current!($editor).1 }}; } @@ -32,8 +41,8 @@ macro_rules! doc_mut { /// Returns `&mut View` #[macro_export] macro_rules! view_mut { - ( $( $editor:ident ).+ ) => {{ - $( $editor ).+ .tree.get_mut($( $editor ).+ .tree.focus) + ($editor:expr) => {{ + $editor.tree.get_mut($editor.tree.focus) }}; } @@ -41,23 +50,14 @@ macro_rules! view_mut { /// Returns `&View` #[macro_export] macro_rules! view { - ( $( $editor:ident ).+ ) => {{ - $( $editor ).+ .tree.get($( $editor ).+ .tree.focus) + ($editor:expr) => {{ + $editor.tree.get($editor.tree.focus) }}; } #[macro_export] macro_rules! doc { - ( $( $editor:ident ).+ ) => {{ - $crate::current_ref!( $( $editor ).+ ).1 - }}; -} - -#[macro_export] -macro_rules! current_ref { - ( $( $editor:ident ).+ ) => {{ - let view = $( $editor ).+ .tree.get($( $editor ).+ .tree.focus); - let doc = &$( $editor ).+ .documents[&view.doc]; - (view, doc) + ($editor:expr) => {{ + $crate::current_ref!($editor).1 }}; } |