Mercurial > emacs
comparison lisp/mouse.el @ 1765:1cc3ee5afc82
(mouse-save-then-kill): When deleting, avoid delay
and don't set the mark. Replace obsolete fn event-point.
(mouse-kill): Replace obsolete fn event-point.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 13 Jan 1993 01:31:45 +0000 |
parents | 2a49d509b30d |
children | 04fb1d3d6992 |
comparison
equal
deleted
inserted
replaced
1764:94ff5d9ef48a | 1765:1cc3ee5afc82 |
---|---|
152 | 152 |
153 (defun mouse-kill (click) | 153 (defun mouse-kill (click) |
154 "Kill the region between point and the mouse click. | 154 "Kill the region between point and the mouse click. |
155 The text is saved in the kill ring, as with \\[kill-region]." | 155 The text is saved in the kill ring, as with \\[kill-region]." |
156 (interactive "e") | 156 (interactive "e") |
157 (let ((click-posn (event-point click))) | 157 (let ((click-posn (posn-point (event-start click)))) |
158 (if (numberp click-posn) | 158 (if (numberp click-posn) |
159 (kill-region (min (point) click-posn) | 159 (kill-region (min (point) click-posn) |
160 (max (point) click-posn))))) | 160 (max (point) click-posn))))) |
161 | 161 |
162 (defun mouse-yank-at-click (click arg) | 162 (defun mouse-yank-at-click (click arg) |
172 (interactive "e") | 172 (interactive "e") |
173 (mouse-set-mark click) | 173 (mouse-set-mark click) |
174 (call-interactively 'kill-ring-save)) | 174 (call-interactively 'kill-ring-save)) |
175 | 175 |
176 (defun mouse-save-then-kill (click) | 176 (defun mouse-save-then-kill (click) |
177 "Copy the region between point and the mouse click in the kill ring. | 177 "Save text to point in kill ring; the second time, kill the text. |
178 This does not delete the region; it acts like \\[kill-ring-save]." | 178 If the text between point and the mouse is the same as what's |
179 (interactive "e") | 179 at the front of the kill ring, this deletes the text. |
180 (mouse-set-mark click) | 180 Otherwise, it adds the text to the kill ring, like \\[kill-ring-save], |
181 (if (string= (buffer-substring (point) (mark)) (car kill-ring)) | 181 which prepares for a second click to delete the text." |
182 ;; If this text was already saved in kill ring, | 182 (interactive "e") |
183 ;; now delete it from the buffer. | 183 (let ((click-posn (posn-point (event-start click)))) |
184 (progn | 184 (if (string= (buffer-substring (point) click-posn) (car kill-ring)) |
185 (let ((buffer-undo-list t)) | 185 ;; If this text was already saved in kill ring, |
186 (delete-region (point) (mark))) | 186 ;; now delete it from the buffer. |
187 ;; Make the undo list by hand so it is shared. | 187 (progn |
188 (setq buffer-undo-list | 188 (let ((buffer-undo-list t)) |
189 (cons (cons (car kill-ring) (point)) buffer-undo-list))) | 189 (delete-region (point) (mark))) |
190 ;; Otherwise, save this region. | 190 ;; Make the undo list by hand so it is shared. |
191 (call-interactively 'kill-ring-save))) | 191 (setq buffer-undo-list |
192 (cons (cons (car kill-ring) (point)) buffer-undo-list))) | |
193 ;; Otherwise, save this region. | |
194 (mouse-set-mark click) | |
195 (call-interactively 'kill-ring-save)))) | |
192 | 196 |
193 (defun mouse-buffer-menu (event) | 197 (defun mouse-buffer-menu (event) |
194 "Pop up a menu of buffers for selection with the mouse. | 198 "Pop up a menu of buffers for selection with the mouse. |
195 This switches buffers in the window that you clicked on, | 199 This switches buffers in the window that you clicked on, |
196 and selects that window." | 200 and selects that window." |