Mercurial > emacs
comparison lisp/delsel.el @ 41254:2538b11fc837
(delete-selection-pre-hook): Handle and resignal
file-supersession errors to interact properly with userlock.el.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 19 Nov 2001 06:21:11 +0000 |
parents | 3dbecf5d82d8 |
children | b03765d292c2 d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
41253:87ae7a37e076 | 41254:2538b11fc837 |
---|---|
82 (defun delete-selection-pre-hook () | 82 (defun delete-selection-pre-hook () |
83 (when (and delete-selection-mode transient-mark-mode mark-active | 83 (when (and delete-selection-mode transient-mark-mode mark-active |
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) |
108 | 115 |
109 (put 'yank 'delete-selection 'yank) | 116 (put 'yank 'delete-selection 'yank) |