diff options
| author | Richard M. Stallman | 2001-11-19 06:21:11 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-11-19 06:21:11 +0000 |
| commit | f13e84fa4b4c387a05aef02648e6754093e13e61 (patch) | |
| tree | 3f880b734fb35148769bffc6537e09ff0054ca40 | |
| parent | a764440a8fd55d1718942076cdf529053dd08bc6 (diff) | |
| download | emacs-f13e84fa4b4c387a05aef02648e6754093e13e61.tar.gz emacs-f13e84fa4b4c387a05aef02648e6754093e13e61.zip | |
(delete-selection-pre-hook): Handle and resignal
file-supersession errors to interact properly with userlock.el.
| -rw-r--r-- | lisp/delsel.el | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/lisp/delsel.el b/lisp/delsel.el index 4301e69b61d..9488e94061e 100644 --- a/lisp/delsel.el +++ b/lisp/delsel.el | |||
| @@ -84,24 +84,31 @@ any selection." | |||
| 84 | (not buffer-read-only)) | 84 | (not buffer-read-only)) |
| 85 | (let ((type (and (symbolp this-command) | 85 | (let ((type (and (symbolp this-command) |
| 86 | (get this-command 'delete-selection)))) | 86 | (get this-command 'delete-selection)))) |
| 87 | (cond ((eq type 'kill) | 87 | (condition-case data |
| 88 | (delete-active-region t)) | 88 | (cond ((eq type 'kill) |
| 89 | ((eq type 'yank) | 89 | (delete-active-region t)) |
| 90 | ;; Before a yank command, | 90 | ((eq type 'yank) |
| 91 | ;; make sure we don't yank the same region | 91 | ;; Before a yank command, |
| 92 | ;; that we are going to delete. | 92 | ;; make sure we don't yank the same region |
| 93 | ;; That would make yank a no-op. | 93 | ;; that we are going to delete. |
| 94 | (when (string= (buffer-substring-no-properties (point) (mark)) | 94 | ;; That would make yank a no-op. |
| 95 | (car kill-ring)) | 95 | (when (string= (buffer-substring-no-properties (point) (mark)) |
| 96 | (current-kill 1)) | 96 | (car kill-ring)) |
| 97 | (delete-active-region)) | 97 | (current-kill 1)) |
| 98 | ((eq type 'supersede) | 98 | (delete-active-region)) |
| 99 | (let ((empty-region (= (point) (mark)))) | 99 | ((eq type 'supersede) |
| 100 | (delete-active-region) | 100 | (let ((empty-region (= (point) (mark)))) |
| 101 | (unless empty-region | 101 | (delete-active-region) |
| 102 | (setq this-command 'ignore)))) | 102 | (unless empty-region |
| 103 | (type | 103 | (setq this-command 'ignore)))) |
| 104 | (delete-active-region)))))) | 104 | (type |
| 105 | (delete-active-region))) | ||
| 106 | (file-supersession | ||
| 107 | ;; If ask-user-about-supersession-threat signals an error, | ||
| 108 | ;; stop safe_run_hooks from clearing out pre-command-hook. | ||
| 109 | (and (eq inhibit-quit 'pre-command-hook) | ||
| 110 | (setq inhibit-quit 'delete-selection-dummy)) | ||
| 111 | (signal 'file-supersession (cdr data))))))) | ||
| 105 | 112 | ||
| 106 | (put 'self-insert-command 'delete-selection t) | 113 | (put 'self-insert-command 'delete-selection t) |
| 107 | (put 'self-insert-iso 'delete-selection t) | 114 | (put 'self-insert-iso 'delete-selection t) |