aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2000-10-01 00:25:27 +0000
committerStefan Monnier2000-10-01 00:25:27 +0000
commitad03cafc90a13e2bda066cd0274371e369a71ee2 (patch)
tree1016da5eb232d9ce064de60df549aab3df83e415
parent42664031425858d208ce472b0ece0997fdc8c5cf (diff)
downloademacs-ad03cafc90a13e2bda066cd0274371e369a71ee2.tar.gz
emacs-ad03cafc90a13e2bda066cd0274371e369a71ee2.zip
(delete-selection-mode): Use define-minor-mode.
-rw-r--r--lisp/delsel.el26
1 files changed, 2 insertions, 24 deletions
diff --git a/lisp/delsel.el b/lisp/delsel.el
index be13301a1f0..f0749eefe77 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -56,7 +56,7 @@
56(defalias 'pending-delete-mode 'delete-selection-mode) 56(defalias 'pending-delete-mode 'delete-selection-mode)
57 57
58;;;###autoload 58;;;###autoload
59(defun delete-selection-mode (&optional arg) 59(define-minor-mode delete-selection-mode
60 "Toggle Delete Selection mode. 60 "Toggle Delete Selection mode.
61With prefix ARG, turn Delete Selection mode on if and only if ARG is 61With prefix ARG, turn Delete Selection mode on if and only if ARG is
62positive. 62positive.
@@ -65,28 +65,12 @@ When Delete Selection mode is enabled, Transient Mark mode is also
65enabled and typed text replaces the selection if the selection is 65enabled and typed text replaces the selection if the selection is
66active. Otherwise, typed text is just inserted at point regardless of 66active. Otherwise, typed text is just inserted at point regardless of
67any selection." 67any selection."
68 (interactive "P") 68 nil nil nil :global t :group 'editing-basics
69 (setq delete-selection-mode (if arg
70 (> (prefix-numeric-value arg) 0)
71 (not delete-selection-mode)))
72 (if (not delete-selection-mode) 69 (if (not delete-selection-mode)
73 (remove-hook 'pre-command-hook 'delete-selection-pre-hook) 70 (remove-hook 'pre-command-hook 'delete-selection-pre-hook)
74 (add-hook 'pre-command-hook 'delete-selection-pre-hook) 71 (add-hook 'pre-command-hook 'delete-selection-pre-hook)
75 (transient-mark-mode t))) 72 (transient-mark-mode t)))
76 73
77;;;###autoload
78(defcustom delete-selection-mode nil
79 "Toggle Delete Selection mode.
80See command `delete-selection-mode'.
81Setting this variable directly does not take effect;
82use either \\[customize] or the function `delete-selection-mode'."
83 :set (lambda (symbol value)
84 (delete-selection-mode (or value 0)))
85 :initialize 'custom-initialize-default
86 :type 'boolean
87 :group 'editing-basics
88 :require 'delsel)
89
90(defun delete-active-region (&optional killp) 74(defun delete-active-region (&optional killp)
91 (if killp 75 (if killp
92 (kill-region (point) (mark)) 76 (kill-region (point) (mark))
@@ -160,10 +144,4 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
160 144
161(provide 'delsel) 145(provide 'delsel)
162 146
163;; This is the standard way to put the mode into effect
164;; if delete-selection-mode has already been set to t
165;; when this file is loaded.
166(when delete-selection-mode
167 (delete-selection-mode t))
168
169;;; delsel.el ends here 147;;; delsel.el ends here