Add add-attachment from pipe, default_header_values
parent
6079909f9c
commit
2a9059f9b4
4
meli.1
4
meli.1
|
@ -339,6 +339,10 @@ composing mail commands:
|
|||
in composer, add
|
||||
.Ar PATH
|
||||
as an attachment
|
||||
.It Cm add-attachment < Ar CMD Ar ARGS
|
||||
in composer, pipe
|
||||
.Ar CMD Ar ARGS
|
||||
output into an attachment
|
||||
.It Cm remove-attachment Ar INDEX
|
||||
remove attachment with given index
|
||||
.It Cm toggle sign
|
||||
|
|
|
@ -281,6 +281,8 @@ If it's missing, the environment variable $EDITOR is looked up.
|
|||
(optional) set format=flowed [RFC3676] in text/plain attachments.
|
||||
.\" default value
|
||||
.Pq Em true
|
||||
.It Ic default_header_values Ar hash table String[String]
|
||||
Default header values used when creating a new draft.
|
||||
.El
|
||||
.Sh SHORTCUTS
|
||||
Shortcuts can take the following values:
|
||||
|
|
|
@ -147,6 +147,23 @@ impl Composer {
|
|||
id: ComponentId::new_v4(),
|
||||
..Default::default()
|
||||
};
|
||||
for (h, v) in context.settings.composing.default_header_values.iter() {
|
||||
if v.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if let Some(k) = ret
|
||||
.draft
|
||||
.headers()
|
||||
.keys()
|
||||
.find(|k| k.eq_ignore_ascii_case(h))
|
||||
{
|
||||
let _k = k.clone();
|
||||
ret.draft.headers_mut().insert(_k, v.into());
|
||||
} else {
|
||||
/* set_header() also updates draft's header_order field */
|
||||
ret.draft.set_header(h, v.into());
|
||||
}
|
||||
}
|
||||
ret.pager
|
||||
.set_colors(crate::conf::value(context, "theme_default"));
|
||||
ret
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
//! Configuration for composing email.
|
||||
use super::default_vals::{false_val, none, true_val};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Settings for writing and sending new e-mail
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
|
@ -38,6 +39,10 @@ pub struct ComposingSettings {
|
|||
/// Default: true
|
||||
#[serde(default = "true_val")]
|
||||
pub format_flowed: bool,
|
||||
/// Set default header values for new drafts
|
||||
/// Default: empty
|
||||
#[serde(default)]
|
||||
pub default_header_values: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl Default for ComposingSettings {
|
||||
|
@ -47,6 +52,7 @@ impl Default for ComposingSettings {
|
|||
editor_cmd: None,
|
||||
embed: false,
|
||||
format_flowed: true,
|
||||
default_header_values: HashMap::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,10 +216,16 @@ define_commands!([
|
|||
desc: "add-attachment PATH",
|
||||
parser:(
|
||||
named!( add_attachment<Action>,
|
||||
do_parse!(
|
||||
alt_complete!(
|
||||
do_parse!(
|
||||
ws!(tag!("add-attachment"))
|
||||
>> ws!(tag!("<"))
|
||||
>> cmd: quoted_argument
|
||||
>> (Compose(AddAttachmentPipe(cmd.to_string()))))
|
||||
| do_parse!(
|
||||
ws!(tag!("add-attachment"))
|
||||
>> path: quoted_argument
|
||||
>> (Compose(AddAttachment(path.to_string())))
|
||||
>> (Compose(AddAttachment(path.to_string()))))
|
||||
)
|
||||
);
|
||||
)
|
||||
|
|
|
@ -77,6 +77,7 @@ pub enum ViewAction {
|
|||
#[derive(Debug)]
|
||||
pub enum ComposeAction {
|
||||
AddAttachment(String),
|
||||
AddAttachmentPipe(String),
|
||||
RemoveAttachment(usize),
|
||||
ToggleSign,
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ impl Drop for File {
|
|||
}
|
||||
|
||||
impl File {
|
||||
pub fn file(&mut self) -> std::fs::File {
|
||||
pub fn file(&self) -> std::fs::File {
|
||||
OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
|
|
Loading…
Reference in New Issue