1525 |
'(0 . 0))) |
'(0 . 0))) |
1526 |
'(0 . 0))) |
'(0 . 0))) |
1527 |
|
|
1528 |
|
(defcustom undo-ask-before-discard t |
1529 |
|
"If non-nil ask about discarding undo info for the current command. |
1530 |
|
Normally, Emacs discards the undo info for the current command if |
1531 |
|
it exceeds `undo-outer-limit'. But if you set this option |
1532 |
|
non-nil, it asks in the echo area whether to discard the info. |
1533 |
|
If you answer no, there a slight risk that Emacs might crash, so |
1534 |
|
only do it if you really want to undo the command. |
1535 |
|
|
1536 |
|
This option is mainly intended for debugging. You have to be |
1537 |
|
careful if you use it for other purposes. Garbage collection is |
1538 |
|
inhibited while the question is asked, meaning that Emacs might |
1539 |
|
leak memory. So you should make sure that you do not wait |
1540 |
|
excessively long before answering the question." |
1541 |
|
:type 'boolean |
1542 |
|
:group 'undo |
1543 |
|
:version "21.4") |
1544 |
|
|
1545 |
(defvar undo-extra-outer-limit nil |
(defvar undo-extra-outer-limit nil |
1546 |
"If non-nil, an extra level of size that's ok in an undo item. |
"If non-nil, an extra level of size that's ok in an undo item. |
1547 |
We don't ask the user about truncating the undo list until the |
We don't ask the user about truncating the undo list until the |
1548 |
current item gets bigger than this amount.") |
current item gets bigger than this amount. |
1549 |
|
|
1550 |
|
This variable only matters if `undo-ask-before-discard' is non-nil.") |
1551 |
(make-variable-buffer-local 'undo-extra-outer-limit) |
(make-variable-buffer-local 'undo-extra-outer-limit) |
1552 |
|
|
1553 |
;; When the first undo batch in an undo list is longer than undo-outer-limit, |
;; When the first undo batch in an undo list is longer than |
1554 |
;; this function gets called to ask the user what to do. |
;; undo-outer-limit, this function gets called to warn the user that |
1555 |
;; Garbage collection is inhibited around the call, |
;; the undo info for the current command was discarded. Garbage |
1556 |
;; so it had better not do a lot of consing. |
;; collection is inhibited around the call, so it had better not do a |
1557 |
|
;; lot of consing. |
1558 |
(setq undo-outer-limit-function 'undo-outer-limit-truncate) |
(setq undo-outer-limit-function 'undo-outer-limit-truncate) |
1559 |
(defun undo-outer-limit-truncate (size) |
(defun undo-outer-limit-truncate (size) |
1560 |
(when (or (null undo-extra-outer-limit) |
(if undo-ask-before-discard |
1561 |
(> size undo-extra-outer-limit)) |
(when (or (null undo-extra-outer-limit) |
1562 |
;; Don't ask the question again unless it gets even bigger. |
(> size undo-extra-outer-limit)) |
1563 |
;; This applies, in particular, if the user quits from the question. |
;; Don't ask the question again unless it gets even bigger. |
1564 |
;; Such a quit quits out of GC, but something else will call GC |
;; This applies, in particular, if the user quits from the question. |
1565 |
;; again momentarily. It will call this function again, |
;; Such a quit quits out of GC, but something else will call GC |
1566 |
;; but we don't want to ask the question again. |
;; again momentarily. It will call this function again, |
1567 |
(setq undo-extra-outer-limit (+ size 50000)) |
;; but we don't want to ask the question again. |
1568 |
(if (let (use-dialog-box) |
(setq undo-extra-outer-limit (+ size 50000)) |
1569 |
(yes-or-no-p (format "Buffer %s undo info is %d bytes long; discard it? " |
(if (let (use-dialog-box track-mouse executing-kbd-macro ) |
1570 |
(buffer-name) size))) |
(yes-or-no-p (format "Buffer %s undo info is %d bytes long; discard it? " |
1571 |
(progn (setq buffer-undo-list nil) |
(buffer-name) size))) |
1572 |
(setq undo-extra-outer-limit nil) |
(progn (setq buffer-undo-list nil) |
1573 |
t) |
(setq undo-extra-outer-limit nil) |
1574 |
nil))) |
t) |
1575 |
|
nil)) |
1576 |
|
(display-warning '(undo discard-info) |
1577 |
|
(concat |
1578 |
|
(format "Buffer %s undo info was %d bytes long.\n" |
1579 |
|
(buffer-name) size) |
1580 |
|
"The undo info was discarded because it exceeded \ |
1581 |
|
`undo-outer-limit'. |
1582 |
|
|
1583 |
|
This is normal if you executed a command that made a huge change |
1584 |
|
to the buffer. In that case, to prevent similar problems in the |
1585 |
|
future, set `undo-outer-limit' to a value that is large enough to |
1586 |
|
cover the maximum size of normal changes you expect a single |
1587 |
|
command to make, but not so large that it might exceed the |
1588 |
|
maximum memory allotted to Emacs. |
1589 |
|
|
1590 |
|
If you did not execute any such command, the situation is |
1591 |
|
probably due to a bug and you should report it. |
1592 |
|
|
1593 |
|
You can disable the popping up of this buffer by adding the entry |
1594 |
|
\(undo discard-info) to the user option `warning-suppress-types'.\n") |
1595 |
|
:warning) |
1596 |
|
(setq buffer-undo-list nil) |
1597 |
|
t)) |
1598 |
|
|
1599 |
(defvar shell-command-history nil |
(defvar shell-command-history nil |
1600 |
"History list for some commands that read shell commands.") |
"History list for some commands that read shell commands.") |