aboutsummaryrefslogtreecommitdiffstats
path: root/config/binds.go
Commit message (Collapse)AuthorAgeFilesLines
* wizard: fix panic on any key pressRobin Jarry2022-12-191-205/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using :new-account, aerc crashes when entering a letter with the following trace: panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x66930e] goroutine 1 [running]: git.sr.ht/~rjarry/aerc/log.PanicHandler() git.sr.ht/~rjarry/aerc/log/panic-logger.go:51 +0x73e panic({0xa2b200, 0x10204e0}) runtime/panic.go:890 +0x262 git.sr.ht/~rjarry/aerc/config.(*KeyBindings).GetBinding(0xc000370000?, {0xc000634c48?, 0xc000118900?, 0x5843da?}) git.sr.ht/~rjarry/aerc/config/binds.go:331 +0x2e git.sr.ht/~rjarry/aerc/widgets.(*Aerc).Event(0xc000370000, {0xbd1e60?, 0xc00112e000?}) git.sr.ht/~rjarry/aerc/widgets/aerc.go:309 +0x196 git.sr.ht/~rjarry/aerc/lib/ui.(*UI).HandleEvent(0xc00031e840, {0xbd1e60?, 0xc00112e000}) git.sr.ht/~rjarry/aerc/lib/ui/ui.go:141 +0x162 main.main() git.sr.ht/~rjarry/aerc/aerc.go:246 +0xa89 The issue is that the keyNames map is empty when defaultBindsConfig() is called and ParseBinding("<C-q>", ":quit<Enter>") returns an error: Unknown key 'C-q' which is (unfortunately) ignored and nil is inserted in the wizard bindings. Fix that by initializing keyNames at the module level and remove init(). Fixes: c05c2ffe0424 ("config: make various sections accessible via global vars") Reported-by: Moritz Poldrack <moritz@poldrack.dev> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Moritz Poldrack <moritz@poldrack.dev>
* config: make various sections accessible via global varsRobin Jarry2022-12-141-31/+31
| | | | | | | | | | | | | | | | | | | | There is only one instance of AercConfig which is associated to the Aerc widget. Everywhere we need to access configuration options, we need somehow to get a reference either to the Aerc widget or to a pointer to the AercConfig instance. This makes the code cluttered. Remove the AercConfig structure and every place where it is referenced. Instead, declare global variables for every configuration section and access them directly from the `config` module. Since bindings and ui sections can be "contextual" (i.e. per account, per folder or per subject), leave most local references intact. Replacing them with config.{Ui,Binds}.For{Account,Folder,Subject} would make this patch even more unreadable. This is something that may be addressed in the future. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* config: rework contextual sections implementationRobin Jarry2022-12-141-28/+62
| | | | | | | | | | | | | The current contextual binds and ui config API is awkward and cumbersome to use. Rework it to make it more elegant. Store the contextual sections as private fields of the UIConfig and KeyBindings structures. Add cache to avoid recomputation of the composed UIConfig and KeyBindings objects every time a contextual item is requested. Replace the cache from DirectoryList with that. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* logging: rename package to logRobin Jarry2022-12-021-4/+4
| | | | | | | | | | Use the same name than the builtin "log" package. That way, we do not risk logging in the wrong place. Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* logging: homogenize levelsRobin Jarry2022-12-021-1/+1
| | | | | | | | | | | | | | | | | | The main goal is to ensure that by default, the log file (if configured) does not grow out of proportions. Most of the logging messages in aerc are actually for debugging and/or trace purposes. Define clear rules for logging levels. Enforce these rules everywhere. After this patch, here is what the log file looks like after starting up with a single account: INFO 2022/11/24 20:26:16.147164 aerc.go:176: Starting up version 0.13.0-100-g683981479c60 (go1.18.7 amd64 linux) INFO 2022/11/24 20:26:17.546448 account.go:254: [work] connected. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* config: add log-file and log-level settingsRobin Jarry2022-11-211-1/+1
| | | | | | | | | | | Allow configuring persistent logging to file with a log level. When redirecting the output of aerc to a file these two settings are ignored and all messages are printed to stdout. Suggested-by: Moritz Poldrack <moritz@poldrack.dev> Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* config: move binds.conf parsing in binds.goRobin Jarry2022-11-161-0/+205
| | | | | | | | | | The config.go file is getting too big. Move all binds.conf parsing logic into binds.go where it belongs. No functional change. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* config: rename bindings -> bindsRobin Jarry2022-11-161-0/+440
For consistency with binds.conf Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>