diff options
| author | Richard M. Stallman | 1993-08-04 04:37:11 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-08-04 04:37:11 +0000 |
| commit | a2d24e958ac600d47716db68f9b1594d7c02debe (patch) | |
| tree | 8d6e28982acd1c2527a283b1272271d01911cf90 | |
| parent | cefeb3a98d5677665742875f7d0b1eed6fb6792d (diff) | |
| download | emacs-a2d24e958ac600d47716db68f9b1594d7c02debe.tar.gz emacs-a2d24e958ac600d47716db68f9b1594d7c02debe.zip | |
(mouse-save-then-kill): Don't discard all the normal
undo info; just replace the deletion entry.
| -rw-r--r-- | lisp/mouse.el | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el index 904227727e9..158173b0bcc 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -347,12 +347,23 @@ which prepares for a second click to delete the text." | |||
| 347 | ;; If this is the second time we've called | 347 | ;; If this is the second time we've called |
| 348 | ;; mouse-save-then-kill, delete the text from the buffer. | 348 | ;; mouse-save-then-kill, delete the text from the buffer. |
| 349 | (progn | 349 | (progn |
| 350 | ;; Delete just one char, so in case buffer is being modified | ||
| 351 | ;; for the first time, the undo list records that fact. | ||
| 352 | (delete-region (point) | ||
| 353 | (+ (point) (if (> (mark) (point)) 1 -1))) | ||
| 354 | ;; Now delete the rest of the specified region, | ||
| 355 | ;; but don't record it. | ||
| 350 | (let ((buffer-undo-list t)) | 356 | (let ((buffer-undo-list t)) |
| 351 | (delete-region (point) (mark))) | 357 | (delete-region (point) (mark))) |
| 352 | ;; Make the undo list by hand so it is shared. | ||
| 353 | (if (not (eq buffer-undo-list t)) | 358 | (if (not (eq buffer-undo-list t)) |
| 354 | (setq buffer-undo-list | 359 | (let ((tail buffer-undo-list)) |
| 355 | (cons (cons (car kill-ring) (point)) buffer-undo-list)))) | 360 | ;; Search back in buffer-undo-list for the string |
| 361 | ;; that came from the first delete-region. | ||
| 362 | (while (and tail (not (stringp (car (car tail))))) | ||
| 363 | (setq tail (cdr tail))) | ||
| 364 | ;; Replace it with an entry for the entire deleted text. | ||
| 365 | (and tail | ||
| 366 | (setcar tail (cons (car kill-ring) (point)))))))) | ||
| 356 | ;; Otherwise, save this region. | 367 | ;; Otherwise, save this region. |
| 357 | (mouse-set-mark-fast click) | 368 | (mouse-set-mark-fast click) |
| 358 | (kill-ring-save (point) (mark t)) | 369 | (kill-ring-save (point) (mark t)) |