From dd7bef18199b0a6e84da795aa5f1c9e7379bdce7 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 30 Jun 2020 17:45:02 -0400 Subject: [PATCH] Add a toggle to enable/disable the sidebar. --- keys | 3 +++ muttrc | 6 +++++- hooks => no-sidebar | 10 ++++++++++ sidebar | 15 +++++++++++++++ sidebar-common | 9 +++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) rename hooks => no-sidebar (61%) create mode 100644 sidebar create mode 100644 sidebar-common diff --git a/keys b/keys index 957d22d..c822ebc 100644 --- a/keys +++ b/keys @@ -9,6 +9,9 @@ bind index next-entry bind index "\Cp" previous-entry bind index "\Cn" next-entry bind index "\Cx\Cf" change-folder +bind index "\ep" sidebar-prev +bind index "\en" sidebar-next +bind index "\eo" sidebar-open bind pager "\Cp" previous-line bind pager "\Cn" next-line diff --git a/muttrc b/muttrc index df70015..c4a6985 100644 --- a/muttrc +++ b/muttrc @@ -9,6 +9,10 @@ source "~/.mutt/colors" source "~/.mutt/headers" source "~/.mutt/keys" source "~/.mutt/folders" -source "~/.mutt/hooks" source "~/.mutt/miscellaneous" source "~/.mutt/ssl" +source "~/.mutt/sidebar-common" + +# If you want the sidebar enabled by default, change this +# from no-sidebar to sidebar. +source "~/.mutt/no-sidebar" diff --git a/hooks b/no-sidebar similarity index 61% rename from hooks rename to no-sidebar index 83728ae..f3828b1 100644 --- a/hooks +++ b/no-sidebar @@ -1,3 +1,7 @@ +# Settings used only when the sidebar is NOT visible. +unset sidebar_visible +unset mail_check_stats + # The "33" is a magic number, totaling the number of characters in the # non-subject/author fields. # @@ -7,3 +11,9 @@ folder-hook .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-33) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-33) / 100))`; set index_format="%D | %Z %-$my_col_from.${my_col_from}t %-$my_col_subject.${my_col_subject}s (%-4.4c)"' folder-hook ! .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-33) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-33) / 100))`; set index_format="%D | %Z %-$my_col_from.${my_col_from}F %-$my_col_subject.${my_col_subject}s (%-4.4c)"' + +# This overrides the macro in "sidebar", so that Alt-s toggles the +# sidebar on and off by loading the (no-)sidebar config file in +# succession. The final "change-folder" command reloads the current +# folder, to ensure that the hook gets run to resize things. +macro index "\es" "source ~/.mutt/sidebar =" diff --git a/sidebar b/sidebar new file mode 100644 index 0000000..8cf5dec --- /dev/null +++ b/sidebar @@ -0,0 +1,15 @@ +# Settings used only when the sidebar is visible. +set sidebar_visible +set mail_check_stats + +# These hooks add 20 to the hooks in "no-sidebar" to account for the +# twenty columns that the sidebar takes up. +folder-hook .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-33) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-33) / 100))`; set index_format="%D | %Z %-$my_col_from.${my_col_from}t %-$my_col_subject.${my_col_subject}s (%-4.4c)"' + +folder-hook ! .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-33) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-33) / 100))`; set index_format="%D | %Z %-$my_col_from.${my_col_from}F %-$my_col_subject.${my_col_subject}s (%-4.4c)"' + +# This overrides the macro in "no-sidebar", so that Alt-s toggles the +# sidebar on and off by loading the (no-)sidebar config file in +# succession. The final "change-folder" command reloads the current +# folder, to ensure that the hook gets run to resize things. +macro index "\es" "source ~/.mutt/no-sidebar =" diff --git a/sidebar-common b/sidebar-common new file mode 100644 index 0000000..27962e8 --- /dev/null +++ b/sidebar-common @@ -0,0 +1,9 @@ +# Sidebar settings that can be set without regard to whether or +# not the sidebar is actually visible. +set sidebar_short_path +set sidebar_new_mail_only +set sidebar_format = "%B%* %N/%S" + +# This has to be large enough to accomodate the largest entry +# in your "mailboxes" list. +set sidebar_width = 20 -- 2.43.2