aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-02-06 23:56:47 +0000
committerRichard M. Stallman1996-02-06 23:56:47 +0000
commit3a5da8a83f20cc260f3d584936b3e704d529b58e (patch)
tree73401acec3b3013c22dc0bafcf7533de6fd97092
parent0dc88e60fa03381f48c3e9833d8da051c6535b04 (diff)
downloademacs-3a5da8a83f20cc260f3d584936b3e704d529b58e.tar.gz
emacs-3a5da8a83f20cc260f3d584936b3e704d529b58e.zip
(text-read-only): New error symbol.
(kill-region): Use it when text has read-only text property. (yank-pop): Turn on inhibit-read-only.
-rw-r--r--lisp/simple.el12
1 files changed, 10 insertions, 2 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 5737469c873..6d8686bfbb6 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1182,6 +1182,10 @@ yanking point; just return the Nth kill forward."
1182(defvar kill-read-only-ok nil 1182(defvar kill-read-only-ok nil
1183 "*Non-nil means don't signal an error for killing read-only text.") 1183 "*Non-nil means don't signal an error for killing read-only text.")
1184 1184
1185(put 'text-read-only 'error-conditions
1186 '(text-read-only buffer-read-only error))
1187(put 'text-read-only 'error-message "Text is read-only")
1188
1185(defun kill-region (beg end) 1189(defun kill-region (beg end)
1186 "Kill between point and mark. 1190 "Kill between point and mark.
1187The text is deleted but saved in the kill ring. 1191The text is deleted but saved in the kill ring.
@@ -1211,7 +1215,10 @@ to make one entry in the kill ring."
1211 (if kill-read-only-ok 1215 (if kill-read-only-ok
1212 (message "Read only text copied to kill ring") 1216 (message "Read only text copied to kill ring")
1213 (setq this-command 'kill-region) 1217 (setq this-command 'kill-region)
1214 (barf-if-buffer-read-only))) 1218 ;; Signal an error if the buffer is read-only.
1219 (barf-if-buffer-read-only)
1220 ;; If the buffer isn't read-only, the text is.
1221 (signal 'text-read-only (list (current-buffer)))))
1215 1222
1216 ;; In certain cases, we can arrange for the undo list and the kill 1223 ;; In certain cases, we can arrange for the undo list and the kill
1217 ;; ring to share the same string object. This code does that. 1224 ;; ring to share the same string object. This code does that.
@@ -1313,7 +1320,8 @@ comes the newest one."
1313 (if (not (eq last-command 'yank)) 1320 (if (not (eq last-command 'yank))
1314 (error "Previous command was not a yank")) 1321 (error "Previous command was not a yank"))
1315 (setq this-command 'yank) 1322 (setq this-command 'yank)
1316 (let ((before (< (point) (mark t)))) 1323 (let ((inhibit-read-only t)
1324 (before (< (point) (mark t))))
1317 (delete-region (point) (mark t)) 1325 (delete-region (point) (mark t))
1318 (set-marker (mark-marker) (point) (current-buffer)) 1326 (set-marker (mark-marker) (point) (current-buffer))
1319 (insert (current-kill arg)) 1327 (insert (current-kill arg))