Mercurial > emacs
comparison lisp/delsel.el @ 2925:902c32c709f7
Provide delsel.
(keyboard-quit): Definition deleted.
(minibuffer-keyboard-quit): If Delete Selection mode is off,
do abort even if mark is active.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 20 May 1993 14:02:07 +0000 |
parents | fa41174db2fa |
children | b589ba0d8960 |
comparison
equal
deleted
inserted
replaced
2924:6e233798a3f7 | 2925:902c32c709f7 |
---|---|
50 (let ((type (and (symbolp this-command) | 50 (let ((type (and (symbolp this-command) |
51 (get this-command 'delete-selection)))) | 51 (get this-command 'delete-selection)))) |
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) |
69 (put 'delete-char 'delete-selection 'supersede) | 69 (put 'delete-char 'delete-selection 'supersede) |
70 | 70 |
71 (put 'newline-and-indent 'delete-selection 't) | 71 (put 'newline-and-indent 'delete-selection 't) |
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. |
79 When OFF, typed text is just inserted at point." | 81 When OFF, typed text is just inserted at point." |
80 (interactive "P") | 82 (interactive "P") |
81 (setq delete-selection-mode | 83 (setq delete-selection-mode |
82 (if (null arg) (not delete-selection-mode) | 84 (if (null arg) (not delete-selection-mode) |
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) |
117 (define-key minibuffer-local-ns-map "\C-g" 'minibuffer-keyboard-quit) | 100 (define-key minibuffer-local-ns-map "\C-g" 'minibuffer-keyboard-quit) |
118 (define-key minibuffer-local-completion-map "\C-g" 'minibuffer-keyboard-quit) | 101 (define-key minibuffer-local-completion-map "\C-g" 'minibuffer-keyboard-quit) |
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 |