diff options
author | Martin Rudalics <rudalics@gmx.at> | 2008-01-24 09:46:40 +0000 |
---|---|---|
committer | Martin Rudalics <rudalics@gmx.at> | 2008-01-24 09:46:40 +0000 |
commit | 578877a1fd02f37293b8a5810fab3b81830f3943 (patch) | |
tree | 04fed09d8b139fb381c6f6332f2787f9afee6a0c | |
parent | fddde1f0b5f04dcb96360fb1f88b0aa0d1f251ed (diff) |
(delete-selection-pre-hook): Avoid clearing out
pre-command-hook when text is read-only.
-rw-r--r-- | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/delsel.el | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 370f63021b..34a8222c13 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2008-01-24 Martin Rudalics <rudalics@gmx.at> + + * delsel.el (delete-selection-pre-hook): Avoid clearing out + pre-command-hook when text is read-only. + 2008-01-24 Thien-Thi Nguyen <ttn@gnuvola.org> * vc.el (vc-process-filter): Do nothing if buffer not live. diff --git a/lisp/delsel.el b/lisp/delsel.el index 6427c39eec..990ca91ace 100644 --- a/lisp/delsel.el +++ b/lisp/delsel.el @@ -113,7 +113,23 @@ any selection." ;; stop safe_run_hooks from clearing out pre-command-hook. (and (eq inhibit-quit 'pre-command-hook) (setq inhibit-quit 'delete-selection-dummy)) - (signal 'file-supersession (cdr data))))))) + (signal 'file-supersession (cdr data))) + (text-read-only + ;; This signal may come either from `delete-active-region' or + ;; `self-insert-command' (when `overwrite-mode' is non-nil). + ;; To avoid clearing out `pre-command-hook' we handle this case + ;; by issuing a simple message. Note, however, that we do not + ;; handle all related problems: When read-only text ends before + ;; the end of the region, the latter is not deleted but any + ;; subsequent insertion will succeed. We could avoid this case + ;; by doing a (setq this-command 'ignore) here. This would, + ;; however, still not handle the case where read-only text ends + ;; precisely where the region starts: In that case the deletion + ;; would succeed but the subsequent insertion would fail with a + ;; text-read-only error. To handle that case we would have to + ;; investigate text properties at both ends of the region and + ;; skip the deletion when inserting text is forbidden there. + (message "Text is read-only") (ding)))))) (put 'self-insert-command 'delete-selection t) (put 'self-insert-iso 'delete-selection t) |