Commit graph

4732 commits

Author SHA1 Message Date
David Bremner
957fc2e1a7 uploaded to Debian unstable
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQGcBAABCAAGBQJTB/eeAAoJEPIClx2kp54s0wAL/15v1V/g62FQVQSyHwMb4gOM
 1qtLkiP61hTKfsCXNwCrEUQCM25Ursy9nHahLEehFr7sN7bk0ohay5+dllYLEXdC
 1ETnScmw1J+LLfafSaYeooNwJphNxqleZSpIr0jjuhut9xi3lsON+JocJaNxqTlI
 ZVozSAEX1TrFDBIZ0ES1yrbR1WQBtDK/CWsNk9ZdVdZtg4M4rAM5nONDe2i65+JZ
 gVZd/Q0iftX8bvXKXgmJ3lENgHGD6epa4YaCkFG7U3wexV6nzdR4Q4wTEI8wV/Pi
 kjQt9oI/IigIdbjhTODFu0NdYbKqswBXslRkzeyX4AFtQH50Gy1XkrgUR8Wu7RD+
 0TycYaEIAfKniLHbHs7fuCvXhklwxN/FhFL5I+RlxY/k105YdEmA+JjiMsDMmPx3
 3Q7urH1+W0vnEmJWSJ/4dLNlYdfyJesnUEghJsPqpbtapFX4o/ywOQxhyR7i09zO
 LRc6dAeuRDPsSP0FIX8DWVE+oph/Y2fc4fWONpXRAQ==
 =uMSW
 -----END PGP SIGNATURE-----

Merge tag 'debian/0.17-4'

uploaded to Debian unstable
2014-02-21 21:05:05 -04:00
David Bremner
c35dcb7704 changelog stanza for 0.17-4 2014-02-18 21:38:55 -04:00
David Bremner
10739d0762 debian: update ruby binary extension install path
From Christian Hofstaedler, Debian bug 739120:

When ruby-defaults > 1:2.0 will be uploaded to sid, the version of
Ruby provided by the 'ruby' and 'ruby-dev' packages will change to
version 2.0.  This version change includes a change to the path for
binary extensions.

This patch works for Ruby 1.9.1 as well as Ruby 2.0, so it's safe to
apply now.
2014-02-18 21:05:14 -04:00
Jed Brown
718d58ade0 emacs: update alist for mail-archive.com API change
Searching by Message-Id no longer works via the old mail-archive.com
API, though I have contacted them in hopes that they restore it to
prevent dead links.  Anyway, the new API is cleaner.

Acked-by: Austin Clements <amdragon@MIT.EDU>
2014-02-16 18:55:24 -04:00
W. Trevor King
320d4a856e nmbug-status: Hardcode UTF-8 instead of using the user's locale
David [1] and Tomi [2] both feel that the user's choice of LANG is not
explicit enough to have such a strong effect on nmbug-status.  For
example, cron jobs usually default to LANG=C, and that is going to
give you ASCII output:

  $ LANG=C python -c 'import locale; print(locale.getpreferredencoding())'
  ANSI_X3.4-1968

Trying to print Unicode author names (and other strings) in that
encoding would crash nmbug-status with a UnicodeEncodeError.  To avoid
that, this patch hardcodes UTF-8, which can handle generic Unicode,
and is the preferred encoding (regardless of LANG settings) for
everyone who has chimed in on the list so far.  I'd prefer trusting
LANG, but in the absence of any users that prefer non-UTF-8 encodings
I'm fine with this approach.

