Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _zarun:1: can't change option: vi



On February 13, 2025, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Hm:
>
> % emulate zsh -c '() { print $options[vi]; options[vi]=on; }'
> on
> (anon): can't change option: vi
> % emulate zsh -c '() { print $options[vi]; options[vi]=off }'
> on
> %

> So ... the problem is that dosetopt() rejects the emacs and vi options
> in sticky emulations even if they're not actually changing ... but
> only if you're turning them on rather than turning them off, which
> seems a bit sideways.

I see. So maybe it should only fail if the value is actually changing?

diff --git a/Src/options.c b/Src/options.c
index 8b37ab5e8..c5186ef2b 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -887,6 +887,8 @@ dosetopt(int optno, int value, int force, char *new_opts)
            acquire_pgrp();
        }
     } else if ((optno == EMACSMODE || optno == VIMODE) && value) {
+       if (new_opts[optno] == value)
+           return 0;
        if (sticky && sticky->emulation)
            return -1;
        zleentry(ZLE_CMD_SET_KEYMAP, optno);



Messages sorted by: Reverse Date, Date, Thread, Author