;;; delsel.el --- delete selection if you insert
;; Copyright (C) 1992, 1997, 1998, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007 Free Software Foundation, Inc.
+;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Author: Matthieu Devin <devin@lucid.com>
;; Maintainer: FSF
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; Commands which will delete the selection need a 'delete-selection
;; property on their symbols; commands which insert text but don't
-;; have this property won't delete the selction. It can be one of
+;; 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
;;;###autoload
(define-minor-mode delete-selection-mode
"Toggle Delete Selection mode.
-With prefix ARG, turn Delete Selection mode on if and only if ARG is
-positive.
+With prefix ARG, turn Delete Selection mode on if ARG is
+positive, off if ARG is not positive.
When Delete Selection mode is enabled, Transient Mark mode is also
enabled and typed text replaces the selection if the selection is
((eq type 'yank)
;; Before a yank command, make sure we don't yank the
;; head of the kill-ring that really comes from the
- ;; currently active region we are going to delete
- ;; (when last-command is one that uses copy-region-as-kill
- ;; or kill-new). That would make yank a no-op.
+ ;; currently active region we are going to delete.
+ ;; That would make yank a no-op.
(when (and (string= (buffer-substring-no-properties (point) (mark))
(car kill-ring))
- (memq last-command
- '(mouse-set-region mouse-drag-region
- mouse-save-then-kill mouse-secondary-save-then-kill)))
+ (fboundp 'mouse-region-match)
+ (mouse-region-match))
(current-kill 1))
(delete-active-region))
((eq type 'supersede)
(define-key minibuffer-local-must-match-map "\C-g" 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map "\C-g" 'minibuffer-keyboard-quit)
-(defun delsel-unload-hook ()
+(defun delsel-unload-function ()
+ "Unload the Delete Selection library."
(define-key minibuffer-local-map "\C-g" 'abort-recursive-edit)
(define-key minibuffer-local-ns-map "\C-g" 'abort-recursive-edit)
(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))
-
-(add-hook 'delsel-unload-hook 'delsel-unload-hook)
+ (define-key minibuffer-local-isearch-map "\C-g" 'abort-recursive-edit)
+ (dolist (sym '(self-insert-command self-insert-iso yank clipboard-yank
+ insert-register delete-backward-char backward-delete-char-untabify
+ delete-char newline-and-indent newline open-line))
+ (remprop sym 'delete-selection))
+ ;; continue standard unloading
+ nil)
(provide 'delsel)