Re: [Feature request] Configuration option for modernbindings
Benno Schulenberg <[email protected]>
| Newsgroups | gmane.editors.nano.devel |
|---|---|
| Message-ID | <[email protected]> |
Op 17-08-2024 om 00:35 schreef theaz7ieth5e--- via Development discussions.: > I'd like to propose a nanorc config line that enables modern bindings, such > as `set modernbindings`. Attached patch does what you want. But if your nanorc files contain any 'bind' command and you compile with '-fsanitize=address', then libasan will throw an error on exit, because of leaked memory. Benno
0001-experimental-feature-allow-set-modernbindings-in-an-.patch
(text/x-patch, 2 KB)
From f0a98e6f3f997f2f766730c2da212d2838966eee Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <[email protected]> Date: Sat, 17 Aug 2024 09:21:29 +0200 Subject: [PATCH] experimental feature: allow 'set modernbindings' in an rcfile This will, however, leak memory when an rcfile also uses 'bind' commands. --- src/nano.c | 15 +++++++++++++++ src/rcfile.c | 1 + 2 files changed, 16 insertions(+) diff --git a/src/nano.c b/src/nano.c index f4dbfdd1..e440a347 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1734,6 +1734,8 @@ int main(int argc, char **argv) #ifdef ENABLE_NANORC bool ignore_rcfiles = FALSE; /* Whether to ignore the nanorc files. */ + bool modernity = FALSE; + /* Whether "modern bindings" has been activated. */ #endif #if defined(ENABLED_WRAPORJUSTIFY) && defined(ENABLE_NANORC) bool fill_used = FALSE; @@ -2167,11 +2169,14 @@ int main(int argc, char **argv) rescind_colors = (getenv("NO_COLOR") != NULL); #endif + rewire: /* Set up the function and shortcut lists. This needs to be done * before reading the rcfile, to be able to rebind/unbind keys. */ shortcut_init(); #ifdef ENABLE_NANORC + modernity = ISSET(MODERN_BINDINGS); + if (!ignore_rcfiles) { /* Back up the command-line options that take an argument. */ #ifdef ENABLED_WRAPORJUSTIFY @@ -2261,6 +2266,16 @@ int main(int argc, char **argv) for (size_t i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) flags[i] |= flags_cmdline[i]; } + + /* If an rcfile has set 'modernbindings', redo the setup of shortcuts. */ + if (!modernity && ISSET(MODERN_BINDINGS)) { + while (sclist) { + keystruct *item = sclist; + sclist = sclist->next; + free(item); + } + goto rewire; + } #endif /* ENABLE_NANORC */ #ifdef ENABLE_WRAPPING diff --git a/src/rcfile.c b/src/rcfile.c index 56edb153..2758250c 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -60,6 +60,7 @@ static const rcoption rcopts[] = { #ifdef HAVE_LIBMAGIC {"magic", USE_MAGIC}, #endif + {"modernbindings", MODERN_BINDINGS}, #ifdef ENABLE_MOUSE {"mouse", USE_MOUSE}, #endif -- 2.45.1
OpenPGP_signature.asc
(application/pgp-signature, 840 B)
-----BEGIN PGP SIGNATURE----- wsF5BAABCAAjFiEEFo5vQpe/16ea/USWUUu+Lrjhlh8FAmbAUfgFAwAAAAAACgkQUUu+Lrjhlh8/ YA/9ExJwfIgpl12Tkp5MRN8JQOpdYfaqvv7Fl36+OIe//eZJgXkwHy/8meaVPAX9xoN7kv6A8zSp 9q4Wh1icDOFTADD1ZSxqoP9WiQZIUNOWmHgKVIJ4iPw+Ec8vvNMgPWhjiXX6gJb9VNwne2Nvlqzd Q7fTpAgQyD95ogpOI66XOEjvq0g1UsIYnCGfN9Xni9BFPUn0k95kHaByKgnpXY3IShMoS9bROXeC 2HYhJGoHvGHMe1pCB5raYFnuQ6e7YyCQKzOuL5WDJGk3qmleUdtehH/3xwivRSK0Fvl3bYrD+myU FbPs7DPCg+lCs6yhZXs8vuO28TMxjtfEIyJjX4vrmhi3qk0UfEUUTJCpiTy0G4QuygLFnL8+1yqB +UDBYaEdwRdWPdV2QzQzizqCqkmYkPY3+SlWMCos0gGDo9CjiyYvak/kDGNAR0dBq8a+fXI8eiB+ RNELsE9zfIAwqzXTAoujjZyhFoct96Xi5vZ9yNsGTrdhkJ0oeuq4RkbGcmeQIMlAcne1GZiIZgjV TqeSd4apawNTvQK4uXcN2gcfZOfWkgqaGh1MMZA4RR6zMhaTjs5II/hfqbRIMPq+WYnIscXL3i6P 9lEkWp1C6Fwkk0DP6d/go5u6SNJz0J4XDmWRzsjLeObA/WOOfOxDXaaoI2OpZZGYC9ynVQqAEK5G YzA= =jNuV -----END PGP SIGNATURE-----