Browse Source

conf: add editor_cmd setting

Set the editor to launch in configuration. If it's missing, check for
Manos Pitsidianakis 10 months ago
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS. GPG Key ID: 73627C2F690DF710
6 changed files with 74 additions and 29 deletions
  1. +36
  2. +7
  3. +2
  4. +18
  5. +6
  6. +5

+ 36
- 0
meli.1 View File

@@ -77,6 +77,42 @@ The view into each folder has 4 modes: plain, threaded, conversations and compac
^^ (`-=-=-=-=-`)
`-=-=-=-=-` ^^
To send mail, press
.Cm m
while viewing the appropriate account to open a new composing tab. To reply to a mail, press
.Cm R Ns
\&. You can edit some of the header fields from within the view, by selecting with the arrow keys and pressing
.Cm enter
to enter
mode. At any time you can press
.Cm e
to launch your editor (see
.Xr meli.conf 5
for how to select which editor to launch). Attachments can be handled with the
.Em add-attachment Ns
.Em remove-attachment
commands (see below). Finally, pressing
.Ar s
will send your message by piping it into a binary of your choosing (see
.Xr meli.conf 5
, setting
.Em mailer_cmd Ns
). To save your draft without sending it, issue command
.Cm close
and select 'save as draft'.
If there is no Draft or Sent folder, meli tries first saving mail in your INBOX and then at any other folder. On complete failure to save your draft or sent message it will be saved in your
.Em tmp
directory instead and you will be notified of its location.
To open a draft for editing later, select your draft in the mail listing and press
.Cm e Ns
.Sh EXECUTE mode
Commands are issued in EXECUTE mode, by default started with the space character and exited with Escape key.

+ 7
- 4
meli.conf.5 View File

@@ -41,7 +41,7 @@ Newline means LF (0x0A) or CRLF (0x0D 0x0A).
Refer to TOML documentation for valid TOML syntax.
The top level sections of the config are accounts, shortcuts, notifications, pager, mailer, pgp.
The top level sections of the config are accounts, shortcuts, notifications, pager, composing, pgp.
.Sy example configuration
.Bd -literal
@@ -74,9 +74,10 @@ filter = "/usr/bin/pygmentize"
script = "notify-send"

# required for sending e-mail
mailer_cmd = 'msmtp --read-recipients --read-envelope-from'
editor_cmd = 'vim +/^$'

scroll_up = 'k'
@@ -172,7 +173,7 @@ example:
otherwise usage is inferred from the folder title.
.It Cm conf_override Ar boolean
(optional) override global settings for this folder. available sections to override are
.Em pager, notifications, shortcuts, mailer
.Em pager, notifications, shortcuts, composing
and the account options
.Em identity and index_style Ns
\&. example:
@@ -183,10 +184,12 @@ and the account options
filter = ""
.Bl -tag -width "danger_accept_invalid_certs boolean" -offset -indent
.It Cm mailer_cmd Ar String
command to pipe new mail to, exit code must be 0 for success.
.It Cm editor_cmd Ar String
command to launch editor. Can have arguments. Draft filename is given as the last argument. If it's missing, the environment variable $EDITOR is looked up.
Shortcuts can take the following values:

+ 2
- 1
sample-config View File

@@ -54,6 +54,7 @@
#page_up = PageUp,
#page_down = PageDown,

# required for sending e-mail
#mailer_cmd = 'msmtp --read-recipients --read-envelope-from'
#editor_cmd = 'vim +/^$' # optional, by default $EDITOR is used.

+ 18
- 15
ui/src/components/mail/ View File

@@ -589,22 +589,24 @@ impl Component for Composer {
return true;
UIEvent::Input(Key::Char('e')) if self.cursor == Cursor::Body => {
UIEvent::Input(Key::Char('e')) => {
/* Edit draft in $EDITOR */
use std::process::{Command, Stdio};
let editor = match std::env::var("EDITOR") {
Err(e) => {
"$EDITOR is not set. You can change an envvar's value with setenv"
let settings = &context.settings;
let editor = if let Some(editor_cmd) = settings.composing.editor_cmd.as_ref() {
} else {
match std::env::var("EDITOR") {
Err(e) => {
"$EDITOR is not set. You can change an envvar's value with setenv or set composing.editor_cmd setting in your configuration.".to_string(),
return true;
return true;
Ok(v) => v,
Ok(v) => v,
/* Kill input thread so that spawned command can be sole receiver of stdin */
@@ -619,9 +621,10 @@ impl Component for Composer {

// TODO: check exit status
if let Err(e) = Command::new(&editor)
let parts = split_command!(editor);
let (cmd, args) = (parts[0], &parts[1..]);
if let Err(e) = Command::new(cmd)
@@ -760,7 +763,7 @@ pub fn send_draft(context: &mut Context, account_cursor: usize, draft: Draft) ->
use std::process::{Command, Stdio};
let mut failure = true;
let settings = &context.settings;
let parts = split_command!(settings.mailer.mailer_cmd);
let parts = split_command!(settings.composing.mailer_cmd);
let (cmd, args) = (parts[0], &parts[1..]);
let mut msmtp = Command::new(cmd)

+ 6
- 6
ui/src/ View File

@@ -24,7 +24,7 @@ extern crate serde;
extern crate toml;
extern crate xdg;

pub mod mailer;
pub mod composing;
pub mod notifications;
pub mod pager;
pub mod pgp;
@@ -32,7 +32,7 @@ pub mod shortcuts;

pub mod accounts;
pub use self::accounts::Account;
pub use self::mailer::*;
pub use self::composing::*;
pub use self::pgp::*;
pub use self::shortcuts::*;

@@ -96,7 +96,7 @@ pub struct MailUIConf {
pub pager: Option<PagerSettings>,
pub notifications: Option<NotificationsSettings>,
pub shortcuts: Option<Shortcuts>,
pub mailer: Option<MailerSettings>,
pub composing: Option<ComposingSettings>,
pub identity: Option<String>,
pub index_style: Option<IndexStyle>,
@@ -273,7 +273,7 @@ struct FileSettings {
notifications: NotificationsSettings,
shortcuts: Shortcuts,
mailer: MailerSettings,
composing: ComposingSettings,
pgp: PGPSettings,
@@ -303,7 +303,7 @@ pub struct Settings {
pub pager: PagerSettings,
pub notifications: NotificationsSettings,
pub shortcuts: Shortcuts,
pub mailer: MailerSettings,
pub composing: ComposingSettings,
pub pgp: PGPSettings,

@@ -391,7 +391,7 @@ impl Settings {
pager: fs.pager,
notifications: fs.notifications,
shortcuts: fs.shortcuts,
mailer: fs.mailer,
composing: fs.composing,
pgp: fs.pgp,

ui/src/conf/ → ui/src/conf/ View File

@@ -1,5 +1,5 @@
* meli - notifications conf module
* meli - conf module
* Copyright 2019 Manos Pitsidianakis
@@ -19,10 +19,12 @@
* along with meli. If not, see <>.

/// Settings for the mailer function.
/// Settings for writing and sending new e-mail
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct MailerSettings {
pub struct ComposingSettings {
/// A command to pipe new emails to
/// Required
pub mailer_cmd: String,
/// Command to launch editor. Can have arguments. Draft filename is given as the last argument. If it's missing, the environment variable $EDITOR is looked up.
pub editor_cmd: Option<String>,