help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Another Emacs incompatibilty


From: Drew Adams
Subject: RE: Another Emacs incompatibilty
Date: Tue, 18 Aug 2020 08:47:50 -0700 (PDT)

> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]