]> git.eshelyaron.com Git - emacs.git/commitdiff
(mouse-save-then-kill): Don't discard all the normal
authorRichard M. Stallman <rms@gnu.org>
Wed, 4 Aug 1993 04:37:11 +0000 (04:37 +0000)
committerRichard M. Stallman <rms@gnu.org>
Wed, 4 Aug 1993 04:37:11 +0000 (04:37 +0000)
undo info; just replace the deletion entry.

lisp/mouse.el

index 904227727e90ca9d22717c9cfe4f8c23167ebd4e..158173b0bcc9bd6fb6864aa8bb96dab264c7eaf0 100644 (file)
@@ -347,12 +347,23 @@ which prepares for a second click to delete the text."
        ;; If this is the second time we've called
        ;; mouse-save-then-kill, delete the text from the buffer.
        (progn
+         ;; Delete just one char, so in case buffer is being modified
+         ;; for the first time, the undo list records that fact.
+         (delete-region (point)
+                        (+ (point) (if (> (mark) (point)) 1 -1)))
+         ;; Now delete the rest of the specified region,
+         ;; but don't record it.
          (let ((buffer-undo-list t))
            (delete-region (point) (mark)))
-         ;; Make the undo list by hand so it is shared.
          (if (not (eq buffer-undo-list t))
-             (setq buffer-undo-list
-                   (cons (cons (car kill-ring) (point)) buffer-undo-list))))
+             (let ((tail buffer-undo-list))
+               ;; Search back in buffer-undo-list for the string
+               ;; that came from the first delete-region.
+               (while (and tail (not (stringp (car (car tail)))))
+                 (setq tail (cdr tail)))
+               ;; Replace it with an entry for the entire deleted text.
+               (and tail
+                    (setcar tail (cons (car kill-ring) (point))))))))
       ;; Otherwise, save this region.
       (mouse-set-mark-fast click)
       (kill-ring-save (point) (mark t))