GNU bug report logs -
#13312
24.3.50; delete selection mode not killing on overwrite
Previous Next
Reported by: Tony Day <tonyday567 <at> gmail.com>
Date: Mon, 31 Dec 2012 01:14:01 UTC
Severity: wishlist
Tags: moreinfo
Found in versions 24.1, 24.3.50
Fixed in version 24.4
Done: Juri Linkov <juri <at> jurta.org>
Bug is archived. No further changes may be made.
Full log
Message #30 received at 13312 <at> debbugs.gnu.org (full text, mbox):
> Did you read the bug description and the associate StackOverflow
> question? The bug is that when you put `kill' as the
> `delete-selection' property value on `self-insert-command' the
> region is not killed - it is not added to the `kill-ring'.
Ah, I thought this is a new bug report from you. But I still
can't find a link to the associate StackOverflow question.
What I wanted to suggest is to add more self-inserting commands
to delsel like `insert-char' and `quoted-insert'. I guess
they don't need the same `self-insert-uses-region-functions'
like the currently existing `self-insert-iso' doesn't use that.
But when you want put `kill' as the `delete-selection' property
then it's better to use this code:
(put 'self-insert-command 'delete-selection
(lambda ()
(and (not (run-hook-with-args-until-success
'self-insert-uses-region-functions))
'kill)))
It currently doesn't work properly because `kill-region' overwrites
the value of `this-command'. This is a bug that can be fixed
by this patch that also fixes overwrite-mode for `kill' and
puts `delete-selection' on more commands:
=== modified file 'lisp/delsel.el'
--- lisp/delsel.el 2013-01-01 09:11:05 +0000
+++ lisp/delsel.el 2013-10-19 16:24:16 +0000
@@ -78,7 +78,9 @@ (defun delete-active-region (&optional k
"Delete the active region.
If KILLP in not-nil, the active region is killed instead of deleted."
(if killp
- (kill-region (point) (mark))
+ ;; Prevent `kill-region' from changing the value of `this-command'.
+ (let (this-command)
+ (kill-region (point) (mark)))
(delete-region (point) (mark)))
t)
@@ -102,7 +104,13 @@ (defun delete-selection-helper (type)
FUNCTION should take no argument and return one of the above values or nil."
(condition-case data
(cond ((eq type 'kill)
- (delete-active-region t))
+ (delete-active-region t)
+ (if (and overwrite-mode
+ (eq this-command 'self-insert-command))
+ (let ((overwrite-mode nil))
+ (self-insert-command
+ (prefix-numeric-value current-prefix-arg))
+ (setq this-command 'ignore))))
((eq type 'yank)
;; Before a yank command, make sure we don't yank the
;; head of the kill-ring that really comes from the
@@ -166,6 +174,8 @@ (put 'self-insert-command 'delete-select
'self-insert-uses-region-functions))))
(put 'self-insert-iso 'delete-selection t)
+(put 'insert-char 'delete-selection t)
+(put 'quoted-insert 'delete-selection t)
(put 'yank 'delete-selection 'yank)
(put 'clipboard-yank 'delete-selection 'yank)
@@ -175,6 +185,7 @@ (put 'delete-backward-char 'delete-selec
(put 'backward-delete-char-untabify 'delete-selection 'supersede)
(put 'delete-char 'delete-selection 'supersede)
+(put 'reindent-then-newline-and-indent 'delete-selection t)
(put 'newline-and-indent 'delete-selection t)
(put 'newline 'delete-selection t)
(put 'open-line 'delete-selection 'kill)
@@ -203,9 +214,9 @@ (defun delsel-unload-function ()
(define-key minibuffer-local-completion-map "\C-g" 'abort-recursive-edit)
(define-key minibuffer-local-must-match-map "\C-g" 'abort-recursive-edit)
(define-key minibuffer-local-isearch-map "\C-g" 'abort-recursive-edit)
- (dolist (sym '(self-insert-command self-insert-iso yank clipboard-yank
+ (dolist (sym '(self-insert-command self-insert-iso insert-char quoted-insert yank clipboard-yank
insert-register delete-backward-char backward-delete-char-untabify
- delete-char newline-and-indent newline open-line))
+ delete-char reindent-then-newline-and-indent newline-and-indent newline open-line))
(put sym 'delete-selection nil))
;; continue standard unloading
nil)
This bug report was last modified 11 years and 261 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.