aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/macros.rs')
-rw-r--r--helix-view/src/macros.rs40
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
}};
}