Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Changing vi / emacs setopts
- X-seq: zsh-workers 53368
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [PATCH] Changing vi / emacs setopts
- Date: Sat, 15 Feb 2025 15:07:51 -0800
- Archived-at: <https://zsh.org/workers/53368>
- List-id: <zsh-workers.zsh.org>
On Thu, Feb 13, 2025 at 5:26 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> 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.
Any problems with the below?
diff --git a/Src/options.c b/Src/options.c
index 8b37ab5e8..696ab5c69 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -887,8 +887,14 @@ dosetopt(int optno, int value, int force, char *new_opts)
acquire_pgrp();
}
} else if ((optno == EMACSMODE || optno == VIMODE) && value) {
+ /* What's going on here:
+ * 1) unsetopt of either emacs or vi is an effective no-op.
+ * 2) setopt of either emacs or vi toggles off the other.
+ * Hence we disallow changing these options in emulation mode,
+ * but only if the change is setopt rather than unsetopt.
+ */
if (sticky && sticky->emulation)
- return -1;
+ return opts[optno] ? 0 : -1;
zleentry(ZLE_CMD_SET_KEYMAP, optno);
new_opts[(optno == EMACSMODE) ? VIMODE : EMACSMODE] = 0;
} else if (optno == SUNKEYBOARDHACK) {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author