While we could achieve the same effect on the output content by
dropping the previous patch (nmbug-status: Encode output using the
user's locale), Tomi also wanted UTF-8 hardcoded as the config-file
encoding [2].  Keeping the output encoding patch and then adding this
to hardcode both the config-file and output encodings at once seems
the easiest route, now that fd29d3f (nmbug-status: Decode Popen output
using the user's locale, 2014-02-10) has landed in master.

[1]: id="877g8z4v4x.fsf@zancas.localnet"
     http://article.gmane.org/gmane.mail.notmuch.general/17202
[2]: id="m2vbwj79lu.fsf@guru.guru-group.fi"
     http://article.gmane.org/gmane.mail.notmuch.general/17209
2014-02-14 21:45:07 -04:00
W. Trevor King
ffed8f2866 nmbug-status: Encode output using the user's locale
Instead of always writing UTF-8, allow the user to configure the
output encoding using their locale.  This is useful for previewing
output in the terminal, for poor souls that don't use UTF-8 locales
;).
2014-02-14 21:44:11 -04:00
W. Trevor King
0d563dae1d nmbug-status: Add inter-message padding
We already had the tbody with a blank row separating threads (which is
not colored); this commit adds a bit of spacing to separate messages
within a thread.  It will also add a bit of colored padding above the
first message and below the final message, but the main goal is to add
padding *between* two-row message blocks.

                                               <--- new padding
  thread-1, message-1, row-1  (class="message-first")
  thread-1, message-1, row-2  (class="message-last")
                                               <--- new padding
    spacer tbody with a blank row
                                               <--- new padding
  thread-2, message-1, row-1  (class="message-first")
  thread-2, message-1, row-2  (class="message-last")
                                               <--- new padding
                                               <--- new padding
  thread-2, message-2, row-1  (class="message-first")
  thread-2, message-2, row-2  (class="message-last")
                                               <--- new padding
2014-02-14 21:42:36 -04:00
W. Trevor King
1aa56c2ac5 nmbug-status: Color threads in HTML output
Add tbody sections so we don't have to color every row.  Multiple
tbody sections are allowed [1].  Use CSS 3's nth-child to handle
even/odd coloring (skipping the spacer rows) [2], which is supported
on the major browsers [3].

border-spacing is from CCS 2.1 [4,5].  I'm using it to avoid
whitespace between td cells.

border-radius is from CCS 3 [6,7].  I'm using it to make the colored
sections a bit less harsh.  I tried adding rounded borders to the
tbody itself doesn't work, but I couldn't get that to work without
setting the tbody's display to 'block'.  That rounded the corners, but
collapsed the cell spacing (e.g. columns were no longer aligned).
This commit's by-corner-td approach is not particularly elegant, but
it works.  The td padding entries just ensure that the cell body is
suitably far from the edges that it doesn't fall outside of the
rounded corners.

The doubled-braces are escapes from Python's str.format.

[1]: http://www.w3.org/TR/html5/tabular-data.html#the-table-element
[2]: http://www.w3.org/TR/css3-selectors/#nth-child-pseudo
[3]: https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child#Browser_compatibility
[4]: http://www.w3.org/TR/CSS2/tables.html#propdef-border-spacing
[5]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-spacing#Browser_compatibility
[6]: http://www.w3.org/TR/css3-background/#the-border-radius
[7]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius#Browser_compatibility
2014-02-14 21:40:20 -04:00
Austin Clements
b1fa95721b new: Detect dirent.d_type support at configure time
Support for dirent.d_type is OS-specific.  Previously, we used
_DIRENT_HAVE_D_TYPE to detect support for this, but this is apparently
a glic-ism (FreeBSD, for example, supports d_type, but does not define
this).  Since there's no cross-platform way to detect support for
dirent.d_type, detect it using a test compile at configure time.
2014-02-14 08:42:45 -04:00
W. Trevor King
aaa7f0d92e nmbug-status: Escape &, <, and > in HTML display data
'message-id' and 'from' now have sensitive characters escaped using
xml.sax.saxutils.escape [1].  The 'subject' data was already being
converted to a link into Gmane; I've escape()d that too, so it doesn't
need to be handled ain the same block as 'message-id' and 'from'.

This prevents broken HTML by if subjects etc. contain characters that
would otherwise be interpreted as HTML markup.

[1]: http://docs.python.org/3/library/xml.sax.utils.html#xml.sax.saxutils.escape
2014-02-14 08:29:33 -04:00
W. Trevor King
aa32d2579b nmbug-status: Use <code> and <p> markup where appropriate
* Wrap free text in <p> tags.
* Convert <blockquote> to <p><code> for query strings.
* Wrap message-id-term (id:"...") in <code>.

The <code> tags get nicer default markup (smaller monospace font) for
notmuch query terms [1].  The <p> tags don't have much effect without
attached CSS, but bare text (phrasing content [2]) in <body> (which
expects flow content [3,4]) feels wrong.

[1]: http://www.w3.org/TR/html5/text-level-semantics.html#the-code-element
[2]: http://www.w3.org/TR/html5/dom.html#phrasing-content-1
[3]: http://www.w3.org/TR/html5/dom.html#flow-content-1
[4]: http://www.w3.org/TR/html5/sections.html#the-body-element
2014-02-13 21:47:37 -04:00
W. Trevor King
711d04c821 nmbug-status: Slug the title when using it as an id
Also allow manual id overrides from the JSON config.  Sluggin avoids
errors like:

   Bad value '#Possible bugs' for attribute href on element a:
   Whitespace in fragment component. Use %20 in place of spaces.

from http://validator.w3.org.

I tried just quoting the titles (e.g. 'Possible%20bugs'), but that
didn't work (at least with Firefox 24.2.0).  Slugging avoids any
ambiguity over when the quotes are expanded in the client.  The specs
are unclear about quoting, saying only [1]:

  Value: Any string, with the following restrictions:

    must be at least one character long
    must not contain any space characters

[1]: http://dev.w3.org/html5/markup/global-attributes.html#common.attrs.id
2014-02-13 21:45:40 -04:00
W. Trevor King
e485b5bd1d nmbug-status: Anchor with h3 ids instead of a names
HTML 5 allows id attributes on all HTML elements [1], but restricts
names to particular cases [2].  Attaching the id attribute to the h3
element allows us to drop the anchor a element altogether.

[1]: http://www.w3.org/TR/html5/dom.html#the-id-attribute
[2]: http://www.w3.org/TR/html5/index.html#attributes-1
2014-02-13 21:44:13 -04:00
Gaute Hope
91aede05a3 doc: notmuch_result_move_to_next -> notmuch_tags_move_to_next
Fix typo in docs.
2014-02-13 08:43:34 -04:00
W. Trevor King
9b98c5f8e9 nmbug-status: Convert from XHTML 1.0 to HTML 5
HTML 5 for the win :).  I also de-namespaced the language; the HTML 5
spec allows a vestigial xml:lang attribute, but it's a no-op [1], so I
stripped it.

