diff options
| author | Richard M. Stallman | 1993-03-09 05:37:50 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-03-09 05:37:50 +0000 |
| commit | af9157b9bcef785b4b17bae541f8935bd39af1c8 (patch) | |
| tree | aec54a884ae1a2e05b4eea31d176936376aee05b | |
| parent | b0dbaa217bd8f5c183dc22fbf25a31911e3e5b25 (diff) | |
| download | emacs-af9157b9bcef785b4b17bae541f8935bd39af1c8.tar.gz emacs-af9157b9bcef785b4b17bae541f8935bd39af1c8.zip | |
entered into RCS
| -rw-r--r-- | lisp/delsel.el | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/lisp/delsel.el b/lisp/delsel.el index 3ae1f295236..29489be8040 100644 --- a/lisp/delsel.el +++ b/lisp/delsel.el | |||
| @@ -24,31 +24,34 @@ | |||
| 24 | ;;; text inserted while the region is active will replace the region contents. | 24 | ;;; text inserted while the region is active will replace the region contents. |
| 25 | ;;; This is a popular behavior of personal computers text editors. | 25 | ;;; This is a popular behavior of personal computers text editors. |
| 26 | 26 | ||
| 27 | (defvar pending-delete-mode t | ||
| 28 | "*Non-nil means Pending Delete mode is enabled. | ||
| 29 | In Pending Delete mode, when a region is highlighted, | ||
| 30 | insertion commands first delete the region and then insert.") | ||
| 31 | |||
| 27 | (defun delete-active-region (&optional killp) | 32 | (defun delete-active-region (&optional killp) |
| 28 | (if (and (not buffer-read-only) | 33 | (if killp |
| 29 | (extentp primary-selection-extent) | 34 | (kill-region (point) (mark)) |
| 30 | (eq (current-buffer) (extent-buffer primary-selection-extent)) | 35 | (delete-region (point) (mark))) |
| 31 | (< 0 (extent-start-position primary-selection-extent)) | 36 | (setq mark-active nil) |
| 32 | (< 0 (extent-end-position primary-selection-extent))) | 37 | (run-hooks 'deactivate-mark-hook) |
| 33 | (progn | 38 | t) |
| 34 | (if killp | ||
| 35 | (kill-region (extent-start-position primary-selection-extent) | ||
| 36 | (extent-end-position primary-selection-extent)) | ||
| 37 | (delete-region (extent-start-position primary-selection-extent) | ||
| 38 | (extent-end-position primary-selection-extent))) | ||
| 39 | (zmacs-deactivate-region) | ||
| 40 | t))) | ||
| 41 | 39 | ||
| 42 | (defun pending-delete-pre-hook () | 40 | (defun pending-delete-pre-hook () |
| 43 | (let ((type (and (symbolp this-command) | 41 | (if (and pending-delete-mode |
| 44 | (get this-command 'pending-delete)))) | 42 | (not buffer-read-only) |
| 45 | (cond ((eq type 'kill) | 43 | transient-mark-mode mark-active) |
| 46 | (delete-active-region t)) | 44 | (let ((type (and (symbolp this-command) |
| 47 | ((eq type 'supersede) | 45 | (get this-command 'pending-delete)))) |
| 48 | (if (delete-active-region ()) | 46 | (cond ((eq type 'kill) |
| 49 | (setq this-command '(lambda () (interactive))))) | 47 | (delete-active-region t)) |
| 50 | (type | 48 | ((eq type 'supersede) |
| 51 | (delete-active-region ()))))) | 49 | (if (delete-active-region ()) |
| 50 | (setq this-command '(lambda () (interactive))))) | ||
| 51 | (type | ||
| 52 | (delete-active-region ())))))) | ||
| 53 | |||
| 54 | (add-hook 'pre-command-hook 'pending-delete-pre-hook) | ||
| 52 | 55 | ||
| 53 | (put 'self-insert-command 'pending-delete t) | 56 | (put 'self-insert-command 'pending-delete t) |
| 54 | 57 | ||
| @@ -63,21 +66,15 @@ | |||
| 63 | (put 'newline 'pending-delete t) | 66 | (put 'newline 'pending-delete t) |
| 64 | (put 'open-line 'pending-delete t) | 67 | (put 'open-line 'pending-delete t) |
| 65 | 68 | ||
| 66 | (defun pending-delete-mode () | 69 | (defun pending-delete-mode (arg) |
| 67 | "Toggle the state of pending-delete mode. | 70 | "Toggle the state of pending-delete mode. |
| 68 | When ON, typed text replaces the selection if the selection is active. | 71 | When ON, typed text replaces the selection if the selection is active. |
| 69 | When OFF, typed text is just inserted at point." | 72 | When OFF, typed text is just inserted at point." |
| 70 | (interactive) | 73 | (interactive "P") |
| 71 | (if (memq 'pending-delete-pre-hook pre-command-hook) | 74 | (setq pending-delete-mode |
| 72 | (progn | 75 | (if (null arg) (not pending-delete-mode) |
| 73 | (remove-hook 'pre-command-hook 'pending-delete-pre-hook) | 76 | (> (prefix-numeric-value arg) 0))) |
| 74 | (message "pending delete is OFF")) | 77 | (set-buffer-modified-p (buffer-modified-p))) ;No-op, but updates mode line. |
| 75 | (progn | ||
| 76 | (add-hook 'pre-command-hook 'pending-delete-pre-hook) | ||
| 77 | (message | ||
| 78 | "Pending delete is ON, use M-x pending-delete to turn it OFF")))) | ||
| 79 | |||
| 80 | (pending-delete-mode) | ||
| 81 | 78 | ||
| 82 | ;; This new definition of control-G makes the first control-G disown the | 79 | ;; This new definition of control-G makes the first control-G disown the |
| 83 | ;; selection and the second one signal a QUIT. | 80 | ;; selection and the second one signal a QUIT. |
| @@ -87,10 +84,8 @@ When OFF, typed text is just inserted at point." | |||
| 87 | ;; with pending delete because pending delete users use the selection more. | 84 | ;; with pending delete because pending delete users use the selection more. |
| 88 | (defun keyboard-quit () | 85 | (defun keyboard-quit () |
| 89 | "Signal a `quit' condition. | 86 | "Signal a `quit' condition. |
| 90 | If this character is typed while lisp code is executing, it will be treated | 87 | During execution of Lisp code, this character causes a quit directly. |
| 91 | as an interrupt. | 88 | At top-level, as an editor command, this simply beeps. |
| 92 | If this character is typed at top-level, this simply beeps. | ||
| 93 | |||
| 94 | In Transient Mark mode, if the mark is active, just deactivate it." | 89 | In Transient Mark mode, if the mark is active, just deactivate it." |
| 95 | (interactive) | 90 | (interactive) |
| 96 | (if (and transient-mark-mode mark-active) | 91 | (if (and transient-mark-mode mark-active) |