diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/calendar/calendar.go | 1 | ||||
-rw-r--r-- | lib/crypto/gpg/gpg.go | 1 | ||||
-rw-r--r-- | lib/crypto/gpg/gpgbin/encrypt.go | 2 | ||||
-rw-r--r-- | lib/crypto/pgp/pgp.go | 6 | ||||
-rw-r--r-- | lib/format/format.go | 14 | ||||
-rw-r--r-- | lib/messageview.go | 11 | ||||
-rw-r--r-- | lib/msgstore.go | 42 | ||||
-rw-r--r-- | lib/oauthbearer.go | 1 | ||||
-rw-r--r-- | lib/open.go | 1 | ||||
-rw-r--r-- | lib/parse/hyperlinks.go | 8 | ||||
-rw-r--r-- | lib/statusline/state.go | 9 | ||||
-rw-r--r-- | lib/structure_helpers_test.go | 20 | ||||
-rw-r--r-- | lib/templates/template.go | 4 | ||||
-rw-r--r-- | lib/ui/borders.go | 3 | ||||
-rw-r--r-- | lib/ui/context.go | 3 | ||||
-rw-r--r-- | lib/ui/tab.go | 6 | ||||
-rw-r--r-- | lib/ui/textinput.go | 3 | ||||
-rw-r--r-- | lib/ui/ui.go | 1 |
18 files changed, 70 insertions, 66 deletions
diff --git a/lib/calendar/calendar.go b/lib/calendar/calendar.go index dbce6bce..ebe1b771 100644 --- a/lib/calendar/calendar.go +++ b/lib/calendar/calendar.go @@ -26,7 +26,6 @@ func (cr *Reply) AddOrganizer(o string) { // CreateReply parses a ics request and return a ics reply (RFC 2446, Section 3.2.3) func CreateReply(reader io.Reader, from *mail.Address, partstat string) (*Reply, error) { - cr := Reply{ MimeType: "text/calendar", Params: map[string]string{ diff --git a/lib/crypto/gpg/gpg.go b/lib/crypto/gpg/gpg.go index e545e1c9..c73272a3 100644 --- a/lib/crypto/gpg/gpg.go +++ b/lib/crypto/gpg/gpg.go @@ -37,7 +37,6 @@ func (m *Mail) ImportKeys(r io.Reader) error { } func (m *Mail) Encrypt(buf *bytes.Buffer, rcpts []string, signer string, decryptKeys openpgp.PromptFunction, header *mail.Header) (io.WriteCloser, error) { - return Encrypt(buf, header.Header.Header, rcpts, signer) } diff --git a/lib/crypto/gpg/gpgbin/encrypt.go b/lib/crypto/gpg/gpgbin/encrypt.go index e72ba148..31245a74 100644 --- a/lib/crypto/gpg/gpgbin/encrypt.go +++ b/lib/crypto/gpg/gpgbin/encrypt.go @@ -11,7 +11,7 @@ import ( // Encrypt runs gpg --encrypt [--sign] -r [recipient]. The default is to have // --trust-model always set func Encrypt(r io.Reader, to []string, from string) ([]byte, error) { - //TODO probably shouldn't have --trust-model always a default + // TODO probably shouldn't have --trust-model always a default args := []string{ "--armor", "--trust-model", "always", diff --git a/lib/crypto/pgp/pgp.go b/lib/crypto/pgp/pgp.go index 647b091b..c305f068 100644 --- a/lib/crypto/pgp/pgp.go +++ b/lib/crypto/pgp/pgp.go @@ -31,10 +31,10 @@ var ( func (m *Mail) Init() error { logging.Infof("Initializing PGP keyring") - os.MkdirAll(path.Join(xdg.DataHome(), "aerc"), 0700) + os.MkdirAll(path.Join(xdg.DataHome(), "aerc"), 0o700) lockpath := path.Join(xdg.DataHome(), "aerc", "keyring.lock") - lockfile, err := os.OpenFile(lockpath, os.O_CREATE|os.O_EXCL, 0600) + lockfile, err := os.OpenFile(lockpath, os.O_CREATE|os.O_EXCL, 0o600) if err != nil { // TODO: Consider connecting to main process over IPC socket locked = false @@ -149,7 +149,7 @@ func (m *Mail) ImportKeys(r io.Reader) error { Keyring = append(Keyring, keys...) if locked { keypath := path.Join(xdg.DataHome(), "aerc", "keyring.asc") - keyfile, err := os.OpenFile(keypath, os.O_CREATE|os.O_APPEND, 0600) + keyfile, err := os.OpenFile(keypath, os.O_CREATE|os.O_APPEND, 0o600) if err != nil { return err } diff --git a/lib/format/format.go b/lib/format/format.go index cc9716dd..0d14cb19 100644 --- a/lib/format/format.go +++ b/lib/format/format.go @@ -81,7 +81,8 @@ type Ctx struct { func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string, thisWeekTimeFmt string, thisYearTimeFmt string, ctx Ctx) ( - string, []interface{}, error) { + string, []interface{}, error, +) { retval := make([]byte, 0, len(format)) var args []interface{} @@ -289,10 +290,10 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string, } case 'Z': // calculate all flags - var readReplyFlag = "" - var delFlag = "" - var flaggedFlag = "" - var markedFlag = "" + readReplyFlag := "" + delFlag := "" + flaggedFlag := "" + markedFlag := "" seen := false recent := false answered := false @@ -390,7 +391,8 @@ handle_end_error: } func dummyIfZeroDate(date time.Time, format string, todayFormat string, - thisWeekFormat string, thisYearFormat string) string { + thisWeekFormat string, thisYearFormat string, +) string { if date.IsZero() { return strings.Repeat("?", len(format)) } diff --git a/lib/messageview.go b/lib/messageview.go index a1797d53..e0e86ea1 100644 --- a/lib/messageview.go +++ b/lib/messageview.go @@ -62,10 +62,12 @@ type MessageStoreView struct { func NewMessageStoreView(messageInfo *models.MessageInfo, store *MessageStore, pgp crypto.Provider, decryptKeys openpgp.PromptFunction, - cb func(MessageView, error)) { - - msv := &MessageStoreView{messageInfo, store, - nil, nil, messageInfo.BodyStructure} + cb func(MessageView, error), +) { + msv := &MessageStoreView{ + messageInfo, store, + nil, nil, messageInfo.BodyStructure, + } if usePGP(messageInfo.BodyStructure) { store.FetchFull([]uint32{messageInfo.Uid}, func(fm *types.FullMessage) { @@ -117,7 +119,6 @@ func (msv *MessageStoreView) MessageDetails() *models.MessageDetails { } func (msv *MessageStoreView) FetchBodyPart(part []int, cb func(io.Reader)) { - if msv.message == nil { msv.messageStore.FetchBodyPart(msv.messageInfo.Uid, part, cb) return diff --git a/lib/msgstore.go b/lib/msgstore.go index b91cd82d..bbaa70ad 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -27,7 +27,7 @@ type MessageStore struct { bodyCallbacks map[uint32][]func(*types.FullMessage) headerCallbacks map[uint32][]func(*types.MessageInfo) - //marking + // marking marked map[uint32]struct{} lastMarked map[uint32]struct{} visualStartUid uint32 @@ -68,8 +68,8 @@ func NewMessageStore(worker *types.Worker, defaultSortCriteria []*types.SortCriterion, thread bool, clientThreads bool, clientThreadsDelay time.Duration, triggerNewEmail func(*models.MessageInfo), - triggerDirectoryChange func()) *MessageStore { - + triggerDirectoryChange func(), +) *MessageStore { if !dirInfo.Caps.Thread { clientThreads = true } @@ -102,8 +102,8 @@ func NewMessageStore(worker *types.Worker, } func (store *MessageStore) FetchHeaders(uids []uint32, - cb func(*types.MessageInfo)) { - + cb func(*types.MessageInfo), +) { // TODO: this could be optimized by pre-allocating toFetch and trimming it // at the end. In practice we expect to get most messages back in one frame. var toFetch []uint32 @@ -166,7 +166,6 @@ func (store *MessageStore) FetchFull(uids []uint32, cb func(*types.FullMessage)) } func (store *MessageStore) FetchBodyPart(uid uint32, part []int, cb func(io.Reader)) { - store.worker.PostAction(&types.FetchMessageBodyPart{ Uid: uid, Part: part, @@ -399,7 +398,6 @@ func (store *MessageStore) runThreadBuilder() { } } store.threadBuilderDebounce = time.AfterFunc(store.threadBuilderDelay, func() { - // temporarily deactiviate the selector in the message list by // setting SelectedUid to the MagicUid oldUid := store.SelectedUid() @@ -436,8 +434,8 @@ func (store *MessageStore) runThreadBuilder() { } func (store *MessageStore) Delete(uids []uint32, - cb func(msg types.WorkerMessage)) { - + cb func(msg types.WorkerMessage), +) { for _, uid := range uids { store.Deleted[uid] = nil } @@ -461,8 +459,8 @@ func (store *MessageStore) revertDeleted(uids []uint32) { } func (store *MessageStore) Copy(uids []uint32, dest string, createDest bool, - cb func(msg types.WorkerMessage)) { - + cb func(msg types.WorkerMessage), +) { if createDest { store.worker.PostAction(&types.CreateDirectory{ Directory: dest, @@ -477,8 +475,8 @@ func (store *MessageStore) Copy(uids []uint32, dest string, createDest bool, } func (store *MessageStore) Move(uids []uint32, dest string, createDest bool, - cb func(msg types.WorkerMessage)) { - + cb func(msg types.WorkerMessage), +) { for _, uid := range uids { store.Deleted[uid] = nil } @@ -505,8 +503,8 @@ func (store *MessageStore) Move(uids []uint32, dest string, createDest bool, } func (store *MessageStore) Flag(uids []uint32, flag models.Flag, - enable bool, cb func(msg types.WorkerMessage)) { - + enable bool, cb func(msg types.WorkerMessage), +) { store.worker.PostAction(&types.FlagMessages{ Enable: enable, Flag: flag, @@ -515,8 +513,8 @@ func (store *MessageStore) Flag(uids []uint32, flag models.Flag, } func (store *MessageStore) Answered(uids []uint32, answered bool, - cb func(msg types.WorkerMessage)) { - + cb func(msg types.WorkerMessage), +) { store.worker.PostAction(&types.AnsweredMessages{ Answered: answered, Uids: uids, @@ -524,7 +522,6 @@ func (store *MessageStore) Answered(uids []uint32, answered bool, } func (store *MessageStore) Uids() []uint32 { - if store.ThreadedView() && store.builder != nil { if uids := store.builder.Uids(); len(uids) > 0 { return uids @@ -608,13 +605,13 @@ func (store *MessageStore) checkMark() { } } -//IsMarked checks whether a MessageInfo has been marked +// IsMarked checks whether a MessageInfo has been marked func (store *MessageStore) IsMarked(uid uint32) bool { _, marked := store.marked[uid] return marked } -//ToggleVisualMark enters or leaves the visual marking mode +// ToggleVisualMark enters or leaves the visual marking mode func (store *MessageStore) ToggleVisualMark() { store.visualMarkMode = !store.visualMarkMode switch store.visualMarkMode { @@ -629,7 +626,7 @@ func (store *MessageStore) ToggleVisualMark() { } } -//ClearVisualMark leaves the visual marking mode and resets any marking +// ClearVisualMark leaves the visual marking mode and resets any marking func (store *MessageStore) ClearVisualMark() { store.resetMark() store.visualMarkMode = false @@ -793,7 +790,8 @@ func (store *MessageStore) PrevResult() { } func (store *MessageStore) ModifyLabels(uids []uint32, add, remove []string, - cb func(msg types.WorkerMessage)) { + cb func(msg types.WorkerMessage), +) { store.worker.PostAction(&types.ModifyLabels{ Uids: uids, Add: add, diff --git a/lib/oauthbearer.go b/lib/oauthbearer.go index 1030696e..4954830f 100644 --- a/lib/oauthbearer.go +++ b/lib/oauthbearer.go @@ -3,6 +3,7 @@ package lib import ( "context" "fmt" + "github.com/emersion/go-imap/client" "github.com/emersion/go-sasl" "golang.org/x/oauth2" diff --git a/lib/open.go b/lib/open.go index f395d13d..c5d4b1c0 100644 --- a/lib/open.go +++ b/lib/open.go @@ -29,7 +29,6 @@ func NewXDGOpen(filename string) *xdgOpen { errCh: errch, args: []string{filename}, } - } // SetArgs sets additional arguments to the open command prior to the filename diff --git a/lib/parse/hyperlinks.go b/lib/parse/hyperlinks.go index 7a005383..2087a55c 100644 --- a/lib/parse/hyperlinks.go +++ b/lib/parse/hyperlinks.go @@ -8,8 +8,10 @@ import ( "strings" ) -var submatch = `(https?:\/\/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,10}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*))` -var httpRe = regexp.MustCompile("\"" + submatch + "\"" + "|" + "\\(" + submatch + "\\)" + "|" + "<" + submatch + ">" + "|" + submatch) +var ( + submatch = `(https?:\/\/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,10}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*))` + httpRe = regexp.MustCompile("\"" + submatch + "\"" + "|" + "\\(" + submatch + "\\)" + "|" + "<" + submatch + ">" + "|" + submatch) +) // HttpLinks searches a reader for a http link and returns a copy of the // reader and a slice with links. @@ -36,7 +38,7 @@ func HttpLinks(r io.Reader) (io.Reader, []string) { } results := []string{} - for link, _ := range linkMap { + for link := range linkMap { results = append(results, link) } diff --git a/lib/statusline/state.go b/lib/statusline/state.go index 54746fbd..8384f200 100644 --- a/lib/statusline/state.go +++ b/lib/statusline/state.go @@ -32,10 +32,11 @@ type folderState struct { } func NewState(name string, multipleAccts bool, conf config.StatuslineConfig) *State { - return &State{separator: conf.Separator, - renderer: newRenderer(conf.RenderFormat, conf.DisplayMode), - acct: &accountState{Name: name, Multiple: multipleAccts}, - fldr: make(map[string]*folderState), + return &State{ + separator: conf.Separator, + renderer: newRenderer(conf.RenderFormat, conf.DisplayMode), + acct: &accountState{Name: name, Multiple: multipleAccts}, + fldr: make(map[string]*folderState), } } diff --git a/lib/structure_helpers_test.go b/lib/structure_helpers_test.go index f670735c..a63825d9 100644 --- a/lib/structure_helpers_test.go +++ b/lib/structure_helpers_test.go @@ -8,27 +8,26 @@ import ( ) func TestLib_FindAllNonMultipart(t *testing.T) { - testStructure := &models.BodyStructure{ MIMEType: "multipart", Parts: []*models.BodyStructure{ - &models.BodyStructure{}, - &models.BodyStructure{ + {}, + { MIMEType: "multipart", Parts: []*models.BodyStructure{ - &models.BodyStructure{}, - &models.BodyStructure{}, + {}, + {}, }, }, - &models.BodyStructure{}, + {}, }, } expected := [][]int{ - []int{1}, - []int{2, 1}, - []int{2, 2}, - []int{3}, + {1}, + {2, 1}, + {2, 2}, + {3}, } parts := lib.FindAllNonMultipart(testStructure, nil, nil) @@ -42,5 +41,4 @@ func TestLib_FindAllNonMultipart(t *testing.T) { t.Errorf("incorrect values; expected: %v, got: %v", expected[i], parts[i]) } } - } diff --git a/lib/templates/template.go b/lib/templates/template.go index 9c71c463..7254d493 100644 --- a/lib/templates/template.go +++ b/lib/templates/template.go @@ -19,7 +19,7 @@ import ( var version string -//SetVersion initializes the aerc version displayed in template functions +// SetVersion initializes the aerc version displayed in template functions func SetVersion(v string) { version = v } @@ -182,7 +182,7 @@ func findTemplate(templateName string, templateDirs []string) (string, error) { "Can't find template %q in any of %v ", templateName, templateDirs) } -//DummyData provides dummy data to test template validity +// DummyData provides dummy data to test template validity func DummyData() interface{} { from := &mail.Address{ Name: "John Doe", diff --git a/lib/ui/borders.go b/lib/ui/borders.go index 6a5e9dc9..8d381b91 100644 --- a/lib/ui/borders.go +++ b/lib/ui/borders.go @@ -22,7 +22,8 @@ type Bordered struct { } func NewBordered( - content Drawable, borders uint, uiConfig *config.UIConfig) *Bordered { + content Drawable, borders uint, uiConfig *config.UIConfig, +) *Bordered { b := &Bordered{ borders: borders, content: content, diff --git a/lib/ui/context.go b/lib/ui/context.go index 7936f359..fc2104df 100644 --- a/lib/ui/context.go +++ b/lib/ui/context.go @@ -63,7 +63,8 @@ func (ctx *Context) SetCell(x, y int, ch rune, style tcell.Style) { } func (ctx *Context) Printf(x, y int, style tcell.Style, - format string, a ...interface{}) int { + format string, a ...interface{}, +) int { width, height := ctx.viewport.Size() if x >= width || y >= height { diff --git a/lib/ui/tab.go b/lib/ui/tab.go index fd49dfee..bcad23c2 100644 --- a/lib/ui/tab.go +++ b/lib/ui/tab.go @@ -36,8 +36,10 @@ type Tab struct { uiConf *config.UIConfig } -type TabStrip Tabs -type TabContent Tabs +type ( + TabStrip Tabs + TabContent Tabs +) func NewTabs(uiConf *config.UIConfig) *Tabs { tabs := &Tabs{} diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go index 9d1de963..8f8f00d0 100644 --- a/lib/ui/textinput.go +++ b/lib/ui/textinput.go @@ -59,7 +59,8 @@ func (ti *TextInput) Prompt(prompt string) *TextInput { } func (ti *TextInput) TabComplete( - tabcomplete func(s string) ([]string, string), d time.Duration) *TextInput { + tabcomplete func(s string) ([]string, string), d time.Duration, +) *TextInput { ti.tabcomplete = tabcomplete ti.completeDelay = d return ti diff --git a/lib/ui/ui.go b/lib/ui/ui.go index b65c06a4..1f618a6f 100644 --- a/lib/ui/ui.go +++ b/lib/ui/ui.go @@ -19,7 +19,6 @@ type UI struct { } func Initialize(content DrawableInteractive) (*UI, error) { - screen, err := tcell.NewScreen() if err != nil { return nil, err |