4

(I'm using Emacs for more than 25 years, starting in version 18.58 I think)

Recently Emacs received changes that make an old-time user quite desperate, and I wonder how to revert some of those dubious "enhancements":

When I set a mark, copy and paste the region, and then want to edit the region (frequently I press C-x C-x to place the mark at the start of the pasted region, then move the cursor and try to replace some text, maybe using backspace or delete), it happened more than once (without me noticing it all the time) that as soon as I edit the pasted region that the whole region is replaced by the character input. This is especially dangerous if you duplicate a longer block of text: Recently I modified the only copy of it instead of modifying the duplicate.

So which customization setting is responsible for this? I'm using Emacs 25.3.

(The other "enhancement" I was able to fix myself was that next-line moved down to the next screen line instead of the next buffer line)

Here's an attempt for a reproducable example:

 C-u [universal-argument]
 7 [digit-argument]
 2 [digit-argument]
 a [self-insert-command]
 <return> [newline]
 C-u [universal-argument]
 7 [digit-argument]
 2 [digit-argument]
 b [self-insert-command]
 <return> [newline]
 <up> [previous-line]
 <up> [previous-line]
 C-SPC [set-mark-command]
 <down> [next-line]
 <down> [next-line]
 M-w [kill-ring-save]
 C-y [yank]
 C-y [yank]
 <up> [previous-line]
 <up> [previous-line]
 <up> [previous-line]
 <up> [previous-line]
 C-SPC [set-mark-command]
 <down> [next-line]
 <down> [next-line]
 M-w [kill-ring-save]
 <up> [previous-line]
 <up> [previous-line]
 C-y [yank]
 C-x C-x [exchange-point-and-mark]
 <right> [right-char]
 <right> [right-char]
 <right> [right-char]
 <right> [right-char]
 <right> [right-char]
 <backspace> [backward-delete-char-untabify]

The first backspace kills the whole region.

10
  • 2
    This sounds like the effects of delete-active-region, although that only functions for 'deleting' commands
    – rpluim
    Nov 21, 2019 at 17:01
  • 1
    Can you reproduce from Emacs -Q? What's the version of your Emacs? Not sure if I understand your question, maybe you accidentally enabled delete-selection-mode? this mode is off by default.
    – xuchunyang
    Nov 21, 2019 at 17:02
  • Sounds like something or someone turned on delete-selection-mode. Please check that you see the same problem when starting Emacs using emacs -Q (no init file). A guess is that you've initiated some mode, or loaded some code, that turns on delete-selection-mode.
    – Drew
    Nov 22, 2019 at 20:55
  • 1
    I just tried in Emacs 25.3 and likewise cannot reproduce this issue. Are you able to provide a recipe for demonstrating the problem, starting from emacs -Q ?
    – phils
    Nov 23, 2019 at 0:03
  • 1
    If you see the problem with emacs -Q, and others don't, then I suspect you have not described the recipe to reproduce it clearly enough. Maybe try breaking it down into baby steps, with a concrete example.
    – Drew
    Nov 23, 2019 at 2:34

1 Answer 1

4

The first backspace kills the whole region.

You'll want to set delete-active-region to nil (it was introduced in 24.1).

delete-backward-char is an interactive compiled Lisp function in ‘simple.el’.
[...]
If Transient Mark mode is enabled, the mark is active, and N is 1,
delete the text in the region and deactivate the mark instead.
To disable this, set option ‘delete-active-region’ to nil.
delete-active-region is a variable defined in ‘simple.el’.
Its value is t

Documentation:
Whether single-char deletion commands delete an active region.
This has an effect only if Transient Mark mode is enabled, and
affects ‘delete-forward-char’ and ‘delete-backward-char’, though
not ‘delete-char’.

If the value is the symbol ‘kill’, the active region is killed
instead of deleted.

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 24.1 of Emacs.

(The other "enhancement" I was able to fix myself was that next-line moved down to the next screen line instead of the next buffer line)

By the way, the intended customization for this is line-move-visual.

line-move-visual is a variable defined in ‘simple.el’.
Its value is t

Documentation:
When non-nil, ‘line-move’ moves point by visual lines.
This movement is based on where the cursor is displayed on the
screen, instead of relying on buffer contents alone.  It takes
into account variable-width characters and line continuation.
If nil, ‘line-move’ moves point by logical lines.
A non-nil setting of ‘goal-column’ overrides the value of this variable
and forces movement by logical lines.
A window that is  horizontally scrolled also forces movement by logical
lines.

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 23.1 of Emacs.
1
  • 2
    transient-mark-mode was set to t (STANDARD). When toggling it, there is no marked region displayed any more, nd delete does not zap away the region any more. Setting delete-active-region to nil while restoring the default of transient-mark-mode still shows the region, but does not zap it when deleting a character inside. This is the setting I feel happy with.
    – U. Windl
    Nov 25, 2019 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.