Pietro Cerutti [Mon, 12 Nov 2018 09:38:50 +0000 (09:38 +0000)]
Avoid FREE'ing a non-malloc'd block
The mx.mbox member variable could remain uninitialized if imap_prepare_mailbox
failed, for example because a mailbox in the list doesn't have an account
associated with it.
Pietro Cerutti [Wed, 7 Nov 2018 12:59:21 +0000 (12:59 +0000)]
Implement mailcap option x-neomutt-keep
The option x-neomutt-keep instructs neomutt not to remove the attachment
after the view-command has quit. This is helpful with mime types handled
by commands such as firefox, which fork before opening the attachment in
the main instance. Example:
Richard Russon [Sat, 10 Nov 2018 13:26:27 +0000 (13:26 +0000)]
merge: imap: remove imap_conn_find
* remove imap_conn_find in cmd_handle_fatal
* remove imap_conn_find in imap_mbox_open_append
* remove imap_conn_find from imap_delete_mailbox
* remove imap_conn_find from imap_subscribe
* remove imap_conn_find from imap_browse
* remove imap_conn_find from imap_completes
* replace all imap_conn_find with MUTT_IMAP_CONN_NONEW
* remove unused imap_conn_find
* rename imap_conn_find2 to imap_login
Austin Ray [Thu, 8 Nov 2018 01:22:24 +0000 (20:22 -0500)]
notmuch: move version-specific loading to one spot
Moved loading of messages and threads to into their own method,
respectively. This helper method abstracts the loading for the caller.
All version-specific calls are in one spot for easier maintenance.
Austin Ray [Sun, 4 Nov 2018 02:18:33 +0000 (22:18 -0400)]
notmuch: remove nm_normalize_uri(...)
`nm_normalize_uri(...)` had one usage in `mutt_parse_unmailboxes(...)`.
Removing it had no affect on the `unmailboxes` command. I was able to
remove mailboxes without error.
Austin Ray [Sun, 4 Nov 2018 00:03:48 +0000 (20:03 -0400)]
notmuch: remove all unneeded #ifdef USE_NOTMUCH
Removed all unnecessary #ifdef USE_NOTMUCH. The remaining #ifdef
USE_NOTMUCH statements gate notmuch-specific calls that are not covered
by an interface.
The notmuch implementation of `mx_path_canon(...)` has been replaced with a
call to `nm_normalize_uri(...)` since that already canonizes notmuch
queries.
Austin Ray [Sun, 4 Nov 2018 01:11:50 +0000 (21:11 -0400)]
notmuch: single point for closing database
There are three points where a database is closed. Each point duplicates
the code for different versions of notmuch. Implemented a new method for
the version-specific notmuch code is handled. This method takes in a
database and closes it.
Austin Ray [Fri, 2 Nov 2018 23:02:11 +0000 (19:02 -0400)]
notmuch: replace hard-coded maildir flags
Replaced the hard-coded maildir flags unread, flagged, and replied with
variables NmUnreadTag, NmFlaggedTag, and NmRepliedTag.
Since unread and flagged may be different from the maildir flag, we do
not want to limit to using "unread", "flagged", or "unread" when
modifying tags. The user can specify which tags they use for the maildir
flags, and the subsystem will update maildir flags correctly.
Mehdi Abaakouk [Fri, 9 Nov 2018 14:26:50 +0000 (15:26 +0100)]
imap: when opening mailbox, reset Mailbox attrs
We currently only reset vcount and msg_count.
But imap_read_headers() call from imap_mbox_open() reload all
messages and then call mx_update_context(). So attributes that have not
been reseted will grow from previous values.
This does the reset of size, msg_unread, msg_flagged, msg_new.
Austin Ray [Tue, 6 Nov 2018 02:02:09 +0000 (21:02 -0500)]
browser: search on description if it exists
The browser searches on mailbox paths; however, with the introduction of
`named-mailboxes` and merging of `virtual-mailboxes`, it is necessary to
search of descriptions. If not, it may be impossible to find a mailbox
that is named.
For example, if we have `named-mailboxes "Test" "+work"` and searched
for "Test", it would not match because the path does not contain "Test".
Searching "work" would match the "Test" mailbox.
This commit modifies `select_file_search(...)` to use the description if
one exists. This way we can properly match searches for
`named-mailboxes` and `virtual-mailboxes` without know their underlying
mailbox paths.
Mehdi Abaakouk [Tue, 6 Nov 2018 21:48:59 +0000 (22:48 +0100)]
imap: add missing free_edata pointer
imap sometimes crashes when changing folder or quiting neomutt.
#1 0x000055555563833f in mutt_email_free (e=0x555555b0cb50) at email/email.c:55
#2 0x00005555555bb4e9 in mx_fastclose_mailbox (ctx=ctx@entry=0x555555980050) at mx.c:407
#3 0x00005555555bd593 in mx_mbox_close (pctx=0x5555558a69b0 <Context>, index_hint=index_hint@entry=0x7fffffffa074) at mx.c:727
...
This change adds the missing free_edata pointer to imap_free_edata.
Austin Ray [Fri, 2 Nov 2018 18:02:25 +0000 (14:02 -0400)]
format: use description by default
Changes the default of status_format and folder_format to display
descriptions instead of file path.
With the inclusion of named-mailboxes, we should try to use descriptions
since they fall back to file path. Otherwise, there would not be a
distinction between mailboxes and named-mailboxes with the defaults.
Austin Ray [Thu, 1 Nov 2018 22:30:33 +0000 (18:30 -0400)]
sidebar: unify virtual-mailboxes
Removed all notmuch specific code from `sidebar.c` This allows for
virtual-mailboxes to appear alongside every other mailbox, and reduces
coupling in sidebar.
In order to facilitate this, the command sidebar-virtual-toggle was
removed as it is no longer necessary. Some users may have utilized this
method so an alternative should be considered.
Austin Ray [Thu, 1 Nov 2018 21:13:13 +0000 (17:13 -0400)]
browser: unify mailboxes and virtual-mailboxes
Merged change-vfolder into change-folder so all mailboxes will be
displayed on the same screen. This removes the special cases needed to
display virtual-mailboxes.
To prevent breaking user's configurations, change-vfolder executes
change-folder. However, since vfolder_format and folder_format have
different default, user's will need to update the format.
Austin Ray [Wed, 31 Oct 2018 00:55:07 +0000 (20:55 -0400)]
notmuch: count flagged messages
`nm_nonctx_get_count(...)` did not count flagged messages. This means
they could not display flagged message counts in the sidebar _unless_ it
was the active mailbox.
This commit introduces NmFlaggedTag, mirrored from NmUnreadTag, and will
query the database for flagged messages.
Austin Ray [Tue, 30 Oct 2018 19:36:23 +0000 (15:36 -0400)]
notmuch: rework progress update math
After architectural changes, NeoMutt was not updating the progress when
opening `virtual-mailboxes`. The math was out of date.
This commit corrects the math involved and removes the unnecessary
counting logic. If counting is necessary, use `nm_nonctx_get_count(...)`
in a future commit.
Austin Ray [Tue, 30 Oct 2018 16:06:33 +0000 (12:06 -0400)]
notmuch: respect limits when counting messages
When NeoMutt counts the number of returned messages for a notmuch query,
it does not consider user specified limits. This affects both `limit=`
and `nm_db_limit` specifications.
This commit modifies `nm_nonctx_get_count(...)` to return the query's
limit if `get_count(...)` exceeds the limit. The check ensures that the
limit is non-zero so we don't return empty mailboxes.
Austin Ray [Mon, 29 Oct 2018 20:26:30 +0000 (16:26 -0400)]
notmuch: use existing open database if possible
When this portion of the code was migrated to use `NmAccountData`
instead of `NmMboxData` the check for an existing database handle was
removed. NeoMutt would lock-up trying to open another instance of the
database.
Austin Ray [Tue, 30 Oct 2018 00:39:20 +0000 (20:39 -0400)]
notmuch: duplicate `uri` during sync
The subsystem reused `ctx->mailbox->path` to store the absolute path for
an email so that it modify the maildir flags. In order to facilitate
this behavior, the subsystem copies the `uri` and uses it to replace the
absolute path after filename modification.
However, the `uri` variable is just a pointer to `ctx->mailbox->path` so
it is overwritten with the physical path.
This commit uses `mutt_str_strdup(...)` to duplicate the `uri` so it can
replace the physical path. Without this duplication, a
`virtual-mailboxes` will lose its notmuch query when modifying tags
corresponding to maildir flags. This results in a `virtual-mailboxes`
disappearing during runtime.