Break util up into modules.

This commit is contained in:
Tom Alexander 2023-12-30 22:02:43 -05:00
parent 48d3de77fe
commit 44483b4d54
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
68 changed files with 316 additions and 314 deletions

View File

@ -7,11 +7,11 @@ use crate::context::GlobalSettings;
use crate::context::LocalFileAccessInterface;
use crate::parser::parse_file_with_settings;
use crate::parser::parse_with_settings;
use crate::util::emacs_parse_anonymous_org_document;
use crate::util::emacs_parse_file_org_document;
use crate::util::foreground_color;
use crate::util::print_versions;
use crate::util::reset_color;
use crate::util::cli::emacs_parse_anonymous_org_document;
use crate::util::cli::emacs_parse_file_org_document;
use crate::util::cli::print_versions;
use crate::util::terminal::foreground_color;
use crate::util::terminal::reset_color;
pub async fn run_anonymous_compare<P: AsRef<str>>(
org_contents: P,

View File

@ -16,8 +16,6 @@ use super::compare_field::compare_property_retain_labels;
use super::compare_field::compare_property_set_of_quoted_string;
use super::compare_field::compare_property_single_ast_node;
use super::compare_field::compare_property_unquoted_atom;
use super::elisp_fact::ElispFact;
use super::elisp_fact::GetElispFact;
use super::sexp::unquote;
use super::sexp::Token;
use super::util::affiliated_keywords_names;
@ -109,8 +107,10 @@ use crate::types::Verbatim;
use crate::types::VerseBlock;
use crate::types::WarningDelayType;
use crate::types::Year;
use crate::util::foreground_color;
use crate::util::reset_color;
use crate::util::elisp_fact::ElispFact;
use crate::util::elisp_fact::GetElispFact;
use crate::util::terminal::foreground_color;
use crate::util::terminal::reset_color;
#[derive(Debug)]
pub enum DiffEntry<'b, 's> {

View File

@ -8,7 +8,6 @@ use super::compare_field::compare_property_quoted_string;
use super::compare_field::ComparePropertiesResult;
use super::diff::DiffEntry;
use super::diff::DiffStatus;
use super::elisp_fact::GetElispFact;
use super::sexp::Token;
use crate::compare::diff::compare_ast_node;
use crate::compare::sexp::unquote;
@ -16,6 +15,7 @@ use crate::types::AffiliatedKeywordValue;
use crate::types::AstNode;
use crate::types::GetAffiliatedKeywords;
use crate::types::StandardProperties;
use crate::util::elisp_fact::GetElispFact;
/// Check if the child string slice is a slice of the parent string slice.
fn is_slice_of(parent: &str, child: &str) -> bool {

View File

@ -12,7 +12,7 @@ extern crate test;
// TODO: I only include compare to use some shared stuff like sexp and DiffResult. Ideally, this would be moved to a shared module.
#[cfg(any(feature = "compare", feature = "wasm_test"))]
pub mod compare;
#[cfg(any(feature = "compare", feature = "wasm_test"))]
#[cfg(any(feature = "compare", feature = "wasm", feature = "wasm_test"))]
pub mod util;
#[cfg(any(feature = "wasm", feature = "wasm_test"))]
pub mod wasm;

191
src/util/cli.rs Normal file
View File

@ -0,0 +1,191 @@
use std::path::Path;
use tokio::process::Command;
use crate::settings::GlobalSettings;
use crate::settings::HeadlineLevelFilter;
pub async fn print_versions() -> Result<(), Box<dyn std::error::Error>> {
eprintln!("Using emacs version: {}", get_emacs_version().await?.trim());
eprintln!(
"Using org-mode version: {}",
get_org_mode_version().await?.trim()
);
Ok(())
}
pub(crate) async fn get_emacs_version() -> Result<String, Box<dyn std::error::Error>> {
let elisp_script = r#"(progn
(message "%s" (version))
)"#;
let mut cmd = Command::new("emacs");
let cmd = cmd
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
out.status.exit_ok()?;
Ok(String::from_utf8(out.stderr)?)
}
pub(crate) async fn get_org_mode_version() -> Result<String, Box<dyn std::error::Error>> {
let elisp_script = r#"(progn
(org-mode)
(message "%s" (org-version nil t nil))
)"#;
let mut cmd = Command::new("emacs");
let cmd = cmd
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
out.status.exit_ok()?;
Ok(String::from_utf8(out.stderr)?)
}
pub(crate) async fn emacs_parse_anonymous_org_document<'g, 's, C>(
file_contents: C,
global_settings: &GlobalSettings<'g, 's>,
) -> Result<String, Box<dyn std::error::Error>>
where
C: AsRef<str>,
{
let escaped_file_contents = escape_elisp_string(file_contents);
let elisp_script = format!(
r#"(progn
(erase-buffer)
(require 'org)
(defun org-table-align () t)
(insert "{escaped_file_contents}")
{global_settings}
(org-mode)
(message "%s" (pp-to-string (org-element-parse-buffer)))
)"#,
escaped_file_contents = escaped_file_contents,
global_settings = global_settings_elisp(global_settings)
);
let mut cmd = Command::new("emacs");
let cmd = cmd
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
let status = out.status.exit_ok();
if status.is_err() {
eprintln!(
"Emacs errored out: {}\n{}",
String::from_utf8(out.stdout)?,
String::from_utf8(out.stderr)?
);
status?;
unreachable!();
}
let org_sexp = out.stderr;
Ok(String::from_utf8(org_sexp)?)
}
pub(crate) async fn emacs_parse_file_org_document<'g, 's, P>(
file_path: P,
global_settings: &GlobalSettings<'g, 's>,
) -> Result<String, Box<dyn std::error::Error>>
where
P: AsRef<Path>,
{
let file_path = file_path.as_ref().canonicalize()?;
let containing_directory = file_path.parent().ok_or(format!(
"Failed to get containing directory for path {}",
file_path.display()
))?;
let elisp_script = format!(
r#"(progn
(require 'org)
(defun org-table-align () t)
(setq vc-handled-backends nil)
{global_settings}
(find-file-read-only "{file_path}")
(org-mode)
(message "%s" (pp-to-string (org-element-parse-buffer)))
)"#,
global_settings = global_settings_elisp(global_settings),
file_path = file_path
.as_os_str()
.to_str()
.expect("File name should be valid utf-8.")
);
let mut cmd = Command::new("emacs");
let cmd = cmd
.current_dir(containing_directory)
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
let status = out.status.exit_ok();
if status.is_err() {
eprintln!(
"Emacs errored out: {}\n{}",
String::from_utf8(out.stdout)?,
String::from_utf8(out.stderr)?
);
status?;
unreachable!();
}
let org_sexp = out.stderr;
Ok(String::from_utf8(org_sexp)?)
}
fn escape_elisp_string<C>(file_contents: C) -> String
where
C: AsRef<str>,
{
let source = file_contents.as_ref();
let source_len = source.len();
// We allocate a string 10% larger than the source to account for escape characters. Without this, we would have more allocations during processing.
let mut output = String::with_capacity(source_len + (source_len / 10));
for c in source.chars() {
match c {
'"' | '\\' => {
output.push('\\');
output.push(c);
}
_ => {
output.push(c);
}
}
}
output
}
/// Generate elisp to configure org-mode parsing settings
///
/// Currently only org-list-allow-alphabetical is supported.
fn global_settings_elisp(global_settings: &GlobalSettings) -> String {
// This string concatenation is wildly inefficient but its only called in tests 🤷.
let mut ret = "".to_owned();
if global_settings.list_allow_alphabetical {
ret += "(setq org-list-allow-alphabetical t)\n"
}
if global_settings.tab_width != crate::settings::DEFAULT_TAB_WIDTH {
ret += format!("(setq-default tab-width {})", global_settings.tab_width).as_str();
}
if global_settings.odd_levels_only != HeadlineLevelFilter::default() {
ret += match global_settings.odd_levels_only {
HeadlineLevelFilter::Odd => "(setq org-odd-levels-only t)\n",
HeadlineLevelFilter::OddEven => "(setq org-odd-levels-only nil)\n",
};
}
ret
}

View File

@ -1,236 +1,6 @@
mod elisp_fact;
use std::borrow::Cow;
use std::path::Path;
pub(crate) use elisp_fact::ElispFact;
use tokio::process::Command;
use crate::settings::GlobalSettings;
use crate::settings::HeadlineLevelFilter;
pub async fn print_versions() -> Result<(), Box<dyn std::error::Error>> {
eprintln!("Using emacs version: {}", get_emacs_version().await?.trim());
eprintln!(
"Using org-mode version: {}",
get_org_mode_version().await?.trim()
);
Ok(())
}
pub(crate) async fn get_emacs_version() -> Result<String, Box<dyn std::error::Error>> {
let elisp_script = r#"(progn
(message "%s" (version))
)"#;
let mut cmd = Command::new("emacs");
let cmd = cmd
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
out.status.exit_ok()?;
Ok(String::from_utf8(out.stderr)?)
}
pub(crate) async fn get_org_mode_version() -> Result<String, Box<dyn std::error::Error>> {
let elisp_script = r#"(progn
(org-mode)
(message "%s" (org-version nil t nil))
)"#;
let mut cmd = Command::new("emacs");
let cmd = cmd
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
out.status.exit_ok()?;
Ok(String::from_utf8(out.stderr)?)
}
pub(crate) async fn emacs_parse_anonymous_org_document<'g, 's, C>(
file_contents: C,
global_settings: &GlobalSettings<'g, 's>,
) -> Result<String, Box<dyn std::error::Error>>
where
C: AsRef<str>,
{
let escaped_file_contents = escape_elisp_string(file_contents);
let elisp_script = format!(
r#"(progn
(erase-buffer)
(require 'org)
(defun org-table-align () t)
(insert "{escaped_file_contents}")
{global_settings}
(org-mode)
(message "%s" (pp-to-string (org-element-parse-buffer)))
)"#,
escaped_file_contents = escaped_file_contents,
global_settings = global_settings_elisp(global_settings)
);
let mut cmd = Command::new("emacs");
let cmd = cmd
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
let status = out.status.exit_ok();
if status.is_err() {
eprintln!(
"Emacs errored out: {}\n{}",
String::from_utf8(out.stdout)?,
String::from_utf8(out.stderr)?
);
status?;
unreachable!();
}
let org_sexp = out.stderr;
Ok(String::from_utf8(org_sexp)?)
}
pub(crate) async fn emacs_parse_file_org_document<'g, 's, P>(
file_path: P,
global_settings: &GlobalSettings<'g, 's>,
) -> Result<String, Box<dyn std::error::Error>>
where
P: AsRef<Path>,
{
let file_path = file_path.as_ref().canonicalize()?;
let containing_directory = file_path.parent().ok_or(format!(
"Failed to get containing directory for path {}",
file_path.display()
))?;
let elisp_script = format!(
r#"(progn
(require 'org)
(defun org-table-align () t)
(setq vc-handled-backends nil)
{global_settings}
(find-file-read-only "{file_path}")
(org-mode)
(message "%s" (pp-to-string (org-element-parse-buffer)))
)"#,
global_settings = global_settings_elisp(global_settings),
file_path = file_path
.as_os_str()
.to_str()
.expect("File name should be valid utf-8.")
);
let mut cmd = Command::new("emacs");
let cmd = cmd
.current_dir(containing_directory)
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
let status = out.status.exit_ok();
if status.is_err() {
eprintln!(
"Emacs errored out: {}\n{}",
String::from_utf8(out.stdout)?,
String::from_utf8(out.stderr)?
);
status?;
unreachable!();
}
let org_sexp = out.stderr;
Ok(String::from_utf8(org_sexp)?)
}
fn escape_elisp_string<C>(file_contents: C) -> String
where
C: AsRef<str>,
{
let source = file_contents.as_ref();
let source_len = source.len();
// We allocate a string 10% larger than the source to account for escape characters. Without this, we would have more allocations during processing.
let mut output = String::with_capacity(source_len + (source_len / 10));
for c in source.chars() {
match c {
'"' | '\\' => {
output.push('\\');
output.push(c);
}
_ => {
output.push(c);
}
}
}
output
}
/// Generate elisp to configure org-mode parsing settings
///
/// Currently only org-list-allow-alphabetical is supported.
fn global_settings_elisp(global_settings: &GlobalSettings) -> String {
// This string concatenation is wildly inefficient but its only called in tests 🤷.
let mut ret = "".to_owned();
if global_settings.list_allow_alphabetical {
ret += "(setq org-list-allow-alphabetical t)\n"
}
if global_settings.tab_width != crate::settings::DEFAULT_TAB_WIDTH {
ret += format!("(setq-default tab-width {})", global_settings.tab_width).as_str();
}
if global_settings.odd_levels_only != HeadlineLevelFilter::default() {
ret += match global_settings.odd_levels_only {
HeadlineLevelFilter::Odd => "(setq org-odd-levels-only t)\n",
HeadlineLevelFilter::OddEven => "(setq org-odd-levels-only nil)\n",
};
}
ret
}
fn should_use_color() -> bool {
!std::env::var("NO_COLOR").is_ok_and(|val| !val.is_empty())
}
pub(crate) fn foreground_color(red: u8, green: u8, blue: u8) -> Cow<'static, str> {
if should_use_color() {
format!(
"\x1b[38;2;{red};{green};{blue}m",
red = red,
green = green,
blue = blue
)
.into()
} else {
Cow::from("")
}
}
#[allow(dead_code)]
pub(crate) fn background_color(red: u8, green: u8, blue: u8) -> Cow<'static, str> {
if should_use_color() {
format!(
"\x1b[48;2;{red};{green};{blue}m",
red = red,
green = green,
blue = blue
)
.into()
} else {
Cow::from("")
}
}
pub(crate) fn reset_color() -> &'static str {
if should_use_color() {
"\x1b[0m"
} else {
""
}
}
#[cfg(any(feature = "compare", feature = "wasm_test"))]
pub mod cli;
#[cfg(any(feature = "compare", feature = "wasm", feature = "wasm_test"))]
pub mod elisp_fact;
#[cfg(any(feature = "compare", feature = "wasm_test"))]
pub mod terminal;

