From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean Whitton Newsgroups: gmane.emacs.bugs Subject: bug#69097: [PATCH] Add 'kill-region-or-word' command Date: Wed, 04 Sep 2024 15:07:08 +0100 Message-ID: <87a5gnzf5f.fsf@zephyr.silentflame.com> References: <871q9g8z8k.fsf@posteo.net> <861q6jji0i.fsf@gnu.org> <87o79n6uj6.fsf@posteo.net> <86v83vi2kr.fsf@gnu.org> <86seyzi2by.fsf@gnu.org> <87cyq26bt8.fsf@posteo.net> <864jbeixkt.fsf@gnu.org> <874jbe65u0.fsf@posteo.net> <8634qwkbtc.fsf@mail.linkov.net> <86h6fceij2.fsf@gnu.org> <87edaeevmr.fsf@zephyr.silentflame.com> <87a5l2evdn.fsf@zephyr.silentflame.com> <86ikzqbzac.fsf@gnu.org> <87seujf8bb.fsf@posteo.net> <867cbu9uce.fsf@gnu.org> <87cyllg57r.fsf@posteo.net> <87zfopbxdk.fsf@zephyr.silentflame.com> <87seuhbx87.fsf@zephyr.silentflame.com> <87zfopep5q.fsf@posteo.net> <86r0a16i71.fsf@gnu.org> <877cbshf4h.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21073"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: rms@gnu.org, 69097@debbugs.gnu.org, juri@linkov.net, stefankangas@gmail.com, Eli Zaretskii , acorallo@gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 04 16:08:11 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1slqg6-0005Hy-RW for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 04 Sep 2024 16:08:11 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slqfx-0000wN-Ju; Wed, 04 Sep 2024 10:08:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slqfv-0000uf-OP for bug-gnu-emacs@gnu.org; Wed, 04 Sep 2024 10:07:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1slqfu-0002E1-Qa for bug-gnu-emacs@gnu.org; Wed, 04 Sep 2024 10:07:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=Ptt1xTOOe1rajM8rWrKJGWQZEww9lvM+As2wDdiU0b4=; b=nhtcvJYLaOyE9iE+UvLPW6eHU/8RhGda3fsjMlRGDPAJqjHD960XZBtFTVVQWXXS838ct85N8XFKLhgR6Uu6FV+5SZk9iRZjDKJlt2pZSoFamc/w5SC6CUAnJ2RVY19Mh1JwNJ69Q5ZEQGjWd0TrVdlsMHGxdEn9MmIhbt8vUpQggSiQsnH+JOnkM3RtV4jjoAsMGaz28UNfUm8qjvGyAXvUlei+aRi29a20iCzcGyWQ2E9PhSjfh9MCF8FjgyfvN9n/9rFDXmat0daTLOq4tJjdG9C+RkFVfF0xgW+X+c/8ydhMqBmiIKFEUZkB4CrPRe6p6i/Q+4seEtDRjE7fGw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1slqgw-0002yR-EU for bug-gnu-emacs@gnu.org; Wed, 04 Sep 2024 10:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Sep 2024 14:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69097 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 69097-submit@debbugs.gnu.org id=B69097.172545893411408 (code B ref 69097); Wed, 04 Sep 2024 14:09:02 +0000 Original-Received: (at 69097) by debbugs.gnu.org; 4 Sep 2024 14:08:54 +0000 Original-Received: from localhost ([127.0.0.1]:35080 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slqgn-0002xu-Po for submit@debbugs.gnu.org; Wed, 04 Sep 2024 10:08:54 -0400 Original-Received: from sendmail.purelymail.com ([34.202.193.197]:37754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slqgl-0002xa-Cb for 69097@debbugs.gnu.org; Wed, 04 Sep 2024 10:08:52 -0400 DKIM-Signature: a=rsa-sha256; b=Z8zOatKTcZdP4u0w5VAMsJHsge3NJoFNiFffi2Tb6k9wnUwB4OhV0SJP4grFbF/SSwI2G3Qf4LfSEzv+3AQFSZ2b+g6aFzunhsuVrQP/xiTpTINsDL+4x18WSctiugvGh8nf8Rjk+qEVHI5mWX/A9Pe/KbOPYet5PXL4LvuYBLnuPV07MXHfp7YlRFXY0+M1Tf6Qty409mzi1PoCDvh1jqC2p1knJAdinYiJlbtxY6qgGya15M80efy2QUMjIJdzlkaoKszKMAkVc2LtMUOUMVSOp87CEnNh4jeO5SDmsxDFEt6RKIhDGROl1EHRqN0W5FPs0Nzxjs7ySC7KhF457w==; s=purelymail1; d=spwhitton.name; v=1; bh=QKQQx9lOjTz1gLQ/R0hpWqGcL1jsa1koXE647j1bHAE=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=Us+M9EwqC9YHHRJwq1PxVZ+8wBi+/2JFLD6vMA0RwGCf0roKoL84cc+9WLnJA2ZrjKCV2erYDsFu1d4BT/uxQdyCEs+1RIV4l5V9knH4YKV4tT+na2r6vyYLkzOIZgKLZ05irhXKuVWomzpQq50HSkwjRsZ1ey69GZYFZ+D3xCziwvFJ7L146Oog0JRRZ7ZS4yg8QcwzQwSmu9+W/eWNQrpsx6i/cov8pxGTnUY2XR0Mq6Us/y94eNuVlDWARXgAdQ/hT3LDeeuNpiUvhhuZml02xjV7tSU6p07yU9NI9MudfzTSIgyL+KJVhwDyaqMi8XuE0S6nFAbEG3TD9I5v/g==; s=purelymail1; d=purelymail.com; v=1; bh=QKQQx9lOjTz1gLQ/R0hpWqGcL1jsa1koXE647j1bHAE=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 69097@debbugs.gnu.org Original-Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -1736106325; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 04 Sep 2024 14:07:09 +0000 (UTC) Original-Received: by zephyr.silentflame.com (Postfix, from userid 1000) id 0A165949A07; Wed, 4 Sep 2024 15:07:08 +0100 (BST) In-Reply-To: <877cbshf4h.fsf@posteo.net> (Philip Kaludercic's message of "Tue, 03 Sep 2024 16:32:46 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291205 Archived-At: 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