aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/emacs/mark.texi4
-rw-r--r--doc/lispref/markers.texi18
-rw-r--r--lisp/delsel.el36
3 files changed, 49 insertions, 9 deletions
diff --git a/doc/emacs/mark.texi b/doc/emacs/mark.texi
index 28b4e3ddaea..98980d5fb3f 100644
--- a/doc/emacs/mark.texi
+++ b/doc/emacs/mark.texi
@@ -288,7 +288,9 @@ instead signal an error if the mark is inactive.
288active---for example, typing @kbd{a} inserts the character @samp{a}, 288active---for example, typing @kbd{a} inserts the character @samp{a},
289then deactivates the mark. If you enable Delete Selection mode, a 289then deactivates the mark. If you enable Delete Selection mode, a
290minor mode, then inserting text while the mark is active causes the 290minor mode, then inserting text while the mark is active causes the
291text in the region to be deleted first. To toggle Delete Selection 291text in the region to be deleted first. Also, commands that normally
292delete just one character, such as @kbd{C-d} or @kbd{@key{DEL}}, will
293delete the entire region instead. To toggle Delete Selection
292mode on or off, type @kbd{M-x delete-selection-mode}. 294mode on or off, type @kbd{M-x delete-selection-mode}.
293 295
294@node Mark Ring 296@node Mark Ring
diff --git a/doc/lispref/markers.texi b/doc/lispref/markers.texi
index d44085527a9..bf185431384 100644
--- a/doc/lispref/markers.texi
+++ b/doc/lispref/markers.texi
@@ -659,6 +659,24 @@ more marks than this are pushed onto the @code{mark-ring},
659@c There is also global-mark-ring-max, but this chapter explicitly 659@c There is also global-mark-ring-max, but this chapter explicitly
660@c does not talk about the global mark. 660@c does not talk about the global mark.
661 661
662@cindex @code{delete-selection}, symbol property
663@findex delete-selection-helper
664@findex delete-selection-pre-hook
665When Delete Selection mode (@pxref{Using Region, Delete Selection, ,
666emacs, The GNU Emacs Manual}) is enabled, commands that operate on the
667active region (a.k.a.@: ``selection'') behave slightly differently.
668This works by adding the function @code{delete-selection-pre-hook} to
669the @code{pre-command-hook} (@pxref{Command Overview}). That function
670calls @code{delete-selection-helper} to delete the selection as
671appropriate for the command. If you want to adapt a command to Delete
672Selection mode, put the @code{delete-selection} property on the
673function's symbol (@pxref{Symbol Plists}); commands that don't have
674this property on their symbol won't delete the selection. This
675property can have one of several values to tailor the behavior to what
676the command is supposed to do; see the doc strings of
677@code{delete-selection-pre-hook} and @code{delete-selection-helper}
678for the details.
679
662@node The Region 680@node The Region
663@section The Region 681@section The Region
664@c The index entry must be just "region" to make it the first hit 682@c The index entry must be just "region" to make it the first hit
diff --git a/lisp/delsel.el b/lisp/delsel.el
index 46eea973a70..6a819ebbf67 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -37,16 +37,26 @@
37;; the values: 37;; the values:
38;; `yank' 38;; `yank'
39;; For commands which do a yank; ensures the region about to be 39;; For commands which do a yank; ensures the region about to be
40;; deleted isn't yanked. 40;; deleted isn't immediately yanked back, which would make the
41;; command a no-op.
41;; `supersede' 42;; `supersede'
42;; Delete the active region and ignore the current command, 43;; Delete the active region and ignore the current command,
43;; i.e. the command will just delete the region. 44;; i.e. the command will just delete the region. This is for
45;; commands that normally delete small amounts of text, like
46;; a single character -- they will instead delete the whole
47;; active region.
48;; `kill'
49;; `kill-region' is used on the selection, rather than
50;; `delete-region'. (Text selected with the mouse will typically
51;; be yankable anyhow.)
44;; t 52;; t
45;; The normal case: delete the active region prior to executing 53;; The normal case: delete the active region prior to executing
46;; the command which will insert replacement text. 54;; the command which will insert replacement text.
47;; <function> 55;; FUNCTION
48;; For commands which need to dynamically determine this behavior. 56;; For commands which need to dynamically determine this behavior.
49;; The function should return one of the above values or nil. 57;; FUNCTION should take no argument and return one of the above
58;; values, or nil. In the latter case, FUNCTION should itself
59;; do with the active region whatever is appropriate."
50 60
51;;; Code: 61;;; Code:
52 62
@@ -66,7 +76,11 @@ enable the mode if ARG is omitted or nil.
66 76
67When Delete Selection mode is enabled, typed text replaces the selection 77When Delete Selection mode is enabled, typed text replaces the selection
68if the selection is active. Otherwise, typed text is just inserted at 78if the selection is active. Otherwise, typed text is just inserted at
69point regardless of any selection." 79point regardless of any selection. Also, commands that normally delete
80just one character will delete the entire selection instead.
81
82See `delete-selection-helper' and `delete-selection-pre-hook' for
83information on adapting behavior of commands in Delete Selection mode."
70 :global t :group 'editing-basics 84 :global t :group 'editing-basics
71 (if (not delete-selection-mode) 85 (if (not delete-selection-mode)
72 (remove-hook 'pre-command-hook 'delete-selection-pre-hook) 86 (remove-hook 'pre-command-hook 'delete-selection-pre-hook)
@@ -147,10 +161,14 @@ With ARG, repeat that many times. `C-u' means until end of buffer."
147 "Delete selection according to TYPE: 161 "Delete selection according to TYPE:
148 `yank' 162 `yank'
149 For commands which do a yank; ensures the region about to be 163 For commands which do a yank; ensures the region about to be
150 deleted isn't yanked. 164 deleted isn't immediately yanked back, which would make the
165 command a no-op.
151 `supersede' 166 `supersede'
152 Delete the active region and ignore the current command, 167 Delete the active region and ignore the current command,
153 i.e. the command will just delete the region. 168 i.e. the command will just delete the region. This is for
169 commands that normally delete small amounts of text, like
170 a single character -- they will instead delete the whole
171 active region.
154 `kill' 172 `kill'
155 `kill-region' is used on the selection, rather than 173 `kill-region' is used on the selection, rather than
156 `delete-region'. (Text selected with the mouse will typically 174 `delete-region'. (Text selected with the mouse will typically
@@ -160,7 +178,9 @@ With ARG, repeat that many times. `C-u' means until end of buffer."
160 the command which will insert replacement text. 178 the command which will insert replacement text.
161 FUNCTION 179 FUNCTION
162 For commands which need to dynamically determine this behavior. 180 For commands which need to dynamically determine this behavior.
163 FUNCTION should take no argument and return one of the above values or nil." 181 FUNCTION should take no argument and return one of the above
182 values, or nil. In the latter case, FUNCTION should itself
183 do with the active region whatever is appropriate."
164 (condition-case data 184 (condition-case data
165 (cond ((eq type 'kill) ;Deprecated, backward compatibility. 185 (cond ((eq type 'kill) ;Deprecated, backward compatibility.
166 (delete-active-region t) 186 (delete-active-region t)