This shouldn't break anything at tethera, which already serves the
status as text/html:

  $ wget -S http://nmbug.tethera.net/status/
  --2014-02-02 21:20:39--  http://nmbug.tethera.net/status/
  Resolving nmbug.tethera.net... 87.98.215.224
  Connecting to nmbug.tethera.net|87.98.215.224|:80... connected.
  HTTP request sent, awaiting response...
    HTTP/1.1 200 OK
    Vary: Accept-Encoding
    Content-Type: text/html
  ...

This also matches the Content-Type in the generated HTML's http-equiv
meta.

[1]: http://www.w3.org/TR/html5/dom.html#the-lang-and-xml:lang-attributes
2014-02-10 22:55:04 -04:00
W. Trevor King
a3a3725e43 nmbug-status: Normalize table HTML indentation
I don't think I've ever seen '</td><td>{value}\n' before :p.  The new
formatting avoids mixing tag levels and content across lines.
2014-02-10 22:53:28 -04:00
W. Trevor King
c48a12365f nmbug-status: Add an OrderedDict stub for Python 2.6
Tomi Ollila and David Bremner (and presumably others) are running
Python 2.6 on their nmbug-status boxes, so it makes sense to keep
support for that version.  This commit adds a really minimal
OrderedDict stub (e.g. it doesn't handle key removal), but it gets the
job done for Page._get_threads.  Once we reach a point where Python
2.6 is no longer important (it's already out of it's security-fix
window [1]), we can pull this stub back out.

[1]: http://www.python.org/download/releases/2.6.9/
2014-02-10 22:51:40 -04:00
W. Trevor King
98cb4779c0 nmbug-status: Add Page and HtmlPage for modular rendering
I was having trouble understanding the logic of the longish print_view
function, so I refactored the output generation into modular bits.
The basic text rendering is handled by Page, which has enough hooks
that HtmlPage can borrow the logic and slot-in HTML generators.

By modularizing the logic it should also be easier to build other
renderers if folks want to customize the layout for other projects.

Timezones
=========

This commit has not effect on the output, except that some dates have
been converted from the sender's timezone to UTC due to:

  -            val = m.get_header(header)
  -            ...
  -            if header == 'date':
  -                val = str.join(' ', val.split(None)[1:4])
  -                val = str(datetime.datetime.strptime(val, '%d %b %Y').date())
  ...
  +                value = str(datetime.datetime.utcfromtimestamp(
  +                    message.get_date()).date())

I also tweaked the HTML header date to be utcnow instead of the local
now() to make all times independent of the generator's local time.
This matches Gmane, which converts all Date headers to UTC (although
they use a 'GMT' suffix).  Notmuch uses
g_mime_utils_header_decode_date to calculate the UTC timestamps, but
uses a NULL tz_offset which drops the information we'd need to get
back to the sender's local time [1].  With the generator's local time
arbitrarily different from the sender's and viewer's local time,
sticking with UTC seems the best bet.

[1]: https://developer.gnome.org/gmime/stable/gmime-gmime-utils.html#g-mime-utils-header-decode-date
2014-02-10 22:51:03 -04:00
W. Trevor King
7b7a83cc32 nmbug-status: Add a Python-3-compatible urllib.parse.quote import
Python 2's urllib.quote [1] has moved to urllib.parse.quote in Python
3 [2].

[1]: http://docs.python.org/2/library/urllib.html#urllib.quote
[2]: http://docs.python.org/3/library/urllib.parse.html#urllib.parse.quote
2014-02-10 22:49:26 -04:00
W. Trevor King
a6ff03df3f nmbug-status: Consolidate HTML header printing
Make this all one big string, using '...{date}...'.format(date=...) to
inject the date [1].  This syntax was added in Python 2.6, and is
preferred to %-formatting in Python 3 [1].

[1]: http://docs.python.org/2/library/stdtypes.html#str.format
2014-02-10 22:47:52 -04:00
W. Trevor King
a7e4d9a18f nmbug-status: Don't require write access
The database in only used for notmuch.Query, so there's no need for
write access.  This allows nmbug-status to run while the database is
being updated, without raising:

  A Xapian exception occurred opening database: Unable to get write lock on …: already locked
  Traceback (most recent call last):
    File "./nmbug-status", line 182, in <module>
      db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)
    File "/…/notmuch/database.py", line 154, in __init__
      self.open(path, mode)
    File "/…/notmuch/database.py", line 214, in open
      raise NotmuchError(status)
  notmuch.errors.XapianError
