Commit Graph

316 Commits

Author SHA1 Message Date
Aleks Kissinger
194fb49523
Merge pull request #76 from The-Compiler/fix-reply-quoted-comma
Fix reply with quoted comma
2024-09-17 18:25:34 +01:00
Aleks Kissinger
c23cd27338
Merge pull request #82 from The-Compiler/fix-empty-search-crash
Fix crash on empty search query
2024-09-17 18:23:50 +01:00
Aleks Kissinger
b1d1e43fcf
Merge pull request #72 from The-Compiler/color-overrides
Implement per-tag color overrides
2024-09-17 18:21:24 +01:00
Aleks Kissinger
b5aaafd990
Merge pull request #74 from The-Compiler/multi-file-select
Allow selecting multiple files to attach
2024-09-17 18:19:55 +01:00
Florian Bruhin
780dfffd1c util: Use email.utils.parseaddr for strip_email
this handles quoted values correctly and we avoid reinventing the wheel.
2024-09-17 17:06:33 +02:00
Florian Bruhin
dc88758e9a util: Simplify email_is_me 2024-09-17 17:05:32 +02:00
Florian Bruhin
f8b0b06519 util: Improve types for email_smtp_account_index 2024-09-17 17:05:32 +02:00
Florian Bruhin
7531707034 compose: Store addresses in parsed format
co- Properly split addresses into name and email
- Deal with them as (name, email) tuples
  internally, as a (quoted) name can contain a comma
- Format them properly again when inserting into the message

Fixes #75
2024-09-17 17:05:32 +02:00
Aleks Kissinger
3c8b53cf73
Merge pull request #71 from The-Compiler/raw-strings
Use raw strings for all regex patterns
2024-09-17 15:53:01 +01:00
Aleks Kissinger
fcfb99727e
Merge pull request #65 from The-Compiler/check-gpg
Improve message if python-gnupg wasn't found
2024-09-17 15:52:24 +01:00
Aleks Kissinger
727333e5c3
Merge pull request #64 from The-Compiler/improve-send-exception
Improve output on send exception
2024-09-17 15:51:53 +01:00
Aleks Kissinger
1311cbb1ba
Merge pull request #63 from The-Compiler/w3m-improvement
Improve call to w3m
2024-09-17 15:51:27 +01:00
Aleks Kissinger
fd79d77349
Merge pull request #62 from laarmen/thread_refocus
thread: restore collapsed state before reselecting the message
2024-09-17 15:48:07 +01:00
Aleks Kissinger
f4d39f0f71
Merge pull request #61 from laarmen/sync_at_beginning
app: initiate a background sync at startup
2024-09-17 15:47:30 +01:00
Aleks Kissinger
fa201b172b
Merge pull request #60 from laarmen/attachment_encoding
attachments: fix handling of text attachments
2024-09-17 15:47:00 +01:00
Florian Bruhin
979e416da8 Fix crash on empty search query
With a trivial "/, Enter", Dodo crashes with:

    Error: notmuch search requires at least one search term.

    Traceback (most recent call last):
      [...]
      File ".../dodo/search.py", line 54, in refresh
        self.d = json.loads(self.json_str)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
      [...]
      File "/usr/lib/python3.12/json/decoder.py", line 355, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Given that only an empty search should be able to trigger such an error,
it seems sensible for an enter press without input to just close the command bar
again.
2024-09-17 15:21:36 +02:00
Florian Bruhin
19cf6e26b7 Allow selecting multiple files to attach 2024-09-16 09:04:17 +02:00
Florian Bruhin
7afd7b1010 Implement per-tag color overrides 2024-09-12 11:30:22 +02:00
Florian Bruhin
a189f59cf7 Use raw strings for all regex patterns
See https://docs.python.org/3/library/re.html#raw-string-notation

Even if those patterns do not contain any backslashes, it is a good practice to
use raw strings for all regex patterns, to avoid footguns when changing the
patterns in the future.