42
src/util/terminal.rs Normal file
View File

@ -0,0 +1,42 @@
use std::borrow::Cow;
fn should_use_color() -> bool {
!std::env::var("NO_COLOR").is_ok_and(|val| !val.is_empty())
}
pub(crate) fn foreground_color(red: u8, green: u8, blue: u8) -> Cow<'static, str> {
if should_use_color() {
format!(
"\x1b[38;2;{red};{green};{blue}m",
red = red,
green = green,
blue = blue
)
.into()
} else {
Cow::from("")
}
}
#[allow(dead_code)]
pub(crate) fn background_color(red: u8, green: u8, blue: u8) -> Cow<'static, str> {
if should_use_color() {
format!(
"\x1b[48;2;{red};{green};{blue}m",
red = red,
green = green,
blue = blue
)
.into()
} else {
Cow::from("")
}
}
pub(crate) fn reset_color() -> &'static str {
if should_use_color() {
"\x1b[0m"
} else {
""
}
}

View File

@ -6,7 +6,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::AngleLink;
use crate::types::LinkType;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::BabelCall;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Bold;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::CenterBlock;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Citation;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::CitationReference;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Clock;
use crate::types::ClockStatus;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Code;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Comment;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::CommentBlock;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::DiarySexp;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -8,7 +8,7 @@ use super::additional_property::AdditionalPropertyValue;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Document;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Drawer;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::DynamicBlock;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::headline::Noop;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Entity;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -8,7 +8,7 @@ use super::src_block::WasmNumberLinesWrapper;
use super::src_block::WasmRetainLabels;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::CharOffsetInLine;
use crate::types::ExampleBlock;
use crate::types::GetAffiliatedKeywords;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::ExportBlock;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::ExportSnippet;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::FixedWidthArea;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -6,7 +6,7 @@ use super::headline::Noop;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::FootnoteDefinition;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::FootnoteReference;
use crate::types::FootnoteReferenceType;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -6,7 +6,7 @@ use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use super::AdditionalPropertyValue;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Heading;
use crate::types::HeadlineLevel;
use crate::types::PriorityCookie;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::HorizontalRule;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::InlineBabelCall;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::InlineSourceBlock;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Italic;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::Keyword;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::LatexEnvironment;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::LatexFragment;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::LineBreak;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -46,8 +46,7 @@ macro_rules! to_wasm {
}
}
#[cfg(feature = "wasm_test")]
impl<'s> crate::compare::ElispFact<'s> for $ostruct {
impl<'s> crate::util::elisp_fact::ElispFact<'s> for $ostruct {
fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> {
let $original = self;
let ret = $elispnamebody;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::NodeProperty;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::OrgMacro;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::Paragraph;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::LinkType;
use crate::types::PlainLink;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::PlainList;
use crate::types::PlainListType;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::CheckboxType;
use crate::types::PlainListItem;
use crate::types::PlainListItemCounter;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::PlainText;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Planning;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::PropertyDrawer;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::QuoteBlock;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::RadioLink;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::RadioTarget;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -6,7 +6,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::LinkType;
use crate::types::RegularLink;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Section;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -6,7 +6,7 @@ use super::headline::Noop;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::SpecialBlock;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::CharOffsetInLine;
use crate::types::GetAffiliatedKeywords;
use crate::types::LineNumber;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::StatisticsCookie;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::StrikeThrough;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Subscript;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Superscript;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -7,7 +7,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::Table;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::TableCell;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::TableRow;
use crate::types::TableRowType;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Target;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::DayOfMonthInner;
use crate::types::HourInner;
use crate::types::MinuteInner;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Underline;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -4,7 +4,7 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::Verbatim;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -5,7 +5,7 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::VerseBlock;
use crate::wasm::to_wasm::ToWasmStandardProperties;

View File

@ -1,7 +1,7 @@
use std::borrow::Cow;
use crate::util::foreground_color;
use crate::util::reset_color;
use crate::util::terminal::foreground_color;
use crate::util::terminal::reset_color;
#[derive(Debug)]
pub struct WasmDiffResult<'s> {

View File

@ -6,11 +6,11 @@ use crate::context::GlobalSettings;
use crate::parser::parse_file_with_settings;
use crate::parser::parse_with_settings;
use crate::settings::LocalFileAccessInterface;
use crate::util::emacs_parse_anonymous_org_document;
use crate::util::emacs_parse_file_org_document;
use crate::util::foreground_color;
use crate::util::print_versions;
use crate::util::reset_color;
use crate::util::cli::emacs_parse_anonymous_org_document;
use crate::util::cli::emacs_parse_file_org_document;
use crate::util::cli::print_versions;
use crate::util::terminal::foreground_color;
use crate::util::terminal::reset_color;
use crate::wasm::ToWasm;
use crate::wasm::ToWasmContext;