GNU bug report logs -
#69097
[PATCH] Add 'kill-region-or-word' command
Previous Next
Reported by: Philip Kaludercic <philipk <at> posteo.net>
Date: Tue, 13 Feb 2024 09:57:02 UTC
Severity: normal
Tags: patch
Done: Sean Whitton <spwhitton <at> spwhitton.name>
Bug is archived. No further changes may be made.
Full log
Message #56 received at 69097 <at> debbugs.gnu.org (full text, mbox):
> From: Philip Kaludercic <philipk <at> posteo.net>
> Cc: rms <at> gnu.org, 69097 <at> debbugs.gnu.org
> Date: Fri, 03 May 2024 19:41:43 +0000
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > I don't think anyone wants the error, so doing something useful in
> > that case should be a no-brainer.
>
> How does this look like:
Looks good, but it needs some polish, I think:
> +---
> +*** New user option 'kill-word-if-no-region'.
> +This option will modify the fall-back behaviour of 'kill-region' if no
> +region is active, and will kill the last word instead of raising an
> +error.
This should be modified according to comments below, and also should
say what is the default of this option.
> +(defcustom kill-word-if-no-region nil
> + "Non-nil means that `kill-region' without a region will kill the last word."
> + :type 'boolean
> + :group 'killing)
This lacks the :version tag.
> +Lisp programs should use this function for killing text. (To delete
> +text, use `delete-region'.) Supply two arguments, character positions
> +BEG and END indicating the stretch of text to be killed. If the
> +optional argument REGION is non-nil, the function ignores BEG and END,
> +and kills the current region instead. If REGION has the special value
> +`kill-word', then it will kill the previous word, as with
> +`backward-kill-word'.
Instead of "the previous word", I would say "word characters before
point", since we don't kill the entire word if point is inside a word.
> Interactively, REGION is always non-nil, and so
> +this command always kills the current region."
This is not accurate, is it? If you invoke C-w immediately after
starting "emacs -Q", C-w currently signals an error. Also, the new
user option should be mentioned here with its effect on what happens
in that case.
> + (cond
> + ((and beg end (use-region-p))
> + (list beg end 'region))
> + (kill-word-if-no-region
> + (list beg end 'kill-word))
> + ((user-error "The mark is not set now, so there is no region"))))))
> +
If transient-mark-mode is OFF and kill-word-if-no-region is non-nil,
this will always kill the previous word, right? I think this is not
what we want, so I think the above should work specially if
transient-mark-mode is turned OFF.
Finally, this needs the suitable changes in the manuals.
Thanks.
This bug report was last modified 244 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.