diff options
| author | Richard M. Stallman | 1993-05-20 14:02:07 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-05-20 14:02:07 +0000 |
| commit | d4df3279afd02a3388134879cc4404c2a075a91e (patch) | |
| tree | d218ac54950bcd896ce40061142ca9a3071cd160 | |
| parent | 258bf7465d693f1cc530c67dcfb2d9c99dce2da3 (diff) | |
| download | emacs-d4df3279afd02a3388134879cc4404c2a075a91e.tar.gz emacs-d4df3279afd02a3388134879cc4404c2a075a91e.zip | |
Provide delsel.
(keyboard-quit): Definition deleted.
(minibuffer-keyboard-quit): If Delete Selection mode is off,
do abort even if mark is active.
| -rw-r--r-- | lisp/delsel.el | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/lisp/delsel.el b/lisp/delsel.el index 57caba59eef..b1ed2a88118 100644 --- a/lisp/delsel.el +++ b/lisp/delsel.el | |||
| @@ -52,17 +52,17 @@ insertion commands first delete the region and then insert.") | |||
| 52 | (cond ((eq type 'kill) | 52 | (cond ((eq type 'kill) |
| 53 | (delete-active-region t)) | 53 | (delete-active-region t)) |
| 54 | ((eq type 'supersede) | 54 | ((eq type 'supersede) |
| 55 | (if (delete-active-region ()) | 55 | (if (delete-active-region nil) |
| 56 | (setq this-command '(lambda () (interactive))))) | 56 | (setq this-command '(lambda () (interactive))))) |
| 57 | (type | 57 | (type |
| 58 | (delete-active-region ())))))) | 58 | (delete-active-region nil)))))) |
| 59 | 59 | ||
| 60 | (add-hook 'pre-command-hook 'delete-selection-pre-hook) | 60 | (add-hook 'pre-command-hook 'delete-selection-pre-hook) |
| 61 | 61 | ||
| 62 | (put 'self-insert-command 'delete-selection t) | 62 | (put 'self-insert-command 'delete-selection t) |
| 63 | 63 | ||
| 64 | (put 'yank 'delete-selection t) | 64 | (put 'yank 'delete-selection t) |
| 65 | (put 'x-yank-clipboard-selection 'delete-selection t) | 65 | (put 'insert-register 'delete-selection t) |
| 66 | 66 | ||
| 67 | (put 'delete-backward-char 'delete-selection 'supersede) | 67 | (put 'delete-backward-char 'delete-selection 'supersede) |
| 68 | (put 'backward-delete-char-untabify 'delete-selection 'supersede) | 68 | (put 'backward-delete-char-untabify 'delete-selection 'supersede) |
| @@ -72,7 +72,9 @@ insertion commands first delete the region and then insert.") | |||
| 72 | (put 'newline 'delete-selection t) | 72 | (put 'newline 'delete-selection t) |
| 73 | (put 'open-line 'delete-selection t) | 73 | (put 'open-line 'delete-selection t) |
| 74 | 74 | ||
| 75 | ;;;###autoload | ||
| 75 | (defalias 'pending-delete-mode 'delete-selection-mode) | 76 | (defalias 'pending-delete-mode 'delete-selection-mode) |
| 77 | ;;;###autoload | ||
| 76 | (defun delete-selection-mode (arg) | 78 | (defun delete-selection-mode (arg) |
| 77 | "Toggle Delete Selection mode. | 79 | "Toggle Delete Selection mode. |
| 78 | When ON, typed text replaces the selection if the selection is active. | 80 | When ON, typed text replaces the selection if the selection is active. |
| @@ -83,34 +85,15 @@ When OFF, typed text is just inserted at point." | |||
| 83 | (> (prefix-numeric-value arg) 0))) | 85 | (> (prefix-numeric-value arg) 0))) |
| 84 | (set-buffer-modified-p (buffer-modified-p))) ;No-op, but updates mode line. | 86 | (set-buffer-modified-p (buffer-modified-p))) ;No-op, but updates mode line. |
| 85 | 87 | ||
| 86 | ;; This new definition of control-G makes the first control-G disown the | ||
| 87 | ;; selection and the second one signal a QUIT. | ||
| 88 | ;; This is very useful for cancelling a selection in the minibuffer without | 88 | ;; This is very useful for cancelling a selection in the minibuffer without |
| 89 | ;; aborting the minibuffer. | 89 | ;; aborting the minibuffer. |
| 90 | ;; It has actually nothing to do with delete-selection but its more necessary | ||
| 91 | ;; with pending delete because pending delete users use the selection more. | ||
| 92 | (defun keyboard-quit () | ||
| 93 | "Signal a `quit' condition. | ||
| 94 | During execution of Lisp code, this character causes a quit directly. | ||
| 95 | At top-level, as an editor command, this simply beeps. | ||
| 96 | In Transient Mark mode, if the mark is active, just deactivate it." | ||
| 97 | (interactive) | ||
| 98 | (if (and transient-mark-mode mark-active) | ||
| 99 | (progn | ||
| 100 | ;; Don't beep if just deactivating the region. | ||
| 101 | (setq mark-active nil) | ||
| 102 | (run-hooks 'deactivate-mark-hook)) | ||
| 103 | (signal 'quit nil))) | ||
| 104 | |||
| 105 | (defun minibuffer-keyboard-quit () | 90 | (defun minibuffer-keyboard-quit () |
| 106 | "Abort recursive edit. | 91 | "Abort recursive edit. |
| 107 | In Transient Mark mode, if the mark is active, just deactivate it." | 92 | In Delete Selection mode mode, if the mark is active, just deactivate it; |
| 93 | then it takes a second C-g to abort the minibuffer." | ||
| 108 | (interactive) | 94 | (interactive) |
| 109 | (if (and transient-mark-mode mark-active) | 95 | (if (and delete-selection-mode transient-mark-mode mark-active) |
| 110 | (progn | 96 | (setq deactivate-mark t) |
| 111 | ;; Don't beep if just deactivating the region. | ||
| 112 | (setq mark-active nil) | ||
| 113 | (run-hooks 'deactivate-mark-hook)) | ||
| 114 | (abort-recursive-edit))) | 97 | (abort-recursive-edit))) |
| 115 | 98 | ||
| 116 | (define-key minibuffer-local-map "\C-g" 'minibuffer-keyboard-quit) | 99 | (define-key minibuffer-local-map "\C-g" 'minibuffer-keyboard-quit) |
| @@ -119,6 +102,6 @@ In Transient Mark mode, if the mark is active, just deactivate it." | |||
| 119 | (define-key minibuffer-local-must-match-map "\C-g" 'minibuffer-keyboard-quit) | 102 | (define-key minibuffer-local-must-match-map "\C-g" 'minibuffer-keyboard-quit) |
| 120 | (define-key minibuffer-local-isearch-map "\C-g" 'minibuffer-keyboard-quit) | 103 | (define-key minibuffer-local-isearch-map "\C-g" 'minibuffer-keyboard-quit) |
| 121 | 104 | ||
| 122 | (provide 'pending-del) | 105 | (provide 'delsel) |
| 123 | 106 | ||
| 124 | ;;; pending-del.el ends here | 107 | ;;; delsel.el ends here |