2014-02-10 22:46:37 -04:00
W. Trevor King
e4d79bfddb nmbug-status: Consolidate functions and main code
The definitions of Thread, output_with_separator, and print_view were
between the main argparse and view-printing code.  Group them together
with our existing read_config at the top of the module, which makes
for easier reading in the main section.

I also:

* Made 'headers' a print_view argument instead of a module-level
  global.  The list -> tuple conversion avoids having a mutable
  default argument, which makes some people jumpy ;).

* Made 'db' a print_view argument instead of relying on the global
  namespace to access it from print_view.
2014-02-10 22:45:28 -04:00
W. Trevor King
a2b64211b2 nmbug-status: Add metavars for --config and --get-query
Now the suggested usage (listed by 'nmbug-status --help') is:

  usage: nmbug-status [-h] [--text] [--config PATH] [--list-views]
                      [--get-query VIEW]

instead of the less obvious:

  usage: nmbug-status [-h] [--text] [--config CONFIG] [--list-views]
                      [--get-query GET_QUERY]
2014-02-10 21:13:37 -04:00
W. Trevor King
b7e6d2cc30 nmbug-status: Factor config-loading out into read_config
By isolating this peripheral handling, we make the core logic of
nmbug-status easier to read.
2014-02-10 21:09:16 -04:00
W. Trevor King
fd29d3f4fb nmbug-status: Decode Popen output using the user's locale
Avoid:

  $ ./nmbug-status --list-views
  Traceback (most recent call last):
    File "./nmbug-status", line 47, in <module>
      'cat-file', 'blob', sha1+':status-config.json'],
  TypeError: can't concat bytes to str

by explicitly converting the byte-stream read from Popen into a
Unicode string.  On Python 2, this conversion is str -> unicode; on
Python 3 it is bytes -> str.

_ENCODING is derived from the user's locale (or system default) in an
attempt to match Git's output encoding.  It may be more robust to skip
the encoding/decoding by using a Python wrapper like pygit2 [1] for
Git access.  That's a fairly heavy dependency though, and using the
locale will probably work.

[1]: http://www.pygit2.org/
2014-02-10 21:04:55 -04:00
W. Trevor King
ee6b5c372f nmbug-status: Use email.utils instead of rfc822
rfc822 has been deprecated since Python 2.3, and it's gone in
Python 3 [1].

