]> code.delx.au - gnu-emacs/blobdiff - lisp/delsel.el
*** empty log message ***
[gnu-emacs] / lisp / delsel.el
index 09b30d3e874bfaeaefcd37b90f4e4c75fe1f5be3..6427c39eecb4cd149e03e7ecece06faa58ecbcd2 100644 (file)
@@ -1,7 +1,7 @@
 ;;; 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
@@ -12,7 +12,7 @@
 
 ;; 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,
@@ -35,7 +35,7 @@
 
 ;; 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
@@ -59,8 +59,8 @@
 ;;;###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
@@ -89,14 +89,12 @@ any selection."
                ((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)
@@ -149,14 +147,19 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
 (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)