GNU bug report logs - #69097
[PATCH] Add 'kill-region-or-word' command

Previous Next

Package: emacs;

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 #164 received at 69097 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: rms <at> gnu.org, 69097 <at> debbugs.gnu.org, juri <at> linkov.net, stefankangas <at> gmail.com,
 Eli Zaretskii <eliz <at> gnu.org>, acorallo <at> gnu.org
Subject: Re: bug#69097: [PATCH] Add 'kill-region-or-word' command
Date: Wed, 04 Sep 2024 15:07:08 +0100
Hello,

On Tue 03 Sep 2024 at 04:32pm GMT, Philip Kaludercic wrote:

>
> +(defcustom kill-region-dwim nil
> +  "Behaviour when `kill-region' is invoked without an active region.
> +If set to nil (default), then an error occurs and nothing is killed.  If
> +set to `emacs-word', then kill a the last word as defined by the current
> +major mode.  If set to `unix-word', then kill the last word in the style
> +of a shell like Bash, disregarding the major mode."
> +  :type '(choice (const :tag "Kill a word like `backward-kill-word'" emacs-word)
> +                 (const :tag "Kill a word like Bash would" unix-word)
> +                 (const :tag "Do not kill anything" nil))
> +  :group 'killing)

I think I'm missing something here.  When it's nil and there is no
*active* region, but there is a region, it should kill that, surely?
With or without TMM.
I very regularly kill inactive regions (e.g. after M->).

> +                     ((eq region 'unix-word)
> +                      (let ((end (point)))
> +                        (save-excursion
> +                          (skip-chars-backward "[:space:]")
> +                          (skip-chars-backward "^[:space:]")
> +                          (filter-buffer-substring
> +                           (if (get-char-property (point) 'read-only)
> +                               (next-single-char-property-change
> +                                (point) 'read-only nil end)
> +                             (point))
> +                           end 'delete))))
> +                     (region
> +                      (funcall region-extract-function 'delete))
> +                     ((filter-buffer-substring beg end 'delete)))))

Shall I rather commit this as an independent unix-word-rubout?

Improves attribution, and it's independently useful.

-- 
Sean Whitton




This bug report was last modified 243 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.