Also see 93244ad996 where this did already cause a
SyntaxWarning before.
2024-09-12 11:16:57 +02:00
Florian Bruhin
0188150af5 Improve message if python-gnupg wasn't found
- Before: "exception name 'Gpg' is not defined"
- After: "exception python-gnupg is needed to sign/encrypt"
2024-09-12 10:37:39 +02:00
Florian Bruhin
cfcfe7ca29 Improve output on send exception
- Fix the stray "f" inside the string breaking the color
- Don't hide the traceback from the user, as it's impossibe to track down issues
  without it ("exception: None"?!)
- HTML escape the exception message - while somewhat unlikely, it could contain
  HTML characters.
2024-09-12 10:31:58 +02:00
Florian Bruhin
3372160149 Improve call to w3m
- Use stdin instead of a temporary file (needs -T argument to w3m to avoid it
  interpreting stdin as plaintext)
- Pass check=True to subprocess.run to raise an exception if w3m fails
- Catch that exception (as well as OSError, e.g. w3m not installed or not
  executable) and show an error instead of crashing dodo
2024-09-12 10:19:16 +02:00
Simon Chopin
05bf42f789 thread: restore collapsed state before reselecting the message
Collapsing causes the scroll position to be reset, which the reselecting
will restore. As a bonus, it seems the framework is smart enough to not
move the scroll position *at all* since both operations are presumably
done within one rendering pass.

It will still snap back to the selected message if the user happened to
have scrolled to a position where it wasn't visible before the sync, but
I still consider this a more sensible behaviour than moving back to the
top.
2024-08-19 11:14:55 +02:00
Simon Chopin
d53a0239a4 app: initiate a background sync at startup
If I configure my MUA to do regular syncs, I'd expect that first sync to
happen at startup *and then* each $time_period. It's especially painful
when the first sync of the day is a bit long, as both delays compound
while you stare blankly at your stale inbox, waiting for your morning
coffee to kick in.
2024-08-19 10:42:40 +02:00
Simon Chopin
3836053bb5 attachments: fix handling of text attachments
The default get_content() implementation (and the only available!) will
decode any 'text/*' attachment into a `str`, which means we need to
handle it a bit differently. Since we're at it, we use the charset
specified so that we write out a file as similar as possible to the one
that was actually sent.

Also, use early return pattern to filter out non-attachments.
2024-07-12 14:57:51 +02:00
Aleks Kissinger
503763c4d7
Merge pull request #58 from laarmen/html_encoding
Encoding fixes
2024-07-04 16:37:06 +01:00
Aleks Kissinger
5eb2e71a18
Merge branch 'master' into html_encoding 2024-07-04 16:36:55 +01:00
Aleks Kissinger
0c3cc43010
Merge pull request #59 from laarmen/treeview
Display threads in a tree view (BREAKING)
2024-07-04 16:35:34 +01:00
Aleks Kissinger
5e12272ff1
Merge pull request #57 from laarmen/thread-refactor
Thread view refactor (BREAKING!!)
2024-07-04 16:35:14 +01:00
Aleks Kissinger
946f6f615c
Merge pull request #56 from laarmen/mega-threads
Better handling of mega threads
2024-07-04 16:33:47 +01:00
Simon Chopin
4fd575a5e0 thread: collapse irrelevant subthreads by default 2024-07-04 16:13:25 +02:00
Simon Chopin
71541f9ea6 thread: keep the collapsed state during view refresh
This makes the tree view more manageable.
2024-07-04 16:13:25 +02:00
Simon Chopin
9b3e2d7c4f thread: add a default "conversation" mode matching the previous behaviour
This should make the transition smoother.
2024-07-04 16:13:25 +02:00
Simon Chopin
ac14df7bec thread: add a splitter between thread and header panels 2024-07-04 16:13:25 +02:00
Simon Chopin
9147fbc4fc thread: flatten the tree if it doesn't branch
If the thread never branches out, simply flatten the tree to avoid the
extra indentation levels.
2024-07-04 16:13:25 +02:00
Simon Chopin
e431c343ee thread: don't show the email address but highlight subject changes
IMHO, having the full name of the sender is more important than the
email in the message list. However, we can use the new free screen
realestate to display the new subject line if it has changed
2024-07-04 16:13:25 +02:00
Simon Chopin
05b8b84b74 Use a tree view for the thread listing
Besides the obvious tree-like thing, this has for consequences that the
ordering of messages is slightly different, as they are now
topologically sorted rather than through purely chronological order.
2024-07-04 16:13:25 +02:00
Simon Chopin
fcc773177f thread: specify that the body is always encoded in utf-8
Unless told otherwise, the web engine will default to latin1 for the
contents. Some emails don't specify the encoding in the HTML payload, so
our mangling at that level didn't have any effect.
2024-06-25 16:33:33 +02:00
Simon Chopin
5f4d5cb693 thread: use a ByteParser to read the email
Using message_from_file will try to force the email into UTF-8, which
can result in exceptions thrown for a perfectly valid email that just
happens to use older encodings.
2024-06-25 16:13:27 +02:00
Simon Chopin
cd3fd02ded thread: call super().refresh() before doing our own
It avoids parallel refreshes, which can happen if the refresh triggers a
secondary data update, e.g. via automatic mark as read on thread
opening.

