Retidy shortcuts

jmap
Manos Pitsidianakis 2019-11-27 01:43:03 +02:00
parent afff63c781
commit 2199726b2c
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
7 changed files with 289 additions and 65 deletions

26
meli.1
View File

@ -62,8 +62,10 @@ At any time, you may press
.Cm \&?
to show a searchable list of all available actions and shortcuts, along with every possible setting and command that your version supports.
.Pp
The main visual navigation tool is the left-side sidebar. The menu's visibility may be toggled (default shortcut
.Cm ` Ns
The main visual navigation tool is the left-side sidebar. The menu's visibility may be toggled with
.Cm `
(shortcuts.listing:
.Ic toggle_menu_visibility Ns
).
.Pp
The view into each folder has 4 modes: plain, threaded, conversations and compact. Plain views each mail indvidually, threaded shows their thread relationship visually, and conversations includes one entry per thread of emails (compact is one row per thread).
@ -115,7 +117,9 @@ to enter
mode. At any time you may press
.Cm e
to launch your editor (see
.Xr meli.conf 5 COMPOSING
.Xr meli.conf 5 COMPOSING Ns
, setting
.Ic editor_cmd
for how to select which editor to launch). Attachments may be handled with the
.Em add-attachment Ns
,
@ -125,7 +129,7 @@ commands (see below). Finally, pressing
will send your message by piping it into a binary of your choosing (see
.Xr meli.conf 5 COMPOSING Ns
, setting
.Em mailer_cmd Ns
.Ic mailer_cmd Ns
). To save your draft without sending it, issue command
.Cm close
and select 'save as draft'.
@ -139,6 +143,20 @@ 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
\&.
Your editor can be used in
.Nm Ns
\&'s embed terminal emulator by setting
.Ic embed
to
.Em true
in your composing settings. When launched, your editor captures all input until it exits or stops. To stop your editor and return to
.Nm
issue Ctrl-z and to resume editing press the
.Ic edit_mail
command again (default
.Em e Ns
).
.Sh SEARCH
Each e-mail storage backend has its default search method.
.Em IMAP

View File

