Authentication-Results: mail-b.sr.ht; dkim=pass header.d=falsifian.org header.i=@falsifian.org Received: from exoco.falsifian.org (exoco.falsifian.org [168.235.109.198]) by mail-b.sr.ht (Postfix) with ESMTPS id 1180E11EE05 for <~rjarry/aerc-devel@lists.sr.ht>; Tue, 5 Jul 2022 06:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2020-07-31; bh=XC7DSOpjJ GmkOfq1LkQcEf/db0DoTxzwMlabkor6NC4=; h=date:subject:cc:to:from; d=falsifian.org; b=j9duQGlnQHr1cSZr2Sv6TOlRywNLojVjvSN4UCIiksXznzpgezt Hf+pYejojWFIjPKHxk2K73CqhT3rWhwcTkM6wYYe6xBVopcAccsuF4ueeLZwOsH93QqBVz 0EDHWzD0GfPCzmdChbm87iMuptEVappq/UIDQKhgBOIloDcGwPuuiRJh9T/ybCvzgCFa2M xAqdRiyclBdlytkgdRiXAMav0ezIq7uGIWMpOpPF0OrJS4jZ17QOi11+bKqbz8KbXg1wac 4rxSsy0BAQx2eu7tkl/nAo6l8TXl3mrI1jgtqOOiSwewRS+yOUEHCWCIC78tTXTB1TgvVv 18gRr6Ujn0w== Received: from moth.falsifian.org ( [50.206.101.226]) by exoco.falsifian.org (OpenSMTPD) with ESMTPSA id e2e74315 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 5 Jul 2022 06:06:28 +0000 (UTC) Received: from localhost (moth.falsifian.org [local]) by moth.falsifian.org (OpenSMTPD) with ESMTPA id 26f7b9b9; Tue, 5 Jul 2022 06:06:27 +0000 (UTC) From: James Cook To: ~rjarry/aerc-devel@lists.sr.ht Cc: falsifian@falsifian.org Subject: [PATCH aerc] Allow not marking viewed messages as seen. Date: Tue, 5 Jul 2022 06:06:18 +0000 Message-Id: <20220705060618.68685-1-falsifian@falsifian.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Fixes: https://todo.sr.ht/~rjarry/aerc/48 Signed-off-by: James Cook --- Sending this out for feedback. I should probably test it at least a little more; e.g. I haven't tried deleting a message to check that the change to delete.go makes sense. commands/account/view.go | 2 +- commands/msg/delete.go | 2 +- commands/msgview/next.go | 2 +- config/aerc.conf | 6 ++++++ config/config.go | 2 ++ doc/aerc-config.5.scd | 5 +++++ lib/messageview.go | 7 +++++-- widgets/msglist.go | 2 +- 8 files changed, 22 insertions(+), 6 deletions(-) diff --git a/commands/account/view.go b/commands/account/view.go index 8537d33..04a1687 100644 --- a/commands/account/view.go +++ b/commands/account/view.go @@ -46,7 +46,7 @@ func (ViewMessage) Execute(aerc *widgets.Aerc, args []string) error { return nil } lib.NewMessageStoreView(msg, store, aerc.Crypto, aerc.DecryptKeys, - func(view lib.MessageView, err error) { + acct.UiConfig(), func(view lib.MessageView, err error) { if err != nil { aerc.PushError(err.Error()) return diff --git a/commands/msg/delete.go b/commands/msg/delete.go index d26169f..aa129fa 100644 --- a/commands/msg/delete.go +++ b/commands/msg/delete.go @@ -69,7 +69,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error { return nil } lib.NewMessageStoreView(next, store, aerc.Crypto, aerc.DecryptKeys, - func(view lib.MessageView, err error) { + acct.UiConfig(), func(view lib.MessageView, err error) { if err != nil { aerc.PushError(err.Error()) return diff --git a/commands/msgview/next.go b/commands/msgview/next.go index 928b9fb..ca72715 100644 --- a/commands/msgview/next.go +++ b/commands/msgview/next.go @@ -43,7 +43,7 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error { return nil } lib.NewMessageStoreView(nextMsg, store, aerc.Crypto, aerc.DecryptKeys, - func(view lib.MessageView, err error) { + acct.UiConfig(), func(view lib.MessageView, err error) { if err != nil { aerc.PushError(err.Error()) return diff --git a/config/aerc.conf b/config/aerc.conf index 2f7597c..2f7a3d9 100644 --- a/config/aerc.conf +++ b/config/aerc.conf @@ -18,6 +18,12 @@ pgp-provider=internal unsafe-accounts-conf=false [ui] +# +# Set the "seen" flag when a message is viewed. +# +# Default: true +auto-mark-read=true + # # Describes the format for each row in a mailbox view. This field is compatible # with mutt's printf-like syntax. diff --git a/config/config.go b/config/config.go index 8a243c3..b1ecc0d 100644 --- a/config/config.go +++ b/config/config.go @@ -32,6 +32,7 @@ type GeneralConfig struct { } type UIConfig struct { + AutoMarkRead bool `ini:"auto-mark-read"` IndexFormat string `ini:"index-format"` TimestampFormat string `ini:"timestamp-format"` ThisDayTimeFormat string `ini:"this-day-time-format"` @@ -689,6 +690,7 @@ func LoadConfigFromFile(root *string, logger *log.Logger) (*AercConfig, error) { }, Ui: UIConfig{ + AutoMarkRead: true, IndexFormat: "%D %-17.17n %s", TimestampFormat: "2006-01-02 03:04 PM", ThisDayTimeFormat: "", diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd index 518fe51..02a1514 100644 --- a/doc/aerc-config.5.scd +++ b/doc/aerc-config.5.scd @@ -97,6 +97,11 @@ These options are configured in the *[ui]* section of aerc.conf. | %Z : flags (O=old, N=new, r=answered, D=deleted, !=flagged, \*=marked) +*auto-mark-read* + Set the "seen" flag when a message is viewed. + + Default: true + *timestamp-format* See time.Time#Format at https://godoc.org/time#Time.Format diff --git a/lib/messageview.go b/lib/messageview.go index a1797d5..0b7b5b9 100644 --- a/lib/messageview.go +++ b/lib/messageview.go @@ -9,6 +9,7 @@ import ( "github.com/emersion/go-message" _ "github.com/emersion/go-message/charset" + "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib/crypto" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/lib" @@ -62,7 +63,7 @@ type MessageStoreView struct { func NewMessageStoreView(messageInfo *models.MessageInfo, store *MessageStore, pgp crypto.Provider, decryptKeys openpgp.PromptFunction, - cb func(MessageView, error)) { + uiConfig *config.UIConfig, cb func(MessageView, error)) { msv := &MessageStoreView{messageInfo, store, nil, nil, messageInfo.BodyStructure} @@ -97,7 +98,9 @@ func NewMessageStoreView(messageInfo *models.MessageInfo, } else { cb(msv, nil) } - store.Flag([]uint32{messageInfo.Uid}, models.SeenFlag, true, nil) + if uiConfig.AutoMarkRead { + store.Flag([]uint32{messageInfo.Uid}, models.SeenFlag, true, nil) + } } func (msv *MessageStoreView) MessageInfo() *models.MessageInfo { diff --git a/widgets/msglist.go b/widgets/msglist.go index ec14e79..949662c 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -305,7 +305,7 @@ func (ml *MessageList) MouseEvent(localX int, localY int, event tcell.Event) { return } lib.NewMessageStoreView(msg, store, ml.aerc.Crypto, - ml.aerc.DecryptKeys, + ml.aerc.DecryptKeys, acct.UiConfig(), func(view lib.MessageView, err error) { if err != nil { ml.aerc.PushError(err.Error()) -- 2.36.1