Skip to contentSkip to conversation

libxcmd: use emacs mode for command history editing

PATCH In review Darrick J. Wong 2 participants 2 messages Dec 1, 2021 – Dec 3, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxcmd: use emacs mode for command history editing

From: Darrick J. Wong <[email protected]>

Prior to xfsprogs 5.7.0, we built xfsprogs with libreadline support by default. In its default configuration, that library interpreted various keystrokes in a direct manner (e.g. backspace deletes the character to the left of the cursor), which seems consistent with how emacs behaves.

However, libeditline's default keybindings are consistent with vim, which means that suddenly users are presented with not the same line editing interface that they had before. Since libeditline is configurable (put "bind -v" in editrc if you really want vim mode), let's put things back the way they were. At least as much as we can.

Fixes bbe12eb9 ("xfsprogs: remove libreadline support")
---
 db/input.c      |    1 +
 libxcmd/input.c |    1 +
 2 files changed, 2 insertions(+)
db/input.c +1 -0
index 448e84b0..d8113599 100644
@@ -227,6 +227,7 @@ fetchline(void)
 		el_set(el, EL_SIGNAL, 1);
 		el_set(el, EL_PROMPT, el_get_prompt);
 		el_set(el, EL_HIST, history, (const char *)hist);
+		el_set(el, EL_EDITOR, "emacs");
 	}
 
 	if (inputstacksize == 1) {
libxcmd/input.c +1 -0
index e3fa626a..fa80e5ab 100644
@@ -45,6 +45,7 @@ fetchline(void)
 		el_set(el, EL_SIGNAL, 1);
 		el_set(el, EL_PROMPT, el_get_prompt);
 		el_set(el, EL_HIST, history, (const char *)hist);
+		el_set(el, EL_EDITOR, "emacs");
 	}
 	cmd = el_gets(el, &count);
 	if (!cmd)