@ -81,10 +81,12 @@ mailer_cmd = 'msmtp --read-recipients --read-envelope-from'
editor_cmd = 'vim +/^$'
[shortcuts]
scroll_up = 'k'
scroll_down = 'j'
page_up = PageUp
page_down = PageDown
[shortcuts.composing]
edit_mail = 'e'
[shortcuts.listing]
new_mail = 'm'
set_seen = 'n'
[terminal]
theme = "light"
@ -248,42 +250,234 @@ Shortcuts can take the following values:
.Qq Em PageDown
.Qq Em Delete
.Qq Em Insert
.Qq Em Enter
.Qq Em Tab
.Qq Em Esc
.Qq Em F1..F12
.Qq Em M-char
.Qq Em C-char
and
.Qq Em char Ns
, where char is a single character string.
The headings before each list indicate the map key of the shortcut list. For example for the first list titled
.Em general
the configuration is typed as follows:
.Bd -literal
[shortcuts.general]
next_tab = 'T'
.Ed
and for
.Em compact-listing Ns
:
.Bd -literal
[shortcuts.compact-listing]
open_thread = "Enter"
exit_thread = 'i'
.Bd
.Sy Em general
.Bl -tag -width 36n
.It Ic next_tab
Go to next tab.
.\" default value
.Pq Em T
.It Ic go_to_tab
Go to the
.Em n Ns
th tab
.Pq Em cannot be redefined
.El
.Sy Em listing
.Bl -tag -width 36n
.It Ic prev_page
Go to previous page.
.\" default value
.Pq Em PageUp
.It Ic next_page
Go to next page.
.\" default value
.Pq Em PageDown
.It Ic prev_folder
Go to previous folder.
.\" default value
.Pq Em K
.It Ic next_folder
Go to next folder.
.\" default value
.Pq Em J
.It Ic prev_account
Go to previous account.
.\" default value
.Pq Em l
.It Ic next_account
Go to next account.
.\" default value
.Pq Em h
.It Ic new_mail
Start new mail draft in new tab
.It Ic open_thread
Open thread.
.\" default value
.Pq Em m
.It Ic search
Search within list of e-mails.
.\" default value
.Pq Em /
.It Ic toggle_menu_visibility
Toggle visibility of side menu in mail list.
.\" default value
.Pq Em `
.El
.Sy Em compact-listing
.Bl -tag -width 36n
.It Ic exit_thread
Exit thread view
.\" default value
.Pq Em i
.It Ic open_thread
Open thread.
.\" default value
.Pq Em Enter
.It Ic select_entry
Select thread entry.
.\" default value
.Pq Em v
.El
.Sy Em pager
.Bl -tag -width 36n
.It Ic scroll_up
Scroll up pager.
.\" default value
.Pq Em k
.It Ic scroll_down
Scroll down pager.
.\" default value
.Pq Em j
.It Ic page_up
Go to previous pager page
.\" default value
.Pq Em PageUp
.It Ic page_down
Go to next pager pag
.\" default value
.Pq Em PageDown
.El
.Sy Em contact-list
.Bl -tag -width 36n
.It Ic create_contact
Create new contact.
.\" default value
.Pq Em c
.It Ic edit_contact
Edit contact under cursor
.\" default value
.Pq Em e
.It Ic mail_contact
Mail contact under cursor
.\" default value
.Pq Em m
.It Ic toggle_menu_visibility
Toggle visibility of side menu in mail list.
.\" default value
.Pq Em `
.El
.Sy Em composing
.Bl -tag -width 36n
.It Ic send_mail
Deliver draft to mailer
.\" default value
.Pq Em s
.It Ic edit_mail
Edit mail.
.\" default value
.Pq Em e
.El
.Sy Em envelope-view
To "select" an attachment, type its index (you will see the typed result in the command buffer on your bottom right of the status line) and then issue the corresponding command.
.Bl -tag -width 36n
.It Ic add_addresses_to_contacts Ns
Select addresses from envelope to add to contacts.
.\" default value
.Pq Em c
.It Ic view_raw_source
View raw envelope source in a pager.
.\" default value
.Pq Em M-r
.It Ic reply
Reply to envelope.
.\" default value
.Pq Em R
.It Ic edit
Open envelope in composer.
.\" default value
.Pq Em e
.It Ic return_to_normal_view
Return to envelope if viewing raw source or attachment.
.\" default value
.Pq Em r
.It Ic open_attachment
Opens selected attachment with
.Cm xdg-open
.\" default value
.Pq Em a
.It Ic open_mailcap
Opens selected attachment according to its mailcap entry. See
.Xr meli.1 FILES
for the mailcap file locations.
.\" default value
.Pq Em m
.It Ic go_to_url
Go to url of given index
.\" default value
.Pq Em g
.It Ic toggle_url_mode
Toggles url open mode. When active, it prepends an index next to each url that you can select by typing and open by issuing
.Ic go_to_url
.\" default value
.Pq Em u
.It Ic toggle_expand_headers
Expand extra headers (References and others)
.\" default value
.Pq Em h
.El
.Sy Em thread-view
.Bl -tag -width 36n
.It Ic reverse_thread_order
Reverse thread order.
.\" default value
.Pq Em r
.It Ic toggle_mailview
Toggle mail view visibility.
.\" default value
.Pq Em p
.It Ic toggle_threadview
Toggle thread view visibility.
.\" default value
.Pq Em t
.It Ic collapse_subtree
Collapse thread branches.
.\" default value
.Pq Em h
.It Ic prev_page
Go to previous page.
.\" default value
.Pq Em PageUp
.It Ic next_page
Go to next page.
.\" default value
.Pq Em PageDown
.El
.Bl -tag -width 36n
.Sh NOTIFICATIONS
.Bl -tag -width 36n
.It Ic enable Ar boolean

View File

@ -68,8 +68,11 @@
#sound_file = PATH # optional
##shortcuts
# Compact mail listing defaults:
#[shortcuts.compact_listing]
#[shortcuts.composing]
#edit_mail = 'e'
#
# Thread view defaults:
#[shortcuts.compact-listing]
#exit_thread = 'i'
#
#[shortcuts.contact-list]

View File

