make account a *Mailbox; small fixes to code and readme
3 files changed, 13 insertions(+), 11 deletions(-)

M README.md
M mh/mh.go
M sequence.go
M README.md +3 -4
@@ 3,12 3,9 @@ Mailbox consists of a library and a comm
  [Go](http://golang.org/). Mailbox is a program in the spirit of [nmh](http://www.nongnu.org/nmh/) - many ideas of nmh found their way into mailbox. Compared to nmh, mailbox has less features, as it aims to be simpler to setup and to use than nmh.   
 As mailbox is setup/installed by editing and compiling the source code it takes some programming skills and a Go compiler to use mailbox.
 
-
-todo: for ppl with few-medium email traffic?
 ## Features/Nonfeatures
 ### No support for .mh_sequence files
-Not worth the SLOC, as I never use sequences (except marking new messages,
- but i can live without).
+Not worth the SLOC, as I never use sequences (except marking new messages, but i can live without).
 Saying that, mailbox is problably not useful for people who receive a lot of emails.
 
 ## Installation

          
@@ 21,6 18,7 @@ First install the package with
 Proceed with the instructions you find in 
 $GOPATH/dev/src/bitbucket.org/telesto/mailbox/setup_template.go 
 to setup mailbox.
+
 ## Sequences
 Mailbox supports a slightly modified subset of nmh sequences when 
 adressing messages.    

          
@@ 36,6 34,7 @@ These simple sequences tokens can be or-
 
 There is no limit, a sequence like 1,5,18-29,44,71,91-98,103,112-145 
 is valid.
+
 ## Examples
 * list all messages in inbox folder
 

          
M mh/mh.go +5 -5
@@ 13,7 13,8 @@ import (
 	"strings"
 )
 
-var account interface{}
+// set in setup.go
+var account *Mailbox
 
 // The folder types for different outputs in list view.
 //

          
@@ 47,11 48,10 @@ type Mailbox struct {
 }
 
 func NewMailbox() *Mailbox {
-	cfg, ok := account.(Mailbox)
-	if !ok {
-		panic("mh.account variable has wrong type. Set account informations first.")
+	if account == nil {
+		panic("mh account is nollllSet account informations first.")
 	}
-	return &cfg
+	return account
 }
 
 func (mh *Mailbox) osPath(elem ...string) string {

          
M sequence.go +5 -2
@@ 31,6 31,9 @@ func (s Sequence) IsMatch(n int64) bool 
 }
 
 func ParseSequence(input string) (*Sequence, error) {
+	invSeqToken := func(token string) error {
+		return errors.New("invalid sequence token '" + token + "'")
+	}
 	var seq Sequence
 	f := strings.Split(input, ",")
 	for i := range f {

          
@@ 43,13 46,13 @@ func ParseSequence(input string) (*Seque
 		// no number, try "n-m"
 		s := strings.Split(f[i], "-")
 		if len(s) != 2 {
-			return nil, errors.New("invalid sequence token '" + f[i] + "'")
+			return nil, invSeqToken(f[i])
 		}
 		var sect [2]int64
 		for j := 0; j <= 1; j++ {
 			n, err := strconv.Atoi(s[j])
 			if err != nil {
-				return nil, errors.New("invalid sequence token '" + f[i] + "'")
+				return nil, invSeqToken(f[i])
 			}
 			sect[j] = int64(n)
 		}