all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Visuwesh <visuweshm@gmail.com>, Eli Zaretskii <eliz@gnu.org>
Cc: "55692@debbugs.gnu.org" <55692@debbugs.gnu.org>
Subject: bug#55692: 29.0.50; delete-selection-mode: Replace region only if set using the mouse
Date: Tue, 31 May 2022 14:33:40 +0000	[thread overview]
Message-ID: <SJ0PR10MB54887C0205A51EC872A981FBF3DC9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87v8tmouag.fsf@gmail.com>

This has long been the text in the manual: 

>        By default, text insertion occurs normally even if the mark is
>     active—for example, typing ‘a’ inserts the character ‘a’, then
>     deactivates the mark.  Delete Selection mode, a minor mode,
>     modifies
>     this behavior: if you enable that mode, then inserting text while
>     the mark is active causes the text in the region to be deleted first.

But this, or similar, is apparently being added now:

>     However, you can tune this behavior by customizing the
>     ‘delete-selection-temporary-region’ option.  Its default value is
>     ‘nil’, but you can set it to ‘t’, in which case only temporarily-active
>     regions
>     will be replaced: those which are set by dragging the mouse (*note
>     Setting Mark) or by shift-selection (*note Shift Selection), as
>     well as by ‘C-u C-x C-x’ when Transient Mark Mode is disabled.  You can
>     further tune the behavior by setting ‘delete-selection-temporary-
>     region’
>     to ‘selection’: then temporary regions by ‘C-u C-x C-x’ won’t be
>     replaced, only the ones activated by dragging the mouse or
>     shift-selection.  To toggle Delete Selection mode on or off, type
>     ‘M-x delete-selection-mode’.

FWIW, I disagree with this doc change.

If you're going to do something like that (let
alone say _more_ about this minor new feature than
about `delete-selection-mode' itself), then at
least tell users about the _real_ way to customize
d-s-mode - the part that's _basic_ to its design
and purpose.

I'm talking about the fact that d-s-mode does _not_
just replace selected text - even by _default_ for
some commands.

The design of d-s-mode - its features that are
useful for both end users and Lisp coders - isn't
even hinted at in the doc.

What is that design?  The mode behaves differently
for different commands.  Both by default and by
easy-peasy customization.

The doc says nothing about this, and yet it's so
simple, general, elegant, and powerful.  Just put
the kind of action you want on a command symbol
as property `delete-selection'.  There are basic,
predefined actions, and you can define any other
action you like.

From the delsel.el Commentary - which is the real
doc, IMO:

;; Commands which will delete the selection need a 'delete-selection
;; property on their symbols; commands which insert text but don't
;; have this property won't delete the selection.  It can be one of
;; the values:
;;
;;  `yank'
;;      For commands which do a yank; ensures the region about to be
;;      deleted isn't immediately yanked back, which would make the
;;      command a no-op.
;;  `supersede'
;;      Delete the active region and ignore the current command,
;;      i.e. the command will just delete the region.  This is for
;;      commands that normally delete small amounts of text, like
;;      a single character -- they will instead delete the whole
;;      active region.
;;  `kill'
;;      `kill-region' is used on the selection, rather than
;;      `delete-region'.  (Text selected with the mouse will typically
;;      be yankable anyhow.)
;;  t
;;      The normal case: delete the active region prior to executing
;;      the command which will insert replacement text.
;;  FUNCTION
;;      For commands which need to dynamically determine this behavior.
;;      FUNCTION should take no argument and return one of the above
;;      values, or nil.  In the latter case, FUNCTION should itself
;;      do with the active region whatever is appropriate."

Note the first sentence, BTW.  You don't get _any_
`delete-selection-mode' behavior at all for a
command unless it has property `delete-selection'.

Yes, most insertion of regular text falls into the
default case.  And yes, that's the main idea behind
the mode.  But that's not a reason for the manual
to speak _only_ of that behavior.  d-s-mode doesn't
have as its aim only to replicate behavior that you
might be used to outside Emacs.

If you're going to start mentioning non-replacement
behavior, please prioritize the basic design of
d-s-mode, not the changes proposed in this thread.

Mention the latter if you like, but please don't
overwhelm the description of d-s-mode itself, and
(especially) please prioritize its essential means
of customization - the basic design.

Emphasize what's important.  The proposed new
feature isn't what's important about being able to
"tune this behavior".  Not IMO.

  reply	other threads:[~2022-05-31 14:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-28 17:33 bug#55692: 29.0.50; delete-selection-mode: Replace region only if set using the mouse Visuwesh
2022-05-28 19:10 ` 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 [this message]
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=SJ0PR10MB54887C0205A51EC872A981FBF3DC9@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=55692@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=visuweshm@gmail.com \
    /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.