help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Accumulating text in the kill ring when in vi-insert mode


From: Jesse Hathaway
Subject: [Help-bash] Accumulating text in the kill ring when in vi-insert mode
Date: Fri, 31 May 2019 12:47:13 -0500

I am working on a readline config[1] that allows vi & emacs users to use the
same config, which is helpful when working together with someone in a shared
terminal. The approach I am taking is adding the emacs key bindings to the
vi-insert mode. This works surprisingly well, but the behavior of kill commands
changes. In emacs mode repeated kill commands accumulate in the kill ring as a
single unit, and are then all pasted together when yanked. In contrast when in
vi-insert mode repeated kill commands do not accumulate in the kill ring.

I was able to change this behavior with this diff:

  diff --git a/lib/readline/kill.c b/lib/readline/kill.c
  index cf8ca932..22c60581 100644
  --- a/lib/readline/kill.c
  +++ b/lib/readline/kill.c
  @@ -128,7 +128,7 @@ _rl_copy_to_kill_ring (char *text, int append)
       slot = rl_kill_ring_length - 1;

     /* If the last command was a kill, prepend or append. */
  -  if (_rl_last_command_was_kill && rl_kill_ring[slot] &&
rl_editing_mode != vi_mode)
  +  if (_rl_last_command_was_kill && rl_kill_ring[slot])
       {
         old = rl_kill_ring[slot];
         new = (char *)xmalloc (1 + strlen (old) + strlen (text));
  @@ -326,8 +326,7 @@ rl_unix_word_rubout (int count, int key)
    }

         rl_kill_text (orig_point, rl_point);
  -      if (rl_editing_mode == emacs_mode)
  - rl_mark = rl_point;
  +      rl_mark = rl_point;
       }

     return 0;

My question is why are kill commands intentionally not accumulated in vi-insert
mode? Would some workflow break if they were accumulated?

Thanks, Jesse

[1]: https://github.com/lollipopman/bash-rsi/blob/master/inputrc



reply via email to

[Prev in Thread] Current Thread [Next in Thread]