Commit b995906c79

b995906c7937fdedc7e6fb3601851ca85555f89c

parent: e5b284ed19

Unregistered key

Ethan Reynolds <1653607+reynoldsme@users.noreply.github.com> · 2024-04-12 03:50 UTC
committer: <noreply@github.com>

Add `external_edit_file_suffix` to config (#253)

Layout: unified · split

config.example.toml +1
@@ -6,6 +6,7 @@ url = "https://matrix.org"
66
77[settings]
88default_room = "#iamb-users:0x.badd.cafe"
9external_edit_file_suffix = ".md"
910log_level = "warn"
1011message_shortcode_display = false
1112open_command = ["my-open", "--file"]
docs/iamb.5 +3
@@ -125,6 +125,9 @@ key and can be overridden as described in
125125.Sx PROFILES .
126126.Bl -tag -width Ds
127127
128.It Sy external_edit_file_suffix
129Suffix to append to temporary file names when using the :editor command. Defaults to .md.
130
128131.It Sy default_room
129132The room to show by default instead of the
130133.Sy :welcome
src/config.rs +8
@@ -507,6 +507,7 @@ pub struct TunableValues {
507507 pub notifications: Notifications,
508508 pub image_preview: Option<ImagePreviewValues>,
509509 pub user_gutter_width: usize,
510 pub external_edit_file_suffix: String,
510511}
511512
512513#[derive(Clone, Default, Deserialize)]
@@ -530,6 +531,7 @@ pub struct Tunables {
530531 pub notifications: Option<Notifications>,
531532 pub image_preview: Option<ImagePreview>,
532533 pub user_gutter_width: Option<usize>,
534 pub external_edit_file_suffix: Option<String>,
533535}
534536
535537impl Tunables {
@@ -557,6 +559,9 @@ impl Tunables {
557559 notifications: self.notifications.or(other.notifications),
558560 image_preview: self.image_preview.or(other.image_preview),
559561 user_gutter_width: self.user_gutter_width.or(other.user_gutter_width),
562 external_edit_file_suffix: self
563 .external_edit_file_suffix
564 .or(other.external_edit_file_suffix),
560565 }
561566 }
562567
@@ -580,6 +585,9 @@ impl Tunables {
580585 notifications: self.notifications.unwrap_or_default(),
581586 image_preview: self.image_preview.map(ImagePreview::values),
582587 user_gutter_width: self.user_gutter_width.unwrap_or(30),
588 external_edit_file_suffix: self
589 .external_edit_file_suffix
590 .unwrap_or_else(|| ".md".to_string()),
583591 }
584592 }
585593}
src/tests.rs +1
@@ -186,6 +186,7 @@ pub fn mock_tunables() -> TunableValues {
186186 .into_iter()
187187 .collect::<HashMap<_, _>>(),
188188 open_command: None,
189 external_edit_file_suffix: String::from(".md"),
189190 username_display: UserDisplayStyle::Username,
190191 message_user_color: false,
191192 notifications: Notifications {
src/windows/room/chat.rs +5 −2
@@ -5,7 +5,8 @@ use std::fs;
55use std::ops::Deref;
66use std::path::{Path, PathBuf};
77
8use edit::edit as external_edit;
8use edit::edit_with_builder as external_edit;
9use edit::Builder;
910use modalkit::editing::store::RegisterError;
1011use std::process::Command;
1112use tokio;
@@ -481,7 +482,9 @@ impl ChatState {
481482 let msg = self.tbox.get();
482483
483484 let msg = if let SendAction::SubmitFromEditor = act {
484 external_edit(msg.trim_end().to_string())?
485 let suffix =
486 store.application.settings.tunables.external_edit_file_suffix.as_str();
487 external_edit(msg.trim_end().to_string(), Builder::new().suffix(suffix))?
485488 } else if msg.is_blank() {
486489 return Ok(None);
487490 } else {