Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow selection of contenttype #1183

Closed
wants to merge 4 commits into from

Conversation

ninewise
Copy link

@ninewise ninewise commented Dec 16, 2017

Fixes #405.

  • Tests
  • Rename :nextctype to :nextpart and reflect this in the code
  • Add a "previous" to the "next"
  • Fix "prefer_plaintext"
  • Quote the selected part on reply/forward
  • Make it pretty
  • rebase and cleanup

Issues:

  • Alot crashes when I swap to a content tab with less content, because we try to select the same line in every content tab (the same line might not exist).
  • A message with multipart/mixed, but only a single part (the attachment), fails to open (example for self: thread:0000000000006739)
  • Body of neither text nor html is shown (example for self: thread:0000000000007fc1)

@ninewise ninewise force-pushed the feature/contenttype-selection branch 2 times, most recently from 3bd0793 to 1a13e74 Compare December 18, 2017 09:36
@ninewise ninewise force-pushed the feature/contenttype-selection branch from 1a13e74 to c7e7816 Compare January 2, 2018 13:37
@ninewise
Copy link
Author

ninewise commented Jan 2, 2018

I fixed the failing tests.

The 2 codeclimate issues are actually issues already there before I started modifying these functions, should I try to fix them? (What is cognitive complexity anyway?)

I'm not sure what's wrong with the first travis job, it doesn't show any errors but still fails.

@@ -236,15 +255,31 @@ def _get_source(self):
self._sourcetree = TextlinesList(sourcetxt, att, att_focus)
return self._sourcetree

def _get_content_parts(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic should not be part of the FocusableText widget tbh.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't? 😕 It's in MessageTree.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, my bad: Github folding tricked me into believing the change is in FocussableText. I take it back :)

Copy link
Collaborator

@lucc lucc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not read the main part of the code. Just some corner cases.

repeatable = True

def __init__(self, **kwargs):
Command.__init__(self, **kwargs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this constructor? Doesn't it inherit the parent constructor automatically?

alot/db/utils.py Outdated
for part
in typed_subpart_iterator(mail, *preferred.split('/'))]

# should we not, ask for all types
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear comment. Is this a question/todo or is it an explanation?

@lucc
Copy link
Collaborator

lucc commented Jan 3, 2018

I like this feature very much. I tried to implement a different way to navigate the mime tree some time back (#894) but never finished it as I was stuck with some urwidtree issues. So I hope we can merge this feature but here are some more points for consideration/discussion/todo:

  • Tests for new code would be nice. Alot aims to improve its testsuite so a new feature and new code is always a good chance to add some more tests.
  • I have prefer_plaintext = True in my config but it is not respected any more. I always get the first mime part initially, no matter its type (I admit it is not very often that you get a mail that has a html part before the plain text part, I only found one in my mail store after a short search)
  • We might want a :previousctype command for symmetry but that can also wait for a later PR (also do we want to jump to one ctype directly or allow count arguments for these commands?)
  • It could maybe be named :nextpart as there might be several parts that do not represent the same information in different types but actually different info. (eg. a mailing list digest from the notmuch mailing list)
  • I am unsure about the visual representation. For me the ctype indication merges with the body but it should feel more like a part of the header information. Or even something like a tabline below the headers. Also mails might have attachements and be signed or encrypted. So we should spend some thought on different cases and how to represent them.

BTW I tried the PR and it works :)

@ninewise
Copy link
Author

ninewise commented Jan 3, 2018

  • Tests should indeed be written. I'll postpone them because I'm lazy and we might still rename some functions though.
  • My PR actually brakes/changes the prefer_plaintext option. AFAIK, it now only influences which text is quoted when replying to an email. I'll select the preferred part by default (but not change the order of the parts) and ensure the quoted text is the currently visible one, not the preferred ctype.
  • A "previous" variant could be trivially added, so I'll add it to here. Only reason I didn't already is, I couldn't think of a good keybinding for it.
  • :nextpart sounds better. I'll rename this later unless someone disagrees.
  • Visual representation is hard. I tried something with trees first, but I got stuck with cycles in the MessageTree :-/. I'd appreciate some thoughts on this.

And yeah, it works ;-)

@lucc
Copy link
Collaborator

lucc commented Jan 3, 2018

Your suggestion in the second point sounds good: select preferred part when opening a mail and use current part when replying. (I have a test mail ready to try it ;)

The cycles in trees are exactly what stopped me in my tracks back in #894.

@pazz
Copy link
Owner

pazz commented Jan 4, 2018

what do you mean by cycles in the tree?

@ninewise
Copy link
Author

ninewise commented Jan 5, 2018

So I had to do something soft of ugly to quote the selected part, but I'm not sure it can be improved without overhauling a lot of command-related-code. Is it even possible to reply to some message that's not the ui.current_buffer.get_selected_message()?

@ninewise
Copy link
Author

ninewise commented Jan 5, 2018

About the cycles, it's probably because I did something wrong with the parent pointers, and at some point while holding the down arrow, all parents are suddenly erased and the parents are gone. Holding the up arrows goes through an infinite cycle of messages.

@lucc
Copy link
Collaborator

lucc commented Jan 6, 2018

preferring plaintext works again.

@lucc
Copy link
Collaborator

lucc commented Jan 6, 2018

maybe also something for the todo list: rebase and clean up history with nice logical steps in the commit log and descriptive messages.

@ninewise ninewise force-pushed the feature/contenttype-selection branch from 93a986c to 219ca8c Compare January 12, 2018 16:33
Repository owner deleted a comment Feb 15, 2018
Repository owner deleted a comment Feb 15, 2018
Repository owner deleted a comment Feb 15, 2018
Repository owner deleted a comment Feb 15, 2018
Repository owner deleted a comment Feb 15, 2018
Repository owner deleted a comment Feb 15, 2018
@ninewise ninewise force-pushed the feature/contenttype-selection branch from e1c6ec2 to f740ff7 Compare March 15, 2018 11:38
@ninewise ninewise force-pushed the feature/contenttype-selection branch 2 times, most recently from 9ea5ee3 to 4afb878 Compare April 3, 2018 13:41
@lucc lucc added the feature label Oct 12, 2018
@ninewise ninewise force-pushed the feature/contenttype-selection branch 2 times, most recently from 3ef23d7 to 44468a7 Compare December 16, 2018 12:01
@ninewise
Copy link
Author

Rebased this feature onto the new master.

@ninewise
Copy link
Author

I need some help to finish this:

  • Are there some examples of graphical tests anywhere? I can write a test for the quote function, but all other tests are graphical and I'm not seeing any in tests/widgets, yet.

  • Is there a way to set the position of the cursor? I'd use this to resolve the first issue in the top post here, but I'm not finding how in the urwidtrees documentation.

@ninewise ninewise force-pushed the feature/contenttype-selection branch from 44468a7 to 57b6966 Compare December 20, 2018 09:17
@ninewise ninewise force-pushed the feature/contenttype-selection branch from 57b6966 to b2d979e Compare December 20, 2018 10:47
@ninewise ninewise force-pushed the feature/contenttype-selection branch from b2d979e to 31f7ab9 Compare August 1, 2019 11:51
@ninewise ninewise force-pushed the feature/contenttype-selection branch from 31f7ab9 to 3657c04 Compare August 5, 2019 14:48
@ninewise
Copy link
Author

I believe this was superseded by #1480 so I'm closing this.

@ninewise ninewise closed this Jun 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toggle plaintext alternative vs. rendered html
3 participants