It means we trigger our own has_refreshed signal, but that's OK, the
effects should only be a top-level view refresh.
2024-06-24 11:43:21 +02:00
Simon Chopin
b75da6aa54 thread: move completely away from int indices
This is a good old breaking change. Now, `current_message` will actually
yield the current message object rather than its index, while said index
is available at `current_index`. All the model APIs are changed to
consume and emit QModelIndex, and said indices are attached the message
they represent at creation, making it easier.

The goal long-term is to be able to move away from the ListView to use a
TreeView instead.
2024-06-24 11:42:52 +02:00
Simon Chopin
1e661e718d thread: do away with show_message
show_message has a weird API that deals in integer indices, and is also
used to refresh the UI. The indices are annoying because they're an
implementation detail, and the refresh part is a bit surprising when you
come across it in the code.

Removing it leaves only `current_message` as the remaining "integer" API
from ThreadPanel.
2024-06-24 11:42:48 +02:00
Simon Chopin
4dc8562779 thread: move the next unread logic to the model 2024-06-24 11:36:44 +02:00
Simon Chopin
52c38ab0aa thread: move tag handing within the model
It makes sense to have the model deal with the external notmuch calls,
while the Panel just connects the dots.
2024-06-24 11:36:44 +02:00
Simon Chopin
09bdd4e770 thread: move the UI update as a reaction to data update
Rather than explicitly refreshing the data *then* the UI, let's just use
the default model signals to trigger the UI refreshes

This actually saves us a full refresh when first opening a thread.
2024-06-24 11:36:44 +02:00
Simon Chopin
7174f2bb04 panel: add a signal post-refresh, used to update the tab title
This will pay off later on when reducing the number of refreshes, and to
develop more dynamic features, e.g. refining a thread query in-place
2024-06-24 11:32:02 +02:00
Simon Chopin
9f836ec01a thread: gray out the irrelevant messages
Irrelevant in the sense that they didn't match the origin search query.
Not all themes have been tested, the values were determined by looking
for the recommended value for code comments on the various colorscheme
homepages.
2024-06-20 18:54:15 +02:00
Simon Chopin
9204231ec0 thread: new keybinding to jump to next relevant unread
Mightily useful when reading huge ML threads.
2024-06-20 18:54:15 +02:00
Simon Chopin
e9b18ae7bf thread: jump to the first message matching the search query
Any thread opening is normally done from a search query. That search
query might have nothing to do with the unread status, and could only
match a handful of messages in the thread. So, rather than jumping to
the first unread message, we keep the search query as context when
opening the thread and use it to jump to the first message matching it.
2024-06-20 18:54:09 +02:00
Simon Chopin
4aa276050e Add refresh at the message granularity
When tagging a single message in a thread, only refresh that message
rather than the entire thread.

This is again due to some threads being *very* big, which when combined
with crypto signatures make the UI feel sluggish when changing the state
of a message, e.g. when reading it for the first time.

The computing time now doesn't scale with the size of the thread. It's
at similar levels from before on small threads, and is an order of
magnitude better on the recent tmpfs thread on debian-devel.

Note that right now we go through the entire list to get the index of a
given message. This could easily be optimized later on.
2024-06-20 18:52:08 +02:00