Mercurial > emacs
comparison lisp/delsel.el @ 87933:1c868d4c8354
(delete-selection-pre-hook): Avoid clearing out
pre-command-hook when text is read-only.
author | Martin Rudalics <rudalics@gmx.at> |
---|---|
date | Thu, 24 Jan 2008 09:46:08 +0000 |
parents | 107ccd98fa12 |
children | b3879b6d2e40 |
comparison
equal
deleted
inserted
replaced
87932:f3fd12e0dddd | 87933:1c868d4c8354 |
---|---|
111 (file-supersession | 111 (file-supersession |
112 ;; If ask-user-about-supersession-threat signals an error, | 112 ;; If ask-user-about-supersession-threat signals an error, |
113 ;; stop safe_run_hooks from clearing out pre-command-hook. | 113 ;; stop safe_run_hooks from clearing out pre-command-hook. |
114 (and (eq inhibit-quit 'pre-command-hook) | 114 (and (eq inhibit-quit 'pre-command-hook) |
115 (setq inhibit-quit 'delete-selection-dummy)) | 115 (setq inhibit-quit 'delete-selection-dummy)) |
116 (signal 'file-supersession (cdr data))))))) | 116 (signal 'file-supersession (cdr data))) |
117 (text-read-only | |
118 ;; This signal may come either from `delete-active-region' or | |
119 ;; `self-insert-command' (when `overwrite-mode' is non-nil). | |
120 ;; To avoid clearing out `pre-command-hook' we handle this case | |
121 ;; by issuing a simple message. Note, however, that we do not | |
122 ;; handle all related problems: When read-only text ends before | |
123 ;; the end of the region, the latter is not deleted but any | |
124 ;; subsequent insertion will succeed. We could avoid this case | |
125 ;; by doing a (setq this-command 'ignore) here. This would, | |
126 ;; however, still not handle the case where read-only text ends | |
127 ;; precisely where the region starts: In that case the deletion | |
128 ;; would succeed but the subsequent insertion would fail with a | |
129 ;; text-read-only error. To handle that case we would have to | |
130 ;; investigate text properties at both ends of the region and | |
131 ;; skip the deletion when inserting text is forbidden there. | |
132 (message "Text is read-only") (ding)))))) | |
117 | 133 |
118 (put 'self-insert-command 'delete-selection t) | 134 (put 'self-insert-command 'delete-selection t) |
119 (put 'self-insert-iso 'delete-selection t) | 135 (put 'self-insert-iso 'delete-selection t) |
120 | 136 |
121 (put 'yank 'delete-selection 'yank) | 137 (put 'yank 'delete-selection 'yank) |