comparison lisp/simple.el @ 26744:f14026cd9767

(kill-region): Use the new `delete-and-extract-region' rather than the undo log (which is incorrect with *-change-functions).
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 07 Dec 1999 06:30:44 +0000
parents b4f7c98850f0
children 8063bfbd8b08
comparison
equal deleted inserted replaced
26743:2ddbff6366e9 26744:f14026cd9767
1631 If the previous command was also a kill command, 1631 If the previous command was also a kill command,
1632 the text killed this time appends to the text killed last time 1632 the text killed this time appends to the text killed last time
1633 to make one entry in the kill ring." 1633 to make one entry in the kill ring."
1634 (interactive "*r") 1634 (interactive "*r")
1635 (condition-case nil 1635 (condition-case nil
1636 ;; Don't let the undo list be truncated before we can even access it. 1636 (let ((string (delete-and-extract-region beg end)))
1637 (let ((undo-strong-limit (+ (- (max beg end) (min beg end)) 100)) 1637 (when string ;STRING is nil if BEG = END
1638 (old-list buffer-undo-list) 1638 ;; Add that string to the kill ring, one way or another.
1639 tail 1639 (if (eq last-command 'kill-region)
1640 ;; If we can't rely on finding the killed text 1640 (kill-append string (< end beg))
1641 ;; in the undo list, save it now as a string. 1641 (kill-new string)))
1642 (string (if (or (eq buffer-undo-list t)
1643 (= beg end))
1644 (buffer-substring beg end))))
1645 (delete-region beg end)
1646 ;; Search back in buffer-undo-list for this string,
1647 ;; in case a change hook made property changes.
1648 (setq tail buffer-undo-list)
1649 (unless string
1650 (while (not (stringp (car (car tail))))
1651 (setq tail (cdr tail)))
1652 ;; If we did not already make the string to use,
1653 ;; use the same one that undo made for us.
1654 (setq string (car (car tail))))
1655 ;; Add that string to the kill ring, one way or another.
1656 (if (eq last-command 'kill-region)
1657 (kill-append string (< end beg))
1658 (kill-new string))
1659 (setq this-command 'kill-region)) 1642 (setq this-command 'kill-region))
1660 ((buffer-read-only text-read-only) 1643 ((buffer-read-only text-read-only)
1661 ;; The code above failed because the buffer, or some of the characters 1644 ;; The code above failed because the buffer, or some of the characters
1662 ;; in the region, are read-only. 1645 ;; in the region, are read-only.
1663 ;; We should beep, in case the user just isn't aware of this. 1646 ;; We should beep, in case the user just isn't aware of this.