emacs-pretest-bug
[Top][All Lists]
Advanced

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

delete-selection-mode and overwrite-mode


From: Juri Linkov
Subject: delete-selection-mode and overwrite-mode
Date: Wed, 10 Aug 2005 12:19:43 +0300
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

After typing a character on a selected region with both
delete-selection-mode and overwrite-mode enabled, it deletes
the character adjacent to the selected region.  This is not what
is expected with these modes.  Instead of that, it should work like
other commands in delete-selection-mode, i.e. to delete only
selected region and nothing more.

For example, if the region `bc' is selected on the line `abcde',
then typing `x' deletes `bc', and also self-insert-command deletes
the next character `d' before inserting `x', thus producing `axe'.
The correct result is `axde' without deleting `d'.

The following patch fixes this by temporarily binding overwrite-mode
to nil before calling self-insert-command explicitly:

Index: lisp/delsel.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/delsel.el,v
retrieving revision 1.35
diff -c -r1.35 delsel.el
*** lisp/delsel.el      6 Aug 2005 22:13:42 -0000       1.35
--- lisp/delsel.el      10 Aug 2005 08:34:31 -0000
***************
*** 101,107 ****
                   (unless empty-region
                     (setq this-command 'ignore))))
                (type
!                (delete-active-region)))
        (file-supersession
         ;; If ask-user-about-supersession-threat signals an error,
         ;; stop safe_run_hooks from clearing out pre-command-hook.
--- 101,111 ----
                   (unless empty-region
                     (setq this-command 'ignore))))
                (type
!                (delete-active-region)
!                (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)))))
        (file-supersession
         ;; If ask-user-about-supersession-threat signals an error,
         ;; stop safe_run_hooks from clearing out pre-command-hook.

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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