「後方行削除」と「UNIX 行破棄」の違い

「後方行削除」と「UNIX 行破棄」の違い

私は bash のマニュアルページを読んで、キーボードショートカットを覚えています。C-x ruboutは にバインドされbackward kill lineC-uは にバインドされていますunix line discardが、これらのコマンドの説明は同じに見えます。これらのコマンドの違いは何ですか?

答え1

彼らの現在の実装backward-kill-lineこれら 2 つの関数は、 が負のプレフィックス引数を取ることができるのに対し、 はunix-line-discardプレフィックス引数を無視することを除いて、ほぼ同じことを行うように見えます。

/* Here is C-u doing what Unix does.  You don't *have* to use these
   key-bindings.  We have a choice of killing the entire line, or
   killing from where we are to the start of the line.  We choose the
   latter, because if you are a Unix weenie, then you haven't backspaced
   into the line at all, and if you aren't, then you know what you are
   doing. */
int
rl_unix_line_discard (int count, int key)
{
  if (rl_point == 0)
    rl_ding ();
  else
    {
      rl_kill_text (rl_point, 0);
      rl_point = 0;
      if (rl_editing_mode == emacs_mode)
    rl_mark = rl_point;
    }
  return 0;
}

/* Kill backwards to the start of the line.  If DIRECTION is negative, kill
   forwards to the line end instead. */
int
rl_backward_kill_line (int direction, int key)
{
  int orig_point;

  if (direction < 0)
    return (rl_kill_line (1, key));
  else
    {
      if (rl_point == 0)
    rl_ding ();
      else
    {
      orig_point = rl_point;
      rl_beg_of_line (1, key);
      if (rl_point != orig_point)
        rl_kill_text (orig_point, rl_point);
      if (rl_editing_mode == emacs_mode)
        rl_mark = rl_point;
    }
    }
  return 0;
}

答え2

私が見つけたものは次のとおりです:

backward-kill-line (C-x Rubout)
    Kill backward to the beginning of the line.

unix-line-discard (C-u)
    Kill backward from the cursor to the beginning of the current line. 

https://ftp.gnu.org/old-gnu/Manuals/bash-2.05a/html_node/bashref_97.html

       backward-kill-line (C-x Rubout)
              Kill backward to the beginning of the line.
       unix-line-discard (C-u)
              Kill backward from point to the beginning of the line.  The
              killed text is saved on the kill-ring.

https://man7.org/linux/man-pages/man3/readline.3.html#編集コマンド

unix-line-discardキーリングに保存されているようですが、backward-kill-line保存されていないようです。ただし、それを検証する方法がわかりませんでした。Emacs ウィキbackward-kill-lineジェリングにも追加されると言う

これらの用語のその他の使用法:https://github.com/junegunn/fzf/pull/489/files#diff-1fabf11f4aca2d62eb64290f66d25217R180

関連情報