Subject: bug#69097: [PATCH] Add 'kill-region-or-word' command

From: Eli Zaretskii <[email-masked]>
Date: Fri, 06 Sep 2024 14:30:54 +0300

> From: Sean Whitton <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  [email-masked],
>   [email-masked],  [email-masked],  [email-masked],  [email-masked]
> Date: Fri, 06 Sep 2024 11:36:25 +0100
> 
> I think you're right, but I would like to commit my function first, so
> that I get attribution (it did take me some time to figure out what was
> useful in this area), and because I think it should be rewritten in
> terms of fields.
> 
> Please take a look at the attached.  unix-word-rubout to follow.

Thanks, but I see no reason to document this command in the manual,
certainly not in the ELisp reference (it's a command, not a function).
IMO it's obscure enough to be documented only in NEWS.

> +(defun forward-unix-word (&optional arg delim)
> +  "Move forward to the end of the next whitespace-delimited word.
> +With argument ARG, do this that many times; the default is once.
> +With negative ARG, go backwards to the beginning of whitespace-delimited
> +words.
> +DELIM is a string specifying what characters are considered whitespace,
> +as might be passed to `skip-chars-forward'.
> +The default is \"[:space:]\\n\".  Do not prefix a `^' character.

Should this be "[:space:]\\n\\r" instead? if not, why not?

Also note that [:space:] depends on mode-specific syntax table, so I
question the wisdom of using it in a command that's supposed to be
mode-agnostic.

> +This command is like `forward-word' except that words are always
> +delimited by whitespace, regardless of the buffer's syntax table.
> +Like `forward-word', this command respects fields.
> +
> +This emulates how C-w at the Unix terminal or shell identifies words.
> +See the `unix-word-rubout' command in Info node `(readline)Commands For
> +Killing'."

This should try to be more explicit about what "word" means for this
command.  Since it's so different from any notion of "word" in Emacs,
I would even seriously consider not to use that word, or maybe quote
it (in addition to explaining what it means).

Also, since this is a command, its doc string should clearly separate
what happens in interactive invocation from what happens when called
from Lisp.  DELIM belongs to the latter.  (Is it even useful to
provide that option for Lisp-only calls? what's the use case for
that?)

And finally, I wonder why we need this command?  AFAIU, the original
intent was to implement something similar to unix-word-rubout, not a
new movement command.  If the plan has changed, I think we need to
discuss the need once again.

Thanks.