<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mutt-alias-auto-add, branch v0.0.2</title>
<subtitle>A display filter for Mutt to automatically add aliases for emails that you read</subtitle>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/'/>
<entry>
<title>Add CHANGELOG</title>
<updated>2016-04-27T21:35:04+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-27T21:35:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=3193e4dd20ea0c01f1ab8195548280914d84c4bd'/>
<id>3193e4dd20ea0c01f1ab8195548280914d84c4bd</id>
<content type='text'>
Include some information about our two releases.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Include some information about our two releases.
</pre>
</div>
</content>
</entry>
<entry>
<title>Increase version 0.0.1 -&gt; 0.0.2</title>
<updated>2016-04-27T21:30:11+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-27T21:30:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=493b35123968b892507aae19ef8fcf1913ffb144'/>
<id>493b35123968b892507aae19ef8fcf1913ffb144</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Makefile: Add task to compress/package a release build</title>
<updated>2016-04-27T21:28:54+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-27T21:28:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=e8f9b8b1a53a3fb7457933cbc1fbd0f9a37d0ae3'/>
<id>e8f9b8b1a53a3fb7457933cbc1fbd0f9a37d0ae3</id>
<content type='text'>
Provide a convenient way of creating a binary package that can be
uploaded to the GitHub releases page.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Provide a convenient way of creating a binary package that can be
uploaded to the GitHub releases page.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'use-writer-for-STDOUT-instead-of-println'</title>
<updated>2016-04-27T20:48:45+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-27T20:48:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=665df66a7cd103b97dcd6667b02a051a797719a3'/>
<id>665df66a7cd103b97dcd6667b02a051a797719a3</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>main: Ignore errors, don't write to STDERR</title>
<updated>2016-04-27T20:46:07+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-27T20:46:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=f45f00cbbe32d473deb4e23e8944a5a61e5f8e45'/>
<id>f45f00cbbe32d473deb4e23e8944a5a61e5f8e45</id>
<content type='text'>
Well, after all that error handling I'm going to have to remove error
output. The problem was that this STDERR output interfered with the
output of the email in Mutt. When viewing a message, the screen would
become mangled (for certain messages), and I'd have to refresh (Ctrl-L)
the view.

After initially thinking this was because I was using `println!` instead
of flushing a full buffer to STDOUT, I just now realised that my output
to STDERR could be causing the problem. Sure enough, removing the STDERR
output fixed the issue.

This is certainly not ideal, so in the long term we'll probably want to
add some kind of logging mechanism so that users actually have
visibility into errors. But for now and for my own personal purposes, I
think this works. And at least it gets me around the immediate annoying
screen mangling issue.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Well, after all that error handling I'm going to have to remove error
output. The problem was that this STDERR output interfered with the
output of the email in Mutt. When viewing a message, the screen would
become mangled (for certain messages), and I'd have to refresh (Ctrl-L)
the view.

After initially thinking this was because I was using `println!` instead
of flushing a full buffer to STDOUT, I just now realised that my output
to STDERR could be causing the problem. Sure enough, removing the STDERR
output fixed the issue.

This is certainly not ideal, so in the long term we'll probably want to
add some kind of logging mechanism so that users actually have
visibility into errors. But for now and for my own personal purposes, I
think this works. And at least it gets me around the immediate annoying
screen mangling issue.
</pre>
</div>
</content>
</entry>
<entry>
<title>Makefile: Add some new targets</title>
<updated>2016-04-27T20:06:56+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-27T20:06:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=e9447a3c6ce3f2c3b057ae71a1949d6663bc1fe7'/>
<id>e9447a3c6ce3f2c3b057ae71a1949d6663bc1fe7</id>
<content type='text'>
To save me some time from having to write commands. Started with a
`reinstall` target to make it easier to put a new build on my PATH.

Then added a `test-all` target so I wouldn't have to use two commands to
run both test suites. Needed to create a `test` task also in order to
run the unit tests before the integration test.

Ensure that we `cargo build` before running integration tests. Otherwise
we might be testing against an old build.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To save me some time from having to write commands. Started with a
`reinstall` target to make it easier to put a new build on my PATH.

Then added a `test-all` target so I wouldn't have to use two commands to
run both test suites. Needed to create a `test` task also in order to
run the unit tests before the integration test.

Ensure that we `cargo build` before running integration tests. Otherwise
we might be testing against an old build.
</pre>
</div>
</content>
</entry>
<entry>
<title>README: Add section on testing</title>
<updated>2016-04-27T10:39:40+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-27T10:39:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=55ddc252ff0fbbf4149afa6497b5fb407905ef52'/>
<id>55ddc252ff0fbbf4149afa6497b5fb407905ef52</id>
<content type='text'>
Describe the commands to use to run the test suite.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Describe the commands to use to run the test suite.
</pre>
</div>
</content>
</entry>
<entry>
<title>README: Update GitHub URL</title>
<updated>2016-04-27T10:36:50+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-27T10:36:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=297821efafa9c54da39ff54227011146e2929225'/>
<id>297821efafa9c54da39ff54227011146e2929225</id>
<content type='text'>
Now that we've actually created and published the GitHub repo, use the
new name. When I wrote the README I just guessed at a name and obviously
that wasn't final.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that we've actually created and published the GitHub repo, use the
new name. When I wrote the README I just guessed at a name and obviously
that wasn't final.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'stream-did-not-contain-valid-utf8-error'</title>
<updated>2016-04-27T10:10:15+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-27T10:10:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=07505d78a316cff202e0dea43a43a96b78fef037'/>
<id>07505d78a316cff202e0dea43a43a96b78fef037</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Read aliases file as bytes and convert to string</title>
<updated>2016-04-27T09:50:40+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-27T09:50:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=78e7b4c607d8fc3b35f90ed88614093bda437195'/>
<id>78e7b4c607d8fc3b35f90ed88614093bda437195</id>
<content type='text'>
Discovered that my Mutt aliases file uses the latin1 character encoding.
That caused a "stream did not contain valid UTF-8" error when trying to
read the file in the `Alias#find_in_file` function.

