Skip to content

Commit

Permalink
add auto-move config option allowing to disable trash target
Browse files Browse the repository at this point in the history
  • Loading branch information
d99kris committed Sep 1, 2024
1 parent a1dbffa commit 364cb14
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ This configuration file controls the UI aspects of nmail. Default configuration
file (platform-dependent defaults are left empty below):

attachment_indicator=📎
automove_trash_allow=1
bottom_reply=0
cancel_without_confirm=0
colors_enabled=1
Expand Down Expand Up @@ -821,6 +822,10 @@ file (platform-dependent defaults are left empty below):
Controls which character to indicate that an email has attachments
(default: `📎`). For a more plain layout one can use an ascii character: `+`.

### automove_trash_allow

Specifies whether trash folder may be selected as automove target folder.

### bottom_reply

Controls whether to reply at the bottom of emails (default disabled).
Expand Down
2 changes: 1 addition & 1 deletion src/nmail.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man.
.TH NMAIL "1" "August 2024" "nmail 5.1.15" "User Commands"
.TH NMAIL "1" "August 2024" "nmail 5.1.16" "User Commands"
.SH NAME
nmail \- ncurses mail
.SH SYNOPSIS
Expand Down
19 changes: 15 additions & 4 deletions src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ void Ui::Init()
{ "terminal_title", "" },
{ "top_bar_show_version", "0" },
{ "unwrap_quoted_lines", "1" },
{ "automove_trash_allow", "1" },
};
const std::string configPath(Util::GetApplicationDir() + std::string("ui.conf"));
m_Config = Config(configPath, defaultConfig);
Expand Down Expand Up @@ -360,6 +361,7 @@ void Ui::Init()
m_Signature = m_Config.Get("signature") == "1";
m_TopBarShowVersion = m_Config.Get("top_bar_show_version") == "1";
m_UnwrapQuotedLines = m_Config.Get("unwrap_quoted_lines") == "1";
m_AutomoveTrashAllow = m_Config.Get("automove_trash_allow") == "1";

try
{
Expand Down Expand Up @@ -7120,36 +7122,45 @@ void Ui::AutoMoveSelectFolder()
const std::string queryCommonAllowTrash = queryNotCurrent + queryNotSent;

std::vector<std::string> queryStrs;
std::vector<std::string> queryStrsAllowTrash;
if (!subject.empty())
{
// full subject
const std::string querySpecific = "subject:\"" + subject + "\"";
queryStrs.push_back(querySpecific + queryCommon);
queryStrs.push_back(querySpecific + queryCommonAllowTrash);
queryStrsAllowTrash.push_back(querySpecific + queryCommonAllowTrash);
}

if (!subjectPrefix.empty() && !sender.empty())
{
// subject prefix and sender name
const std::string querySpecific = "subject:\"" + subjectPrefix + "*\" AND from:\"" + sender + "\"";
queryStrs.push_back(querySpecific + queryCommon);
queryStrs.push_back(querySpecific + queryCommonAllowTrash);
queryStrsAllowTrash.push_back(querySpecific + queryCommonAllowTrash);
}

if (!subjectPrefix.empty())
{
// subject prefix
const std::string querySpecific = "subject:\"" + subjectPrefix + "*\"";
queryStrs.push_back(querySpecific + queryCommon);
queryStrs.push_back(querySpecific + queryCommonAllowTrash);
queryStrsAllowTrash.push_back(querySpecific + queryCommonAllowTrash);
}

if (m_AutomoveTrashAllow)
{
queryStrs.insert(queryStrs.end(), queryStrsAllowTrash.begin(), queryStrsAllowTrash.end());
}

if (!sender.empty())
{
// sender name
const std::string querySpecific = "from:\"" + sender + "\"";
queryStrs.push_back(querySpecific + queryCommon);
queryStrs.push_back(querySpecific + queryCommonAllowTrash);
if (m_AutomoveTrashAllow)
{
queryStrs.push_back(querySpecific + queryCommonAllowTrash);
}
}

if (!queryStrs.empty())
Expand Down
1 change: 1 addition & 0 deletions src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ class Ui
bool m_Signature = false;
bool m_TopBarShowVersion = false;
bool m_UnwrapQuotedLines = false;
bool m_AutomoveTrashAllow = false;

std::string m_TerminalTitle;

Expand Down
2 changes: 1 addition & 1 deletion src/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "version.h"

#define NMAIL_VERSION "5.1.15"
#define NMAIL_VERSION "5.1.16"

std::string Version::GetBuildOs()
{
Expand Down

0 comments on commit 364cb14

Please sign in to comment.