diff options
| author | Eli Zaretskii | 2017-11-24 12:49:04 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2017-11-24 12:49:04 +0200 |
| commit | eea4e9194c209770dceb55b4853451da25da4ea5 (patch) | |
| tree | 16b07073153c4e2a5a3d9b530fd4cb7b28f06458 /lisp | |
| parent | e6e41dac879d2e9b63c2a5dd700a9d88d8065e4d (diff) | |
| download | emacs-eea4e9194c209770dceb55b4853451da25da4ea5.tar.gz emacs-eea4e9194c209770dceb55b4853451da25da4ea5.zip | |
Improve documentation of self-insert-uses-region-functions
* lisp/simple.el (self-insert-uses-region-functions): Clarify the
doc string.
* lisp/delsel.el (delete-selection-uses-region-p): Mention
'self-insert-command' in the doc string. (Bug#29373)
* doc/lispref/text.texi (Commands for Insertion): Mention
'self-insert-uses-region-functions'.
* doc/lispref/modes.texi (Keymaps and Minor Modes): Add a
cross-reference to "Commands for Insertion".
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/delsel.el | 12 | ||||
| -rw-r--r-- | lisp/simple.el | 15 |
2 files changed, 21 insertions, 6 deletions
diff --git a/lisp/delsel.el b/lisp/delsel.el index 17b46efc7cb..65b2cb85cea 100644 --- a/lisp/delsel.el +++ b/lisp/delsel.el | |||
| @@ -256,12 +256,18 @@ See `delete-selection-helper'." | |||
| 256 | (get this-command 'delete-selection))))) | 256 | (get this-command 'delete-selection))))) |
| 257 | 257 | ||
| 258 | (defun delete-selection-uses-region-p () | 258 | (defun delete-selection-uses-region-p () |
| 259 | "Return t when the current command will be using the region | 259 | "Return t when `delete-selection-mode' should not delete the region. |
| 260 | rather than having `delete-selection' delete it, nil otherwise. | 260 | |
| 261 | The `self-insert-command' could be the current command or may be | ||
| 262 | called by the current command. If this function returns nil, | ||
| 263 | then `delete-selection' is allowed to delete the region. | ||
| 261 | 264 | ||
| 262 | This function is intended for use as the value of the | 265 | This function is intended for use as the value of the |
| 263 | `delete-selection' property of a command, and shouldn't be used | 266 | `delete-selection' property of a command, and shouldn't be used |
| 264 | for anything else." | 267 | for anything else. In particular, `self-insert-command' has this |
| 268 | function as its `delete-selection' property, so that \"electric\" | ||
| 269 | self-insert commands that act on the region could adapt themselves | ||
| 270 | to `delete-selection-mode'." | ||
| 265 | (not (run-hook-with-args-until-success | 271 | (not (run-hook-with-args-until-success |
| 266 | 'self-insert-uses-region-functions))) | 272 | 'self-insert-uses-region-functions))) |
| 267 | 273 | ||
diff --git a/lisp/simple.el b/lisp/simple.el index 7d47d0f8645..d629fb66599 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -401,9 +401,18 @@ Other major modes are defined by comparison with this one." | |||
| 401 | (defvar self-insert-uses-region-functions nil | 401 | (defvar self-insert-uses-region-functions nil |
| 402 | "Special hook to tell if `self-insert-command' will use the region. | 402 | "Special hook to tell if `self-insert-command' will use the region. |
| 403 | It must be called via `run-hook-with-args-until-success' with no arguments. | 403 | It must be called via `run-hook-with-args-until-success' with no arguments. |
| 404 | Any `post-self-insert-command' which consumes the region should | 404 | |
| 405 | register a function on this hook so that things like `delete-selection-mode' | 405 | If any function on this hook returns a non-nil value, `delete-selection-mode' |
| 406 | can refrain from consuming the region.") | 406 | will act on that value (see `delete-selection-helper'), and will |
| 407 | usually delete the region. If all the functions on this hook return | ||
| 408 | nil, it is an indiction that `self-insert-command' needs the region | ||
| 409 | untouched by `delete-selection-mode', and will itself do whatever is | ||
| 410 | appropriate with the region. | ||
| 411 | Any function on `post-self-insert-hook' which act on the region should | ||
| 412 | add a function to this hook so that `delete-selection-mode' could | ||
| 413 | refrain from deleting the region before `post-self-insert-hook' | ||
| 414 | functions are called. | ||
| 415 | This hook is run by `delete-selection-uses-region-p', which see.") | ||
| 407 | 416 | ||
| 408 | (defvar hard-newline (propertize "\n" 'hard t 'rear-nonsticky '(hard)) | 417 | (defvar hard-newline (propertize "\n" 'hard t 'rear-nonsticky '(hard)) |
| 409 | "Propertized string representing a hard newline character.") | 418 | "Propertized string representing a hard newline character.") |