Anton Lindqvist [Wed, 20 Jul 2016 01:56:13 +0000 (18:56 -0700)]
Fix arithmetic exception due to menu->pagelen being negative.
Resizing the terminal window down to two lines when in an empty
mailbox causes mutt to crash due to division by zero since menu->max
equals 0 and menu->pagelen < 0 in status.c:205.
Fixing the problem at this specific line felt wrong since I did notice
menu->pagelen being negative. The pagelen is inherited from the rows
calculation in mutt_reflow_windows. Since the number of lines can
potentially be smaller than the accumulated number of rows acquired by
the status, help and message window, make sure the calculation does
not turn negative.
Kevin McCarthy [Mon, 18 Jul 2016 02:31:16 +0000 (19:31 -0700)]
Add imap-fast-trash patch.
This is based on the patch by Paul Miller.
Modifications are:
* Create a new flag, MUTT_TRASH for imap_make_msg_set(), rather than
use MUTT_EXPIRED.
* Change imap_make_msg_set(MUTT_TRASH) to only look at
hdrs[n]->deleted && !hdrs[n]->purge, behaving like MUTT_TAG, rather
than looking at the HEADER_DATA.
* Reimplement imap_fast_trash() based on imap_copy_message().
It looks the old version was too, but it lacked handling of TRYCREATE
and also queued the UID COPY but didn't exec it. (Presumably this
happened in the subsequent sync).
* Move the Context magic and mx_is_imap() checks outside of
imap_fast_trash()
Kevin McCarthy [Mon, 18 Jul 2016 02:31:09 +0000 (19:31 -0700)]
Add the trash folder patch.
This is based on the trash folder patch by Cedric Duval.
Modifications to the original patch are:
* Use a flag called M_PURGE instead of M_APPENDED. The same flag is
then used in the following "purge" patch instead of adding a
different flag.
* Removed the counter in context. The existing context->deleted
is all that's needed.
* Removed the "auto unset M_PURGE" when M_DELETED is unset inside
_mutt_set_flag(), although this is convenient, it easily leads to
header->purge not being reset in a few situations.
* Reset purge flag along with the deleted flag if $delete is answered
no.
* Set M_PURGE on an edited message. (edit_one_message())
* Preserve purge flag in mutt_reopen_mailbox()
* Turn off OPTCONFIRMAPPEND when saving to the trash, rather than
hardcoding it off in mutt_save_confirm(). That way, normal save to the
folder will respect the option.
Kevin McCarthy [Tue, 12 Jul 2016 01:36:21 +0000 (18:36 -0700)]
Initialize mutt windows even in batch mode. (closes #3853)
mutt_select_fcc() calls mutt_addr_hook() -> mutt_make_string() which
refers to MuttIndexWindow->cols when calling mutt_FormatString(). In
batch mode, MuttIndexWindow hasn't been initialized, leading to a
segfault.
This might be the only overlap, but it seems wiser to just initialize
the mutt windows in case there are other references (now or in the
future) when processing format strings in batch mode.
Kevin McCarthy [Sat, 9 Jul 2016 01:52:56 +0000 (18:52 -0700)]
Change sidebar highlighted mailbox behavior.
Delay selecting the highlighted mailbox until prepare_mailbox(), to
avoid a hidden mailbox being selected during the Buffy list population
(in mutt_sb_notify_mailbox()).
Change update_entries_visibility() to not automatically make the
highlighted mailbox visible.
Change prepare_sidebar() to (re)set the highlighted mailbox when the
current highlighted mailbox is hidden.
Kevin McCarthy [Sat, 9 Jul 2016 01:47:57 +0000 (18:47 -0700)]
Don't overwrite imap_status->uidnext with a lower value. (closes #3771)
imap_read_headers() updates the idata and imap_status uidnext after
reading through all the new headers.
The idata is updated properly (only if its uidnext is below maxuid+1),
but the imap_status was always being set to maxuid.
This causes a problem with new mail checking if the most recent
messages are deleted. Then the uidnext will be greater than maxuid+1
in the mailbox, and if there are any other unread messages it will
*always* report new mail even if $mail_check_recent is set.
Kevin McCarthy [Sat, 2 Jul 2016 19:24:25 +0000 (12:24 -0700)]
Fix sidebar "unsorted" order to match Buffy list order.
Since the previous commit decoupled the sidebar from the Buffy list,
we can now restore the order to match the buffy list when
sidebar_sort_method is set (back) to "unsorted".
Kevin McCarthy [Sat, 2 Jul 2016 19:22:51 +0000 (12:22 -0700)]
Decouple the sidebar from the Buffy list.
Change the sidebar to use an array of SBENTRY* instead. Move the
"is_hidden" into SBENTRY. Remove the added "prev" pointer from BUFFY.
This way, sorting the sidebar doesn't affect the BUFFY list order, and
we don't need elements inside BUFFY just for the sidebar presentation.
Fix sidebar-next for the case where the mailboxes are unsorted and
$sidebar_new_mail_only is set. Change sorting not to clump hidden
mailboxes at the bottom, instead simply skip over hidden mailboxes in
sidebar-next/prev.
Kevin McCarthy [Fri, 1 Jul 2016 20:33:20 +0000 (13:33 -0700)]
Check $pgp_autoinline and $pgp_replyinline if oppenc is set. (closes #3846)
The first oppenc call takes place after the initial checks of
$pgp_autoline and $pgp_replyinline, and doesn't go through the pgp
menu.
Therefore, check for $pgp_autoline and $pgp_replyinline if oppenc is
set too, to avoid oppenc enabling encryption without INLINE being set
in those cases.
a6a4d6ed0f19 previously cleaned things up so that it is safe
to set INLINE even if encryption isn't enabled.
USE_SIDEBAR needed to be set in doc/makedoc-defs.h so that the sidebar
option documentation is generated whether mutt is configured with the
sidebar or not.
Kevin McCarthy [Thu, 30 Jun 2016 01:58:53 +0000 (18:58 -0700)]
Fix cppflags and muttlibs duplication with --with-gss.
When krb5-config was found, MUTT_AM_PATH_GSSAPI included CFLAGS in
GSSAPI_CFLAGS and MUTTLIBS in GSSAPI_LIBS. However, configure.ac
afterwards sets:
CPPFLAGS="$CPPFLAGS $GSSAPI_CFLAGS"
MUTTLIBS="$MUTTLIBS $GSSAPI_LIBS"
This caused the flags and libs to be duplicated.
Kevin McCarthy [Thu, 30 Jun 2016 01:58:48 +0000 (18:58 -0700)]
Include ncurses tinfo library if found.
Thanks to Fabian Groffen for reporting this issue and providing a
couple possible patches. From Fabian's report:
For some time now, ncurses can be built in a mode where the low level
terminfo functionality lives in a separate lib called libtinfo.
Because some people do, this means Mutt needs to include this
library in that case to avoid linking errors [...]
Remove $sidebar_refresh_time from Sample Sidebar Config
The $sidebar_refresh_time option was removed with the changeset 1f840760e6e0. Remove it from the sample sidebar configuration as well,
so that anyone using that file in its entirety won't have to deal with "unknown
variable" errors.
Kevin McCarthy [Thu, 23 Jun 2016 19:38:07 +0000 (12:38 -0700)]
Change sidebar to consistently use realpath for context and buffy comparison.
The original sidebar patch contained a half-implemented attempt to use
realpath() mailbox paths for comparison. (Presumably so the open mailbox
remains highlighted despite symlink issues).
Add realpath to the Context, and set it when opening a mailbox.
Remove sidebar ifdef for the buffy member, and always set it there too.
Change the sidebar to use the realpath for comparison everywhere.
mutt_buffy_check() is using stat device and inode for comparison.
Perhaps this can be changed to use realpath instead, but that's beyond
the scope of this patch.
Damien Riegel [Sat, 18 Jun 2016 20:36:18 +0000 (13:36 -0700)]
prepend maildir_commit_message function name with an underscore
Basically, rename maildir_commit_message to _maildir_commit_message.
This commit is preparatory to make the maildir_commit_message symbol
available for further use.
Symbols starting with underscore should be avoided but this one is long
enough to prevent collision.
Damien Riegel [Sat, 18 Jun 2016 20:36:12 +0000 (13:36 -0700)]
remove unused HEADER parameter in mh_commit_message
mh_commit_message is only called in one place with the header parameter
set to NULL. To make the commit function consistent with other
mailboxes, which only takes ctx and msg as parameters, remove this
unused parameter.
Damien Riegel [Sat, 18 Jun 2016 19:41:43 +0000 (12:41 -0700)]
Remove magic member in MESSAGE structure
The "magic" was copied from the context to the message structure to be
able to determine which close function had to be called in
mx_close_message. Now that this function is context aware, there is no
need to store the magic in the MESSAGE structure and it can be safely
removed.
Damien Riegel [Sat, 18 Jun 2016 02:01:31 +0000 (19:01 -0700)]
Add open_msg to struct mx_ops
Add the callback to open an existing message to struct mx_ops. For mbox,
mmdf, maildir, and mh, the code was implemented directly into
mx_open_message, so it is moved in their respective source files. For
imap and pop, there were already <mailbox>_fetch_message functions, but
their argument order has been changed to pass the context as a first
argument.
Olaf Hering [Fri, 17 Jun 2016 17:33:56 +0000 (10:33 -0700)]
folder_file: remove struct stat
Add and use new flag to indicate the folder is on local filesystem.
Add and use new gid, uid and nlink member.
Use existing ->mode member instead of stat->st_mode.
Use existing ->size member instead of stat->st_size.
Use existing ->mtime member instead of stat->st_mtime.
Remove struct stat, the used values were already duplicated in the struct.
This reduces memory usage.
Kevin McCarthy [Fri, 17 Jun 2016 17:30:30 +0000 (10:30 -0700)]
Combine the basic and extended buffy functions.
Add a check_stats parameter to the mbox, maildir, and mh buffy
functions. Use that parameter to determine whether to also count
total, new, and flagged messages.
This makes the functions a bit more complicated, but improves
efficiency (for maildir and mh).
Also includes the following cleanup/fixes:
* Move the orig-value counter reset to the beginnining of the loop,
(before tmp->new is set to 0).
* Change trashed maildir messages to not be counted in msg_count
* Remove an incorrect setting of mailbox->new based on msg_count in
maildir. (I missed this one for 1f840760e6e0)
* Change mbox to use the context->mtime for stats_last_checked,
removing a race condition.
* Fix mh to actually count the messages in order to generate msg_count.
mh_sequences only covers the range of messages with some sort of
flag.
Kevin McCarthy [Tue, 14 Jun 2016 20:11:56 +0000 (13:11 -0700)]
Reset buffy->new for the current mailbox in IMAP.
1f840760e6e0 moved the buffy->new reset inside the STATUS processor.
Since the current mailbox is not STATUS'ed, it needs to be reset in
imap_buffy_check().
Thanks to Aaron Schrab for reporting this issue (and for helping test
tip).
Kevin McCarthy [Tue, 7 Jun 2016 22:02:58 +0000 (15:02 -0700)]
Make extended buffy independent of the sidebar.
Add new boolean option $mail_check_stats (default off) and
$mail_check_stats_interval. The first turns extended buffy on. The
second sets the amount of time in between extended buffy checks
(defaulting to 60 seconds).
Remove the option $sidebar_refresh_time.
Change mutt_buffy_check() to only notify the sidebar to redraw if a
mailbox buffy value changes.
Remove the #ifdefs around the extended buffy functions. The next
patch will merge these functions with the basic functions and pass a
parameter instead.
Imap is a special case, because it sends out the status in one batch.
Change this to perform the comparisons inside cmd_parse_status() and
flag the sidebar there. It was previously directly assigning the
status counters (unsigned int) to the buffy->new (short). Change this
to assign 1/0.
Kevin McCarthy [Wed, 8 Jun 2016 21:43:35 +0000 (14:43 -0700)]
Change the default for sidebar_format to use %n.
The next series of patches is going to create a new option,
$mail_check_stats defaulting off. When off, the extended buffy which
calculates total/new/flagged messages won't be run. To help reduce
"sidebar is broken" bug reports, this changes the default format to
something not requiring extended buffy.
The previous default is documented in the option and preserved in the
sample sidebar muttrc in contrib.
Richard Russon [Thu, 9 Jun 2016 19:06:10 +0000 (12:06 -0700)]
Fix alignment in the compose menu.
Several of the compose-panel labels didn't use the TITLE_FMT to align
themselves. This causes formatting problems when the width is changed,
e.g. by the NNTP patch.
Kevin McCarthy [Tue, 7 Jun 2016 20:27:45 +0000 (13:27 -0700)]
Fix columns used for $status_format and $pager_format in the pager.
The code was hardcoding use of MuttIndexWindow->cols in
mutt_make_string_info() and MuttStatusWindow->cols in
menu_status_line().
Add a parameter to mutt_make_info_string(). Change menu_status_line()
to use menu->statuswin->cols, falling back to MuttStatusWindow if no
menu is passed in.
Set menu->statuswin appropriately inside pager.c.
Thanks to Richard Russon for tracking down this problem, and for the initial patch.
Kevin McCarthy [Mon, 6 Jun 2016 01:05:41 +0000 (18:05 -0700)]
Fix sidebar buffy stats updating on mailbox close.
Move the mutt_sb_set_buffystats() call from mx_fastclose_mailbox() to
the bottom of mx_close_mailbox(). Append-only mailboxes don't have
msgcount set, so fastclose was the wrong place to be doing these
updates.
Kevin McCarthy [Sat, 4 Jun 2016 18:32:12 +0000 (11:32 -0700)]
Start to fix sidebar buffy modifications.
The extended buffy for mh had incorrect placement of the loop
brackets. The counters weren't being incremented in the loop.
Fix extended buffy for maildir to count a maildir message as new if it
doesn't have the info delimeter.
Remove shortcircuits added to the basic buffy stating there is new
mail when (msg_unread > 0). This is not necessarily true, depending
on $mail_check_recent.
Note: the extended buffy still needs more fixes, which will be done
when it is refactored into its own option.
Kevin McCarthy [Sat, 4 Jun 2016 18:32:09 +0000 (11:32 -0700)]
Various fixes to the sidebar logic.
Use strfcpy instead of strncpy. The current logic could write past
the end of the buffer.
Don't mess with BUFFY next pointers during removal. The
mutt_parse_mailboxes() is fine, but this is still not something that
should be done inside sidebar.c.
On removal, set next->prev since we can.
Fix unmailboxes logic:
* only fix the prev pointers once.
* if we unmailbox the open mailbox, set it to NULL.
Kevin McCarthy [Sat, 4 Jun 2016 18:32:07 +0000 (11:32 -0700)]
Clean up the sidebar manual.
Remove the introduction section. It's a nice effort, but reads more
like a tutorial than something that belongs in section 2. Will
probably put in on the website instead.
Remove references to a "patch", neomutt, and the history.
Damien Riegel [Thu, 26 May 2016 21:05:42 +0000 (14:05 -0700)]
add check operation to struct mx_ops
In mx_check_mailbox switch case, we simply call
<mailbox>_check_mailbox, so this operation can be move into the mx_ops
structure pretty easily.
This commit adds a mandatory "check" operation to struct mx_ops and
change all mailboxes to use it. Check functions are made static as they
are only used in their respective source files now.
Damien Riegel [Thu, 26 May 2016 21:05:39 +0000 (14:05 -0700)]
mx_check_mailbox: remove lock argument in function call
This function is only called in one place with lock = 0. Basically, all
code under if (lock) is dead code, so we can remove it, making the
function simpler to factorize.
Damien Riegel [Thu, 26 May 2016 21:05:36 +0000 (14:05 -0700)]
add function imap_check_mailbox_reopen
In mx_check_mailbox, imap mailbox is the only function with a different
prototype: it has an extra force argument.
In order to move the check operation to the mx_ops structure, we need
that all mailboxes have the same prototype. To do so, a new function
imap_check_mailbox_reopen is added.
Damien Riegel [Wed, 25 May 2016 22:53:07 +0000 (15:53 -0700)]
add open_new_msg operation to struct mx_ops
The code was already using a function pointer to do this operation. This
commit moves this function pointer to the mx_ops structure and the
open_new_message functions to their respective source files if it needs
to.
Kevin McCarthy [Tue, 24 May 2016 19:08:46 +0000 (12:08 -0700)]
Fix infinite loop when help is bound to a named key combination.
Commit a07e8215a0ef introduced a bug in km_error_key, which is called
when an unbound key is pressed.
If help is bound to a sequence containing named keys (e.g. <esc>), the
raw (untokenized) string would be pushed back into the unget buffer.
This could lead to an infinite loop of unbound key presses triggering
more unbound keys being put into the unget buffer.
Change km_error_key to tokenize the string before putting it in the unget buffer.
Much thanks to Jiri Bohac for his bug report, analysis, and initial patch!
Damien Riegel [Thu, 12 May 2016 19:41:25 +0000 (12:41 -0700)]
Start decoupling mailbox operations.
Introduce a dedicated structure for mailbox operations: struct mx_ops.
Move the open and close operations into that structure.
Assign this structure to the context in mx_open_mailbox. This is
currently based on the "magic" for the mailbox type, but may be
refactored in the future.
Add a stub mbox_close_mailbox function. This function does nothing,
the main purpose is to introduce a mx_ops structure for mbox, so its
usage is similar to mh/imap/pop. We reuse the name that was made
available by the previous commmit. Note that the actual closing of
the descriptor is done in mx.c.
To be more consistent with other mailboxes, introduce functions
mh_open_mailbox and maildir_open_mailbox, and create a dedicated
structure for mmdf.
Kevin McCarthy [Tue, 10 May 2016 16:42:27 +0000 (09:42 -0700)]
Set COLUMNS to MuttIndexWindow->cols in mutt_create_filter_fd. (closes #3837)
This allows filters to automatically (or via a command line argument)
adjust to the width of the pager/index. This is even more important
with the sidebar, since the width of the pager is smaller than the
terminal width.
Thanks to Vincent Lefèvre for his helpful information and suggestions,
and to Richard Russon for the initial patches.
Derek Martin [Mon, 9 May 2016 21:06:54 +0000 (14:06 -0700)]
Change M_* symbols to MUTT_*
Changeset 23334e967dd7 created a workaround for a namespace conflict
with Solaris and derivatives. After some discussion, the team decided
it would be best to move away from using the "M_" prefix for macros.
This patch was automatically generated by running:
perl -wpi -e 's/\bM_(\w+)\b/MUTT_$1/g' `find . -name '*.[ch]' -print`
with the exception that sys_socket.h was exempted. (That file will
be backed out subsequent to this commit.)
Thanks to Andras Salamon for supplying the perl script used to make
this change.
Kevin McCarthy [Sat, 30 Apr 2016 20:05:43 +0000 (13:05 -0700)]
Fix pager mini-index drawing when $pager_index_lines = 1 and $status_on_top.
When $pager_index_lines is 1, there is room for the index status line,
but not for any actual index entries. The index redraw part was
always calling menu_redraw_current() which doesn't actually check if
there is room for the current row.
This bug only shows up with $status_on_top, due to the order things
are redrawn.
Kevin McCarthy [Sat, 30 Apr 2016 17:50:43 +0000 (10:50 -0700)]
Fix pager layout when $status_on_top with no mini-index. (closes #3836)
The pager_window->row_offset should only be adjusted when we have a
mini-index.
Pull common window initialization above, and adjust only when the
mini-index is enabled. The pager_window rows and row_offset code
could be further consolidated (since the status line is always a
height of one), but I think the code reads a bit more clearly when the
adjustments are explicitly stated.
Kevin McCarthy [Thu, 28 Apr 2016 00:56:59 +0000 (17:56 -0700)]
Add cols parameter to mutt_FormatString()
Continuing with the conversion to using windows for screen drawing,
mutt_FormatString() was directly using COLS for right justification
and similar formatting. Instead pass in a parameter, cols.
This change involved seeding the parameter through callback functions
too, as many of them call mutt_FormatString() back.