diff options
author | Alan Mackenzie <acm@muc.de> | 2015-08-19 16:47:10 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2015-08-19 16:47:10 +0000 |
commit | 82a3da21ffece64ce9f4f99f35cbc0afe851e6ee (patch) | |
tree | 3e994ddb89d7014701323f28813097284d3ff266 /lisp/delsel.el | |
parent | ec07cfbee12528b9800a8c8fa019af72e3c9cfe4 (diff) | |
download | emacs-82a3da21ffece64ce9f4f99f35cbc0afe851e6ee.tar.gz |
Make electric-pair-mode, delete-selection-mode and CC Mode cooperate.
Fixes debbugs#21275.
In Emacs >= 25, let electric-pair-mode take precedence over
delete-selection-mode.
delsel.el (delete-selection-uses-region-p): New function, previously a
lambda expression in a property value for `self-insert-command'.
(top-level) Set the `delete-selection' property of `self-insert-command'
to `delete-selection-uses-region-p'.
progmodes/cc-cmds.el (top-level): Give the `delete-selection' property
for c-electric-\(brace\|paren\) the value `delete-selection-uses-region-p'
when the latter function exists.
Diffstat (limited to 'lisp/delsel.el')
-rw-r--r-- | lisp/delsel.el | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/delsel.el b/lisp/delsel.el index 740b60345ed..586c130020b 100644 --- a/lisp/delsel.el +++ b/lisp/delsel.el @@ -231,10 +231,17 @@ See `delete-selection-helper'." (delete-selection-helper (and (symbolp this-command) (get this-command 'delete-selection))))) -(put 'self-insert-command 'delete-selection - (lambda () - (not (run-hook-with-args-until-success - 'self-insert-uses-region-functions)))) +(defun delete-selection-uses-region-p () + "Return t when the current command will be using the region +rather than having `delete-selection' delete it, nil otherwise. + +This function is intended for use as the value of the +`delete-selection' property of a command, and shouldn't be used +for anything else." + (not (run-hook-with-args-until-success + 'self-insert-uses-region-functions))) + +(put 'self-insert-command 'delete-selection 'delete-selection-uses-region-p) (put 'insert-char 'delete-selection t) (put 'quoted-insert 'delete-selection t) |