diff options
| -rw-r--r-- | lisp/delsel.el | 15 | ||||
| -rw-r--r-- | lisp/progmodes/cc-cmds.el | 15 |
2 files changed, 23 insertions, 7 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'." | |||
| 231 | (delete-selection-helper (and (symbolp this-command) | 231 | (delete-selection-helper (and (symbolp this-command) |
| 232 | (get this-command 'delete-selection))))) | 232 | (get this-command 'delete-selection))))) |
| 233 | 233 | ||
| 234 | (put 'self-insert-command 'delete-selection | 234 | (defun delete-selection-uses-region-p () |
| 235 | (lambda () | 235 | "Return t when the current command will be using the region |
| 236 | (not (run-hook-with-args-until-success | 236 | rather than having `delete-selection' delete it, nil otherwise. |
| 237 | 'self-insert-uses-region-functions)))) | 237 | |
| 238 | This function is intended for use as the value of the | ||
| 239 | `delete-selection' property of a command, and shouldn't be used | ||
| 240 | for anything else." | ||
| 241 | (not (run-hook-with-args-until-success | ||
| 242 | 'self-insert-uses-region-functions))) | ||
| 243 | |||
| 244 | (put 'self-insert-command 'delete-selection 'delete-selection-uses-region-p) | ||
| 238 | 245 | ||
| 239 | (put 'insert-char 'delete-selection t) | 246 | (put 'insert-char 'delete-selection t) |
| 240 | (put 'quoted-insert 'delete-selection t) | 247 | (put 'quoted-insert 'delete-selection t) |
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index c9f59451b7e..0beaf268a80 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el | |||
| @@ -2853,19 +2853,28 @@ sentence motion in or near comments and multiline strings." | |||
| 2853 | 2853 | ||
| 2854 | ;; set up electric character functions to work with pending-del, | 2854 | ;; set up electric character functions to work with pending-del, |
| 2855 | ;; (a.k.a. delsel) mode. All symbols get the t value except | 2855 | ;; (a.k.a. delsel) mode. All symbols get the t value except |
| 2856 | ;; the functions which delete, which gets 'supersede. | 2856 | ;; the functions which delete, which gets 'supersede, and (from Emacs |
| 2857 | ;; 25) `c-electric-brace' and `c-electric-paren' get special handling | ||
| 2858 | ;; so as to work gracefully with `electric-pair-mode'. | ||
| 2857 | (mapc | 2859 | (mapc |
| 2858 | (function | 2860 | (function |
| 2859 | (lambda (sym) | 2861 | (lambda (sym) |
| 2860 | (put sym 'delete-selection t) ; for delsel (Emacs) | 2862 | (put sym 'delete-selection t) ; for delsel (Emacs) |
| 2861 | (put sym 'pending-delete t))) ; for pending-del (XEmacs) | 2863 | (put sym 'pending-delete t))) ; for pending-del (XEmacs) |
| 2862 | '(c-electric-pound | 2864 | '(c-electric-pound |
| 2863 | c-electric-brace | ||
| 2864 | c-electric-slash | 2865 | c-electric-slash |
| 2865 | c-electric-star | 2866 | c-electric-star |
| 2866 | c-electric-semi&comma | 2867 | c-electric-semi&comma |
| 2867 | c-electric-lt-gt | 2868 | c-electric-lt-gt |
| 2868 | c-electric-colon | 2869 | c-electric-colon)) |
| 2870 | (mapc | ||
| 2871 | (function | ||
| 2872 | (lambda (sym) | ||
| 2873 | (put sym 'delete-selection (if (fboundp 'delete-selection-uses-region-p) | ||
| 2874 | 'delete-selection-uses-region-p | ||
| 2875 | t)) | ||
| 2876 | (put sym 'pending-delete t))) | ||
| 2877 | '(c-electric-brace | ||
| 2869 | c-electric-paren)) | 2878 | c-electric-paren)) |
| 2870 | (put 'c-electric-delete 'delete-selection 'supersede) ; delsel | 2879 | (put 'c-electric-delete 'delete-selection 'supersede) ; delsel |
| 2871 | (put 'c-electric-delete 'pending-delete 'supersede) ; pending-del | 2880 | (put 'c-electric-delete 'pending-delete 'supersede) ; pending-del |