[1]: http://docs.python.org/2/library/rfc822.html
2014-02-10 21:03:12 -04:00
W. Trevor King
a8b81adc8e nmbug-status: Convert to Python-3-compatible print functions
We shouldn't require folks to install Python 2 to run nmbug-status.
2014-02-10 20:52:23 -04:00
Tomi Ollila
9c1bc977d7 emacs: initialize ido(-completing-read) in emacs 23.[123]
Otherwise `ido-completing-read' will freeze after PROMPT is displayed.
2014-02-03 16:20:39 -04:00
Jani Nikula
b220aefdf9 completion: bash completion for notmuch new --quiet option
notmuch new now has --quiet option, complete it too.
2014-02-03 16:19:49 -04:00
Jani Nikula
aff5af582e configure: only install bash completion if supported
Our bash completion depends on bash-completion 1.90 or later. Only
install where available.
2014-02-03 16:19:08 -04:00
Tomi Ollila
9ac863c549 emacs: ad-activate 'mm-shr after ad-disable-advice 'mm-shr
Imitated from "Enabling advice" in Emacs lisp manual...

ad-disable-advice by itself only changes the enable flag for a
piece of advice. To make the change take effect in the
advised definition, the advice needs to be activated again.
2014-01-30 12:21:25 -04:00
Jani Nikula
3e1d7f6476 test: add basic tests for notmuch new --quiet option
This does not cover all the possible paths notmuch new could output
stuff, but it's better than nothing.
2014-01-27 08:42:08 -04:00
David Bremner
1c2f2c960c emacs: add notmuch-assert-cli-sane to notmuch-hello
This is meant to be the friendly entrypoint, so let's do something
better than the mangled output described in

       id:5228989D.8030607@fifthhorseman.net
2014-01-26 15:10:30 -04:00
David Bremner
71d809ac9a emacs: add function notmuch-assert-cli-sane
If the CLI seems borked, signal an error, and log a suggestion for the
user about how to recover.
2014-01-26 15:10:30 -04:00
David Bremner
71d6a40581 emacs: add a function to heuristically test if the CLI is configured OK.
We cache the result so that we can call the function many places
without worrying about the cost.
2014-01-26 15:10:29 -04:00
Jani Nikula
aa57e9d2b8 man: document notmuch new --quiet option 2014-01-26 09:52:20 -04:00
Jani Nikula
e932fca54f cli: add --quiet option to notmuch new
Tie it to --verbose (resulting in verbosity levels of quiet, normal,
and verbose) but leave --debug orthogonal. Do some drive-by cleaning
while at it.
2014-01-26 09:49:00 -04:00
Jani Nikula
12621980ee cli: abstract notmuch new result printing
The notmuch_new_command() function has grown huge, chop it up a
bit. This should also be helpful when adding a --quiet option to
notmuch new. No functional changes.
2014-01-26 09:44:42 -04:00
Jani Nikula
f849b371cc cli: for loop is more customary
With the happy day stop condition within the while, it was
confusing. Switch to the paradigm for loop. No functional changes.
2014-01-26 09:41:29 -04:00
Jani Nikula
0b247cb411 cli: use dirent_type in count_files too
Avoid an extra stat per file, if possible, also when counting the
files for initial indexing.
2014-01-26 09:38:22 -04:00
Jani Nikula
65ebd34329 cli: only check the ignore list if needed
Premature optimization is the root of all evil, but this is simple
enough.
2014-01-26 09:37:01 -04:00
Jani Nikula
caf5514a36 cli: extract single message addition in notmuch new to clarify code
The add_files() function has grown huge, chop it up a bit. No
functional changes.
2014-01-26 09:36:51 -04:00
David Bremner
3b74537f49 lib: update documentation for notmuch_database_get_directory
Clarify that using the directory after destroying the corresponding
database is not permitted.

This is implicit in the description of notmuch_database_destroy, but
it doesn't hurt to be explicit, and we do express similar "ownership"
relationships at other places in the docs.
2014-01-26 09:36:38 -04:00
Tomi Ollila
b54e2f4fb1 build: delete the default .SUFFIXES
All implicit rules in notmuch Makefiles are "pattern rules"; Deleting the
default suffixes (to support obsolete, old-fashioned "suffix rules") from
make reduces the output of 'make -d' by 40 to 90 percent, helping e.g.
debugging make problems.
2014-01-25 13:09:45 -04:00
David Bremner
ecbb29e8ce notmuch-show: detect NULL pointer returned from notmuch_query_search_threads
We want to return an error status, not 0 or (worse) segfault.
2014-01-24 20:24:11 -04:00
David Bremner
29f1252126 lib: make notmuch_threads_valid return FALSE when passed NULL
Without this patch, the example code in the header docs crashes for certain
invalid queries (see id:871u00oimv.fsf@approx.mit.edu)
2014-01-24 20:20:54 -04:00
David Bremner
5c526d1737 test: add known broken test exit code of notmuch show
This test catches a segfault on a syntactically invalid query. It also
catches a problem with my initial fix, which still returned 0.
2014-01-24 20:19:50 -04:00
David Bremner
5dd59d2a5e man: update notmuch-dump man page for new default.
Actually the previous default was not documented explicitely.  I moved
the batch-tag section first because it seemed that the formats were
previously documented in order default, other.
2014-01-24 08:52:22 -04:00
David Bremner
f4167e6de8 notmuch dump: default to batch-tag format.
Although we didn't formally deprecate the old format, the new one has
been available for a year.
2014-01-24 08:52:09 -04:00
Jani Nikula
3b36898f0b cli: abstract common config get/set code
Pretty straightforward abstraction similar to get/set list.
2014-01-18 20:09:49 -04:00