pazz / alot

Terminal-based Mail User Agent
GNU General Public License v3.0
696 stars 164 forks source link

Date/timestamp missing from search mode #1527

Closed hgvhgv closed 4 years ago

hgvhgv commented 4 years ago

After updating from alot .8 to .9 today, the dates/timestamps are not showing up in search mode (see image). They show up in thread mode, so I believe my timestamp_format hook is still working. And when using the default alot theme, they do show up in search mode, so I believe the problem is with solarized_light, which I usually use.

In the debug log, it's clear that something is going wrong with reading the solarized_light theme, which is just the standard version that comes with alot . All 16 basic colors (in both 16 and 256) are "missing," even though they are defined in the file. This problem was already present in alot .8 (I noticed it when debugging other problems) but didn't cause the missing date/timestamp issue (for reference, my timestamp_format hook is below).

Could it have something to do with Configobject (see #1238; the "unknown values" in the config file maybe point to this?) or leftover python caches (homebrew sometimes has issues with these)? Or maybe how iTerm2 implements solarized? Any times would be appreciated. Not even sure how to start debugging further.

Software Versions

To Reproduce Steps to reproduce the behaviour:

  1. open alot
  2. see missing date/timestamp

Error Log Please include all error information from the log file.

INFO:utils:Unknown values were found in `/Users/hgv/.config/alot/config`. Please check for typos if a specified setting does not seem to work:
bindings: search
bindings: envelope
bindings: thread
DEBUG:manager:template directory: `/Users/hgv/.config/alot/templates`
DEBUG:manager:themes directory: `/Users/hgv/.config/alot/themes`
WARNING:manager:Theme `/Users/hgv/.config/alot/themes/solarized_light` does not exist.
INFO:utils:Unknown values were found in `/usr/local/share/alot/themes/solarized_light`. Please check for typos if a specified setting does not seem to work:
16_base03
16_base02
16_base01
16_base00
16_base0
16_base1
16_base2
16_base3
16_yellow
16_orange
16_red
16_magenta
16_violet
16_blue
16_cyan
16_green
256_base03
256_base02
256_base01
256_base00
256_base0
256_base1
256_base2
256_base3
256_yellow
256_orange
256_red
256_magenta
256_violet
256_blue
256_cyan
256_green

~/.config/alot/hooks.py

# Better date formatting
from datetime import timedelta
from datetime import datetime
from alot.helper import string_decode

def timestamp_format(d):
    hourfmt = '%Hh'
    hourminfmt = '%H:%M'
    now = datetime.now()
    today = now.date()
    if d.date() == today or d > now - timedelta(hours=6):
        delta = datetime.now() - d
        if delta.seconds < 60:
            string = 'just now'
        elif delta.seconds < 3600:
            string = '%dmin ago' % (delta.seconds / 60)
        elif delta.seconds < 6 * 3600:
            string = '%dh ago' % (delta.seconds / 3600)
        else:
            string = d.strftime(hourfmt)
    elif d.date() == today - timedelta(1):
        string = d.strftime('yest ' + hourfmt)
    elif d.date() > today - timedelta(7):
        string = d.strftime('%a ' + hourfmt)
    elif d.year != today.year:
        string = d.strftime('%Y %b %d')
    else:
        string = d.strftime('%b %d')
    return string_decode(string, 'UTF-8')
Screen Shot 2020-06-15 at 16 30 31--edited
hgvhgv commented 4 years ago

After poking around some more, I'm more stumped. I receive a similar "Unknown values" warning from solarized_dark, but there the date/timestamp shows up in search mode. Whereas using the tomorrow theme (the only other "light" theme shipped), I receive a similar warning about "Unknown values" and there is no date/timestamp in search mode.

I took the "Unknown values" warning out of this issue hed as a result. Not sure how to further debug.

With all of the debug logs, I am getting this line at the end of each new search mode query, e.g.

DEBUG:ui:Got key (['2'], [50])
DEBUG:ui:cmdline: 'search tag:flagged'
DEBUG:ui:search command string: "search tag:flagged"
DEBUG:__init__:mode:search got commandline "search tag:flagged"
DEBUG:__init__:ARGS: ['search', 'tag:flagged']
DEBUG:__init__:cmd parms {'sort': None, 'query': ['tag:flagged']}
DEBUG:utils:unquoted header: [snip]
. . .
DEBUG:utils:unquoted header: [snip]
DEBUG:walker:EMPTY PIPE
DEBUG:ui:Got key (['q'], [113])
DEBUG:ui:cmdline: 'exit'

Could that be related?

pazz commented 4 years ago

It seems that the solarized_light theme was not in order. I have not fully debugged the reason but the commit that I've just pushed to the master branch fixes this issue for me. The two lines are difectly taken from the solarized_dark theme.

hgvhgv commented 4 years ago

Great worked for me too!