From: Visuwesh <visuweshm@gmail.com>
To: 55692@debbugs.gnu.org
Subject: bug#55692: 29.0.50; delete-selection-mode: Replace region only if set using the mouse
Date: Sat, 28 May 2022 23:03:51 +0530 [thread overview]
Message-ID: <87zgj1v9xc.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 354 bytes --]
Tags: patch
Motivation: I often find myself annoyed by `delete-selection-mode' when
using the keyboard since the region in Emacs does not translate to text
selections in other applications. On the contrary, I find myself
wanting the behaviour of `delete-selection-mode' for regions set using
the mouse. Attached patch adds an user option to do that.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-delete-selection-mode-Add-user-option-to-delete-mous.patch --]
[-- Type: text/x-patch, Size: 2062 bytes --]
From 3db630457b46bb25514a8041eeb80f35e73ef40c Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
Date: Sat, 28 May 2022 22:52:19 +0530
Subject: [PATCH] delete-selection-mode: Add user option to delete mouse
regions only
* lisp/delsel.el (delete-selection-mouse-selection-only): Add new user option.
(delete-selection-pre-hook): Respect it.
* etc/NEWS: Announce the new user option.
---
etc/NEWS | 4 ++++
lisp/delsel.el | 9 +++++++++
2 files changed, 13 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 3065fa85d3..100be767b3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -265,6 +265,10 @@ startup. Previously, these functions ignored
* Changes in Emacs 29.1
+++
+** New user option 'delete-selection-mouse-selection-only'.
+When non-nil, 'delete-selection-mode' will only delete the active
+region if it was set using the mouse.
+
** New user option 'switch-to-prev-buffer-skip-regexp'.
This should be a regexp or a list of regexps; buffers whose names
match those regexps will be ignored by 'switch-to-prev-buffer' and
diff --git a/lisp/delsel.el b/lisp/delsel.el
index f5fe7cf793..a011be9ede 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -64,6 +64,12 @@ delete-selection-save-to-register
"If non-nil, deleted region text is stored in this register.
Value must be the register (key) to use.")
+(defcustom delete-selection-mouse-selection-only nil
+ "If non-nil, delete the region only if set using the mouse."
+ :version "29.1"
+ :group 'editing-basics
+ :type 'boolean)
+
;;;###autoload
(defalias 'pending-delete-mode 'delete-selection-mode)
@@ -251,6 +257,9 @@ delete-selection-pre-hook
have this property won't delete the selection.
See `delete-selection-helper'."
(when (and delete-selection-mode (use-region-p)
+ (if delete-selection-mouse-selection-only
+ (mouse-region-match)
+ t)
(not buffer-read-only))
(delete-selection-helper (and (symbolp this-command)
(get this-command 'delete-selection)))))
--
2.33.1
next reply other threads:[~2022-05-28 17:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-28 17:33 Visuwesh [this message]
2022-05-28 19:10 ` bug#55692: 29.0.50; delete-selection-mode: Replace region only if set using the mouse Eli Zaretskii
2022-05-29 6:17 ` Visuwesh
2022-05-29 6:52 ` Eli Zaretskii
2022-05-29 8:10 ` Visuwesh
2022-05-29 9:04 ` Eli Zaretskii
2022-05-29 14:53 ` Visuwesh
2022-05-29 17:10 ` Eli Zaretskii
2022-05-31 10:44 ` Visuwesh
2022-05-31 14:33 ` Drew Adams
2022-06-01 16:04 ` Eli Zaretskii
2022-06-01 17:03 ` Visuwesh
2022-09-06 10:59 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zgj1v9xc.fsf@gmail.com \
--to=visuweshm@gmail.com \
--cc=55692@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.