aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-11-18 05:13:42 +0000
committerBlaž Hrastnik2021-11-18 05:13:42 +0000
commit27ceeb83bb055c90670cb9a4d8fdab7d5c742b2f (patch)
treeef4b53d5aadf306985c065ace3e91b1a392a8e87
parentfa4c59df4623ac33c307c5637dcf74c83c71d763 (diff)
Simplify view/doc macros
-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
}};
}