unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Eric Abrahamsen <eric@ericabrahamsen.net>, help-gnu-emacs@gnu.org
Subject: RE: Another Emacs incompatibilty
Date: Tue, 18 Aug 2020 08:47:50 -0700 (PDT)	[thread overview]
Message-ID: <2a7d658b-972c-46e0-b893-af8c236da401@default> (raw)
In-Reply-To: <875z9gg5qm.fsf@ericabrahamsen.net>

> Almost by coincidence, I just discovered `delete-selection-mode', which
> does the same thing. I also don't understand the utility of this, but
> apparently it's useful enough to have been implemented twice! Neither
> should be active by default, though.

Some of us think that `delete-selection-mode'
should be enabled by default - and that this
is long overdue.

FYI, a similar debate took place for
`transient-mark-mode'.  It took _decades_ to
finally get that turned on by default.

Maybe you can't imagine t-m-mode being off by
default.  Try it.  ;-)  There are some good
arguments for that behavior, as there are
against it.

I argued then to turn on t-m-mode by default.
And I argued (and still do) to also turn on
`delete-selection-mode' by default.

`delete-selection-mode' is a common behavior
outside Emacs: just-select-and-type-to-replace.
The default Emacs behavior makes you use `C-w'
first.

But d-s-mode also lets users and libraries easily
_control_ just which commands (actions) delete
selected text, which ones kill it, which ones do
neither, which ones are yanks (to not then yank
the text to be deleted), whether to also perform
the command's normal action, or whether to do
something else altogether.

Here's the relevant part of the `delsel.el'
Commentary:

;; Commands which will delete the selection need a `delete-selection'
                                                  ^
                                              [non-nil]
;; 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."

That's the Emacs way: a general, default behavior,
but also user/code control over it.  You can get
whatever behavior you want for a given command.
The command gets to decide what it does with the
active region.  (That means you get to decide.)

 (put 'my-command 'delete-selection nil) ; Ignore d-s-mode.



  parent reply	other threads:[~2020-08-18 15:47 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-16 20:57 Another Emacs incompatibilty Torbjörn Granlund
2020-08-16 21:17 ` Stefan Monnier
2020-08-16 23:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-17  8:12 ` On the rate of change [was: Another Emacs incompatibilty] tomas
2020-08-17 14:21   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-17 15:20     ` tomas
2020-08-17 17:44       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-17 15:14 ` Another Emacs incompatibilty Torbjörn Granlund
2020-08-17 15:54   ` Robert Pluim
2020-08-17 16:08   ` Eli Zaretskii
2020-08-17 20:16     ` Torbjörn Granlund
2020-08-17 20:42       ` Stefan Monnier
2020-08-17 21:22         ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-17 22:00         ` Gregory Heytings via Users list for the GNU Emacs text editor
2020-08-17 22:18         ` Eric Abrahamsen
2020-08-17 23:00           ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-18  0:25             ` Eric Abrahamsen
2020-08-18  4:16               ` Stefan Monnier
2020-08-18  4:47               ` Eli Zaretskii
2020-08-18  5:27                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-18  5:36                   ` Eli Zaretskii
2020-08-23 20:10                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-24  6:43                       ` Alan Davis
2020-08-24  6:55                         ` Eli Zaretskii
2020-08-24 23:21                           ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-24 14:31                         ` Drew Adams
2020-08-24 23:24                           ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-25  0:53                             ` Alan Davis
2020-08-25  4:09                             ` Drew Adams
2020-08-25  4:14                               ` Drew Adams
2020-08-25  4:30                               ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-25  5:04                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-25  5:46                                 ` Drew Adams
2020-08-25  6:07                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-25  5:51                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-24 15:31                         ` Stefan Monnier
2020-08-24 23:14                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-18 15:47               ` Drew Adams [this message]
2020-08-18 16:45                 ` Eric Abrahamsen
2020-08-18 16:52                   ` Drew Adams
2020-08-18 17:50                     ` Eric Abrahamsen
2020-08-18 17:10                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-17 16:31   ` Gregory Heytings via Users list for the GNU Emacs text editor
2020-08-17 16:49     ` Perry Smith
2020-08-17 16:54       ` Gregory Heytings via Users list for the GNU Emacs text editor
2020-08-17 17:22         ` Eli Zaretskii
2020-08-17 17:28         ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-17 17:11       ` Eli Zaretskii
2020-08-17 17:16   ` Emanuel Berg via Users list for the GNU Emacs text editor

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a7d658b-972c-46e0-b893-af8c236da401@default \
    --to=drew.adams@oracle.com \
    --cc=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).