<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mutt-alias-auto-add, branch v0.0.1</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>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>
<entry>
<title>README: Fix Mutt `display_filter` setting</title>
<updated>2016-04-25T18:45:51+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-25T18:45:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=2b99fd30c28fecc95d9425f229eab426080dbc85'/>
<id>2b99fd30c28fecc95d9425f229eab426080dbc85</id>
<content type='text'>
* Should use `/usr/local/bin` not /usr/local`
* Should be enclosed in quotes, otherwise Mutt complains
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Should use `/usr/local/bin` not /usr/local`
* Should be enclosed in quotes, otherwise Mutt complains
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'add-readme'</title>
<updated>2016-04-25T08:14:33+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-25T08:14:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=373a303b9cf953149c53046d003ed7ed42ffe7ba'/>
<id>373a303b9cf953149c53046d003ed7ed42ffe7ba</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add README</title>
<updated>2016-04-25T08:13:34+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-25T08:13:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=7c4d7bd8bf3c35272fcdcf10285d8c2560d2a329'/>
<id>7c4d7bd8bf3c35272fcdcf10285d8c2560d2a329</id>
<content type='text'>
Initial draft of the README. Include a description of the program,
installation and uninstallation directions, and license information.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Initial draft of the README. Include a description of the program,
installation and uninstallation directions, and license information.
</pre>
</div>
</content>
</entry>
<entry>
<title>Set `install.root` configuration</title>
<updated>2016-04-25T07:49:57+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-25T07:49:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=478e6f1e3771166702712b372fc996be4639ab23'/>
<id>478e6f1e3771166702712b372fc996be4639ab23</id>
<content type='text'>
Set the default installation path to `/usr/local/bin`. This allows us to
install the program to that path using `cargo install`. The default can
be overridden using `cargo install --root /some/path`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Set the default installation path to `/usr/local/bin`. This allows us to
install the program to that path using `cargo install`. The default can
be overridden using `cargo install --root /some/path`.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'append-alias-even-if-it-doesn,t-already-exist'</title>
<updated>2016-04-24T13:41:02+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-24T13:41:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=5e18a1e5a34cac5876d43796c36e6c1369658c6e'/>
<id>5e18a1e5a34cac5876d43796c36e6c1369658c6e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>test: Fix `write_to_file` race condition</title>
<updated>2016-04-24T13:39:14+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-24T13:39:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=79e78aaa7c0c77064264ffdad0c3172aa0f5c376'/>
<id>79e78aaa7c0c77064264ffdad0c3172aa0f5c376</id>
<content type='text'>
Have each `write_to_file` test pass in a custom filename to the helper
function. This way each test has its own file to deal with, eliminating
the race condition when running tests in parallel (the default).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Have each `write_to_file` test pass in a custom filename to the helper
function. This way each test has its own file to deal with, eliminating
the race condition when running tests in parallel (the default).
</pre>
</div>
</content>
</entry>
</feed>