This error was ostensibly triggered by a `str::from_utf8` call in the
standard library
(https://github.com/rust-lang/rust/blob/2174bd97c1458d89a87eb2b614135d7ad68d6f18/src/libstd/io/mod.rs#L315-L338).

I ended up finding this Stack Overflow answer with an easy solution:
http://stackoverflow.com/questions/28169745/what-are-the-options-to-convert-iso-8859-1-latin-1-to-a-string-utf-8/28175593#28175593

      fn latin1_to_string(s: &amp;[u8]) -&gt; String {
          s.iter().map(|c| c as char).collect()
      }

Since latin1 is a subset of Unicode, we can just read the bytes from the
file and typecast them to Rust chars (which are UTF-8). That gives us
the opportunity to easily get the text into an encoding that we can
actually work with in Rust.

At first I got frustrated because the suggestion didn't compile for me.
It was suggested in January 2015, before Rust 1.0, so perhaps that
factors into the error I was getting. Here it is:

    src/alias.rs:59:41: 59:45 error: mismatched types:
     expected `&amp;[u8]`,
        found `core::result::Result&lt;collections::string::String, std::io::error::Error&gt;`
    (expected &amp;-ptr,
        found enum `core::result::Result`) [E0308]
    src/alias.rs:59             let line = latin1_to_string(line);
                                                            ^~~~
    src/alias.rs:59:41: 59:45 help: run `rustc --explain E0308` to see a detailed explanation
    src/alias.rs:99:22: 99:31 error: only `u8` can be cast as `char`, not `&amp;u8`
    src/alias.rs:99     s.iter().map(|c| c as char).collect()
                                         ^~~~~~~~~
    error: aborting due to 2 previous errors

A recommendation from 'niconii' Mozilla#rust-beginners was to use the
Encoding library in order to do the conversion
(https://github.com/lifthrasiir/rust-encoding). That certainly seems
more robust and would be a good idea to try if this change doesn't work
out in the long term. But the Stack Overflow answer just seemed so short
and sweet that I really didn't like the idea of adding a dependency if I
could get what I wanted with 3 lines of code.

Finally took another look and reworked the suggested code to take a
vector (which is what `BufReader#split` gives us) and clone the u8
characters to clear the compiler error of not being able to cast an &amp;u8.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Discovered that my Mutt aliases file uses the latin1 character encoding.
That caused a "stream did not contain valid UTF-8" error when trying to
read the file in the `Alias#find_in_file` function.

This error was ostensibly triggered by a `str::from_utf8` call in the
standard library
(https://github.com/rust-lang/rust/blob/2174bd97c1458d89a87eb2b614135d7ad68d6f18/src/libstd/io/mod.rs#L315-L338).

I ended up finding this Stack Overflow answer with an easy solution:
http://stackoverflow.com/questions/28169745/what-are-the-options-to-convert-iso-8859-1-latin-1-to-a-string-utf-8/28175593#28175593

      fn latin1_to_string(s: &amp;[u8]) -&gt; String {
          s.iter().map(|c| c as char).collect()
      }

Since latin1 is a subset of Unicode, we can just read the bytes from the
file and typecast them to Rust chars (which are UTF-8). That gives us
the opportunity to easily get the text into an encoding that we can
actually work with in Rust.

At first I got frustrated because the suggestion didn't compile for me.
It was suggested in January 2015, before Rust 1.0, so perhaps that
factors into the error I was getting. Here it is:

    src/alias.rs:59:41: 59:45 error: mismatched types:
     expected `&amp;[u8]`,
        found `core::result::Result&lt;collections::string::String, std::io::error::Error&gt;`
    (expected &amp;-ptr,
        found enum `core::result::Result`) [E0308]
    src/alias.rs:59             let line = latin1_to_string(line);
                                                            ^~~~
    src/alias.rs:59:41: 59:45 help: run `rustc --explain E0308` to see a detailed explanation
    src/alias.rs:99:22: 99:31 error: only `u8` can be cast as `char`, not `&amp;u8`
    src/alias.rs:99     s.iter().map(|c| c as char).collect()
                                         ^~~~~~~~~
    error: aborting due to 2 previous errors

A recommendation from 'niconii' Mozilla#rust-beginners was to use the
Encoding library in order to do the conversion
(https://github.com/lifthrasiir/rust-encoding). That certainly seems
more robust and would be a good idea to try if this change doesn't work
out in the long term. But the Stack Overflow answer just seemed so short
and sweet that I really didn't like the idea of adding a dependency if I
could get what I wanted with 3 lines of code.

Finally took another look and reworked the suggested code to take a
vector (which is what `BufReader#split` gives us) and clone the u8
characters to clear the compiler error of not being able to cast an &amp;u8.
</pre>
</div>
</content>
</entry>
</feed>
