Commits

Anonymous committed 32afc46

applied go1rename gofix changes

Comments (0)

Files changed (2)

cmd/notmuch-addrlookup/notmuch-addrlookup.go

 
 /* Used to sort the email addresses from most to least used */
 func sort_by_freq(m1, m2 *mail_addr_freq) int {
-	if (m1.count[0] == m2.count[0] &&
+	if m1.count[0] == m2.count[0] &&
 		m1.count[1] == m2.count[1] &&
-		m1.count[2] == m2.count[2]) {
+		m1.count[2] == m2.count[2] {
 		return 0
 	}
 
-	if (m1.count[0] >  m2.count[0] ||
+	if m1.count[0] > m2.count[0] ||
 		m1.count[0] == m2.count[0] &&
-		m1.count[1] >  m2.count[1] ||
+			m1.count[1] > m2.count[1] ||
 		m1.count[0] == m2.count[0] &&
-		m1.count[1] == m2.count[1] &&
-		m1.count[2] >  m2.count[2]) {
+			m1.count[1] == m2.count[1] &&
+			m1.count[2] > m2.count[2] {
 		return -1
 	}
 
 	return len(*self)
 }
 
-func (self *maddresses) Less(i,j int) bool {
+func (self *maddresses) Less(i, j int) bool {
 	m1 := (*self)[i]
 	m2 := (*self)[j]
-	v  := sort_by_freq(m1, m2)
-	if v<=0 {
+	v := sort_by_freq(m1, m2)
+	if v <= 0 {
 		return true
 	}
 	return false
 }
 
-func (self *maddresses) Swap(i,j int) {
+func (self *maddresses) Swap(i, j int) {
 	(*self)[i], (*self)[j] = (*self)[j], (*self)[i]
 }
 
 	fullname := ""
 	freqs_sz := len(freqs)
 
-	for mail,freq := range freqs {
+	for mail, freq := range freqs {
 		if (freq > maxfreq && mail != "") || freqs_sz == 1 {
 			// only use the entry if it has a real name
 			// or if this is the only entry
 	// 	"<?(?P<mail>\\b\\w+([-+.]\\w+)*\\@\\w+[-\\.\\w]*\\.([-\\.\\w]+)*\\w\\b)>?)"
 	pattern = `.*` + strings.ToLower(name) + `.*`
 	var re *regexp.Regexp = nil
-	var err os.Error = nil
-	if re,err = regexp.Compile(pattern); err != nil {
+	var err error = nil
+	if re, err = regexp.Compile(pattern); err != nil {
 		log.Printf("error: %v\n", err)
 		return &freqs
 	}
-	
+
 	headers := []string{"from"}
 	if pass == 1 {
 		headers = append(headers, "to", "cc", "bcc")
 	}
 
-	for ;msgs.Valid();msgs.MoveToNext() {
+	for ; msgs.Valid(); msgs.MoveToNext() {
 		msg := msgs.Get()
 		//println("==> msg [", msg.GetMessageId(), "]")
-		for _,header := range headers {
+		for _, header := range headers {
 			froms := strings.ToLower(msg.GetHeader(header))
 			//println("  froms: ["+froms+"]")
-			for _,from := range strings.Split(froms, ",") {
+			for _, from := range strings.Split(froms, ",") {
 				from = strings.Trim(from, " ")
 				match := re.FindString(from)
 				//println("  -> match: ["+match+"]")
-				occ,ok := freqs[match]
+				occ, ok := freqs[match]
 				if !ok {
 					freqs[match] = 0
 					occ = 0
 				}
-				freqs[match] = occ+1
+				freqs[match] = occ + 1
 			}
 		}
 	}
 	addr_to_realname := make(map[string]*frequencies)
 
 	var pass uint = 0 // 0-based
-	for _,query := range queries {
+	for _, query := range queries {
 		if query == nil {
 			//println("**warning: idx [",idx,"] contains a nil query")
 			continue
 		msgs := query.SearchMessages()
 		ht := addresses_by_frequency(msgs, name, pass, &addr_to_realname)
 		for addr, count := range *ht {
-			freq,ok := addr_freq[addr]
+			freq, ok := addr_freq[addr]
 			if !ok {
-				freq = &mail_addr_freq{addr:addr, count:[3]uint{0,0,0}}
+				freq = &mail_addr_freq{addr: addr, count: [3]uint{0, 0, 0}}
 			}
 			freq.count[pass] = count
 			addr_freq[addr] = freq
 	}
 	sort.Sort(&addrs)
 
-	for _,addr := range addrs {
-		freqs,ok := addr_to_realname[addr.addr]
+	for _, addr := range addrs {
+		freqs, ok := addr_to_realname[addr.addr]
 		if ok {
 			val = append(val, frequent_fullname(*freqs))
 		} else {
 
 func new_address_matcher() *address_matcher {
 	var cfg *config.Config
-	var err os.Error
+	var err error
 
 	// honor NOTMUCH_CONFIG
 	home := os.Getenv("NOTMUCH_CONFIG")
 		home = os.Getenv("HOME")
 	}
 
-	if cfg,err = config.ReadDefault(path.Join(home, ".notmuch-config")); err != nil {
-		log.Fatalf("error loading config file:",err)
+	if cfg, err = config.ReadDefault(path.Join(home, ".notmuch-config")); err != nil {
+		log.Fatalf("error loading config file:", err)
 	}
 
-	db_path,_ := cfg.String("database", "path")
-	primary_email,_ := cfg.String("user", "primary_email")
-	addrbook_tag,err := cfg.String("user", "addrbook_tag")
+	db_path, _ := cfg.String("database", "path")
+	primary_email, _ := cfg.String("user", "primary_email")
+	addrbook_tag, err := cfg.String("user", "addrbook_tag")
 	if err != nil {
 		addrbook_tag = "addressbook"
 	}
 
-	self := &address_matcher{db:nil, 
-	                         user_db_path:db_path,
-	                         user_primary_email:primary_email,
-	                         user_addrbook_tag:addrbook_tag}
+	self := &address_matcher{db: nil,
+		user_db_path:       db_path,
+		user_primary_email: primary_email,
+		user_addrbook_tag:  addrbook_tag}
 	return self
 }
 
 func (self *address_matcher) run(name string) {
 	queries := [3]*notmuch.Query{}
-	
+
 	// open the database
-	self.db = notmuch.OpenDatabase(self.user_db_path, 
+	self.db = notmuch.OpenDatabase(self.user_db_path,
 		notmuch.DATABASE_MODE_READ_ONLY)
 
 	// pass 1: look at all from: addresses with the address book tag
 	// pass 2: look at all to: addresses sent from our primary mail
 	query = ""
 	if name != "" {
-		query = "to:"+name+"*"
+		query = "to:" + name + "*"
 	}
 	if self.user_primary_email != "" {
 		query = query + " from:" + self.user_primary_email
 	queries[1] = self.db.CreateQuery(query)
 
 	// if that leads only to a few hits, we check every from too
-	if queries[0].CountMessages() + queries[1].CountMessages() < 10 {
+	if queries[0].CountMessages()+queries[1].CountMessages() < 10 {
 		query = ""
 		if name != "" {
-			query = "from:"+name+"*"
+			query = "from:" + name + "*"
 		}
 		queries[2] = self.db.CreateQuery(query)
 	}
-	
+
 	// actually retrieve and sort addresses
 	results := search_address_passes(queries, name)
-	for _,v := range results {
+	for _, v := range results {
 		if v != "" && v != "\n" {
 			fmt.Println(v)
 		}
 		name = os.Args[1]
 	}
 	app.run(name)
-}
+}

pkg/notmuch/notmuch.go

  *	* An out-of-memory situation occurs
  *	* A Xapian exception occurs
  */
-func (self *Database) FindMessage(message_id string) *Message {
+// func (self *Database) FindMessage(message_id string) *Message {
 	
-	var c_msg_id *C.char = C.CString(message_id)
-	defer C.free(unsafe.Pointer(c_msg_id))
+// 	var c_msg_id *C.char = C.CString(message_id)
+// 	defer C.free(unsafe.Pointer(c_msg_id))
 
-	if c_msg_id == nil {
-		return nil
-	}
+// 	if c_msg_id == nil {
+// 		return nil
+// 	}
 
-	msg := C.notmuch_database_find_message(self.db, c_msg_id)
-	if msg == nil {
-		return nil
-	}
-	return &Message{message:msg}
-}
+// 	msg := C.notmuch_database_find_message(self.db, c_msg_id)
+// 	if msg == nil {
+// 		return nil
+// 	}
+// 	return &Message{message:msg}
+// }
 
 /* Return a list of all tags found in the database.
  *