@ -105,7 +105,7 @@ impl fmt::Display for MailView {
}
impl MailView {
const DESCRIPTION: &'static str = "mail";
const DESCRIPTION: &'static str = "view mail";
pub fn new(
coordinates: (usize, usize, EnvelopeHash),
pager: Option<Pager>,
@ -1316,27 +1316,21 @@ impl Component for MailView {
self.pager.get_shortcuts(context)
};
let mut our_map = FnvHashMap::with_capacity_and_hasher(4, Default::default());
our_map.insert("add_addresses_to_contacts", Key::Char('c'));
our_map.insert("view_raw_source", Key::Alt('r'));
our_map.insert("reply", Key::Char('R'));
our_map.insert("edit", Key::Char('e'));
if self.mode.is_attachment()
let mut our_map = context.settings.shortcuts.envelope_view.key_values();
if !(self.mode.is_attachment()
|| self.mode == ViewMode::Subview
|| self.mode == ViewMode::Raw
|| self.mode == ViewMode::Url
|| self.mode == ViewMode::Url)
{
our_map.insert("return_to_normal_view", Key::Char('r'));
our_map.remove("return_to_normal_view");
}
our_map.insert("open_attachment", Key::Char('a'));
our_map.insert("open_mailcap", Key::Char('m'));
if self.mode == ViewMode::Url {
our_map.insert("go_to_url", Key::Char('g'));
if self.mode != ViewMode::Url {
our_map.remove("go_to_url");
}
if self.mode == ViewMode::Normal || self.mode == ViewMode::Url {
our_map.insert("toggle_url_mode", Key::Char('u'));
if !(self.mode == ViewMode::Normal || self.mode == ViewMode::Url) {
our_map.remove("toggle_url_mode");
}
our_map.insert("toggle_expand_headers", Key::Char('h'));
map.insert(MailView::DESCRIPTION, our_map);
map

View File

@ -1094,8 +1094,7 @@ impl Component for ThreadView {
}
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
let mut map = self.mailview.get_shortcuts(context);
//FIXME
let config_map = context.settings.shortcuts.envelope_view.key_values();
let config_map = context.settings.shortcuts.thread_view.key_values();
map.insert(ThreadView::DESCRIPTION, config_map);

View File

@ -17,6 +17,8 @@ pub struct Shortcuts {
#[serde(default)]
pub envelope_view: EnvelopeViewShortcuts,
#[serde(default)]
pub thread_view: ThreadViewShortcuts,
#[serde(default)]
pub pager: PagerShortcuts,
}
@ -26,7 +28,7 @@ macro_rules! shortcut_key_values {
(
$cname:expr,
$(#[$outer:meta])*
pub struct $name:ident { $($fname:ident : Key |> $fdesc:literal |> $default:expr),* }) => {
pub struct $name:ident { $($fname:ident |> $fdesc:literal |> $default:expr),* }) => {
$(#[$outer])*
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
@ -64,71 +66,86 @@ macro_rules! shortcut_key_values {
shortcut_key_values! { "compact-listing",
/// Shortcut listing for a mail listing in compact mode.
pub struct CompactListingShortcuts {
open_thread: Key |> "Open thread." |> Key::Char('\n'),
exit_thread: Key |> "Exit thread view." |> Key::Char('i'),
select_entry: Key |> "Select thread entry." |> Key::Char('v')
exit_thread |> "Exit thread view." |> Key::Char('i'),
open_thread |> "Open thread." |> Key::Char('\n'),
select_entry |> "Select thread entry." |> Key::Char('v')
}
}
shortcut_key_values! { "listing",
/// Shortcut listing for a mail listing.
pub struct ListingShortcuts {
prev_page: Key |> "Go to previous page." |> Key::PageUp,
next_page: Key |> "Go to next page." |> Key::PageDown,
prev_folder: Key |> "Go to previous folder." |> Key::Char('K'),
next_folder: Key |> "Go to next folder." |> Key::Char('J'),
prev_account: Key |> "Go to previous account." |> Key::Char('l'),
next_account: Key |> "Go to next account." |> Key::Char('h'),
new_mail: Key |> "Start new mail draft in new tab." |> Key::Char('m'),
set_seen: Key |> "Set thread as seen." |> Key::Char('n'),
search: Key |> "Search within list of e-mails." |> Key::Char('/'),
toggle_menu_visibility: Key |> "Toggle visibility of side menu in mail list." |> Key::Char('`')
new_mail |> "Start new mail draft in new tab." |> Key::Char('m'),
next_account |> "Go to next account." |> Key::Char('h'),
next_folder |> "Go to next folder." |> Key::Char('J'),
next_page |> "Go to next page." |> Key::PageDown,
prev_account |> "Go to previous account." |> Key::Char('l'),
prev_folder |> "Go to previous folder." |> Key::Char('K'),
prev_page |> "Go to previous page." |> Key::PageUp,
search |> "Search within list of e-mails." |> Key::Char('/'),
set_seen |> "Set thread as seen." |> Key::Char('n'),
toggle_menu_visibility |> "Toggle visibility of side menu in mail list." |> Key::Char('`')
}
}
shortcut_key_values! { "contact-list",
/// Shortcut listing for the contact list view
pub struct ContactListShortcuts {
create_contact: Key |> "Create new contact." |> Key::Char('c'),
edit_contact: Key |> "Edit contact under cursor." |> Key::Char('e'),
toggle_menu_visibility: Key |> "Toggle visibility of side menu in mail list." |> Key::Char('`'),
prev_account: Key |> "Go to previous account." |> Key::Char('l'),
next_account: Key |> "Go to next account." |> Key::Char('h')
create_contact |> "Create new contact." |> Key::Char('c'),
edit_contact |> "Edit contact under cursor." |> Key::Char('e'),
mail_contact |> "Mail contact under cursor." |> Key::Char('m'),
next_account |> "Go to next account." |> Key::Char('h'),
prev_account |> "Go to previous account." |> Key::Char('l'),
toggle_menu_visibility |> "Toggle visibility of side menu in mail list." |> Key::Char('`')
}
}
shortcut_key_values! { "pager",
/// Shortcut listing for the text pager
pub struct PagerShortcuts {
scroll_up: Key |> "Scroll up pager." |> Key::Char('k'),
scroll_down: Key |> "Scroll down pager." |> Key::Char('j'),
page_up: Key |> "Go to previous pager page" |> Key::PageUp,
page_down: Key |> "Go to next pager page" |> Key::PageDown
page_down |> "Go to next pager page" |> Key::PageDown,
page_up |> "Go to previous pager page" |> Key::PageUp,
scroll_down |> "Scroll down pager." |> Key::Char('j'),
scroll_up |> "Scroll up pager." |> Key::Char('k')
}
}
shortcut_key_values! { "general",
pub struct GeneralShortcuts {
next_tab: Key |> "Next tab." |> Key::Char('T'),
go_to_tab: Key |> "Go to the nth tab" |> Key::Alt('n')
go_to_tab |> "Go to the nth tab" |> Key::Alt('n'),
next_tab |> "Next tab." |> Key::Char('T')
}
}
shortcut_key_values! { "composing",
pub struct ComposingShortcuts {
send_mail: Key |> "Deliver draft to mailer" |> Key::Char('s'),
edit_mail: Key |> "Edit mail." |> Key::Char('e')
edit_mail |> "Edit mail." |> Key::Char('e'),
send_mail |> "Deliver draft to mailer" |> Key::Char('s')
}
}
shortcut_key_values! { "envelope-view",
pub struct EnvelopeViewShortcuts {
reverse_thread_order: Key |> "reverse thread order" |> Key::Ctrl('r'),
toggle_mailview: Key |> "toggle mail view visibility" |> Key::Char('p'),
toggle_threadview: Key |> "toggle thread view visibility" |> Key::Char('t'),
collapse_subtree: Key |> "collapse thread branches" |> Key::Char('h'),
exit_thread: Key |> "exit thread" |> Key::Char('i'),
prev_page: Key |> "Go to previous page." |> Key::PageUp,
next_page: Key |> "Go to next page." |> Key::PageDown
add_addresses_to_contacts |> "Select addresses from envelope to add to contacts." |> Key::Char('c'),
edit |> "Open envelope in composer." |> Key::Char('e'),
go_to_url |> "Go to url of given index" |> Key::Char('g'),
open_attachment |> "Opens selected attachment with xdg-open." |> Key::Char('a'),
open_mailcap |> "Opens selected attachment according to its mailcap entry." |> Key::Char('m'),
reply |> "Reply to envelope." |> Key::Char('R'),
return_to_normal_view |> "Return to envelope if viewing raw source or attachment." |> Key::Char('r'),
toggle_expand_headers |> "Expand extra headers (References and others)." |> Key::Char('h'),
toggle_url_mode |> "Toggles url open mode." |> Key::Char('u'),
view_raw_source |> "View raw envelope source in a pager." |> Key::Alt('r')
}
}
shortcut_key_values! { "thread-view",
pub struct ThreadViewShortcuts {
collapse_subtree |> "collapse thread branches" |> Key::Char('h'),
next_page |> "Go to next page." |> Key::PageDown,
prev_page |> "Go to previous page." |> Key::PageUp,
reverse_thread_order |> "reverse thread order" |> Key::Ctrl('r'),
toggle_mailview |> "toggle mail view visibility" |> Key::Char('p'),
toggle_threadview |> "toggle thread view visibility" |> Key::Char('t')
}
}

View File

@ -255,7 +255,6 @@ pub fn get_events_raw(
}
}
}
const FIELDS: &[&str] = &[];
impl<'de> Deserialize<'de> for Key {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>