aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar David Aspinall <da@inf.ed.ac.uk>2009-09-05 13:18:14 +0000
committerGravatar David Aspinall <da@inf.ed.ac.uk>2009-09-05 13:18:14 +0000
commit41ac69352f5c7325acaa4e56859f9c88a37e832e (patch)
tree840c7dda38eb5763853b9222d31638a9a5cc8f31
parentc50c8e3075f9ed2306265b8b13e38f374b9cf404 (diff)
pg-protected-undo: Use key remapping instead of hacking function values
-rw-r--r--generic/pg-user.el18
1 files changed, 5 insertions, 13 deletions
diff --git a/generic/pg-user.el b/generic/pg-user.el
index 9416ddec..edd84ffc 100644
--- a/generic/pg-user.el
+++ b/generic/pg-user.el
@@ -1343,13 +1343,9 @@ removed if it matches the last item in the ring."
;; previous use of `undo-make-selective-list' to hack
;; `buffer-undo-list' in `proof-set-queue-endpoints'.
;;
-;; We make a cheeky replacement of the standard undo function
-;; (cf adding advice). Rebinding keys in proof script mode
-;; would be cleaner, but would need to alter edit menu, as well.
-;;
-(unless (fboundp 'pg-ordinary-undo)
- (fset 'pg-ordinary-undo (symbol-function 'undo)))
+(define-key proof-mode-map [remap undo] 'pg-protected-undo)
+(define-key proof-mode-map [remap advertised-undo] 'pg-protected-undo)
(defun pg-protected-undo (&optional arg)
"Behaves as `undo' unless undo would edit the locked region.
@@ -1357,14 +1353,12 @@ In this case, undo is only allowed in the unlocked region,
unless `proof-allow-undo-in-read-only' is set.
Undoing will use the standard undo in region behaviour, which
-skips undo entries in the locked region.
-
-This function uses `pg-ordinary-undo' as a rebound version of undo."
+skips undo entries in the locked region."
(interactive "*P")
(if (or (not proof-locked-span)
proof-allow-undo-in-read-only
(equal (proof-queue-or-locked-end) (point-min)))
- (pg-ordinary-undo arg)
+ (undo arg)
(let* (;(transient-mark-mode nil)
(savedpoint (point))
;(savedmark (mark))
@@ -1373,12 +1367,10 @@ This function uses `pg-ordinary-undo' as a rebound version of undo."
(save-excursion
(goto-char (point-max))
(while (> repeat 0) ; crude recovery of n-fold undo
- (pg-ordinary-undo t) ; undo in unlocked region only
+ (undo t) ; undo in unlocked region only
(decf repeat)))
(pop-mark))))
-(defalias 'undo 'pg-protected-undo)
-
(provide 'pg-user)
;;; pg-user.el ends here