Skip to content

Conversation

@tsdh
Copy link

@tsdh tsdh commented Nov 22, 2024

In Emacs 31, there's a new user option.

kill-region-dwim is a variable defined in ‘simple.el’.

Its value is ‘emacs-word’
Original value was nil

Behavior when ‘kill-region’ is invoked without an active region.
If set to nil (default), kill the region even if it is inactive,
signaling an error if there is no region.
If set to ‘emacs-word’, kill the last word as defined by the
current major mode.
If set to ‘unix-word’, kill the last word in the style of a shell like
Bash.  This ignores the major mode like ‘unix-word-rubout’ (which see).

  This variable was introduced, or its default value was changed, in
  version 31.1 of Emacs.
  You can customize this variable.

So when set to emacs-word (or unix-word) and you hit C-w (kill-region) while there is no active region, it will just kill the previous word. That's a very nice feature. However, it won't work with puni-kill-active-region which always signals an error when there's no active region. This PR changes that so that erroring itself, we simply fall back to kill-region.

…ve region

The default kill-region fallback behavior is to signal an error, or, since
Emacs 31, to perform the action defined by kill-region-dwim (which are variant
of killing the word before point which is a very handy operation for fixing
typos while writing).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant