X-Loop: help-debbugs@HIDDEN Subject: bug#27214: truncate_undo_list in undo.c: exclusions, warnings, documentation. Resent-From: Keith David Bershatsky <esq@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 03 Jun 2017 17:51:02 +0000 Resent-Message-ID: <handler.27214.B.14965122098360 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 27214 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 27214 <at> debbugs.gnu.org X-Debbugs-Original-To: Emacs Bug Reports <bug-gnu-emacs@HIDDEN> Received: via spool by submit <at> debbugs.gnu.org id=B.14965122098360 (code B ref -1); Sat, 03 Jun 2017 17:51:02 +0000 Received: (at submit) by debbugs.gnu.org; 3 Jun 2017 17:50:09 +0000 Received: from localhost ([127.0.0.1]:54087 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1dHDBf-0002Ak-Aa for submit <at> debbugs.gnu.org; Sat, 03 Jun 2017 13:50:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48345) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <esq@HIDDEN>) id 1dHDBd-0002AC-HS for submit <at> debbugs.gnu.org; Sat, 03 Jun 2017 13:50:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <esq@HIDDEN>) id 1dHDBX-0004AB-Fu for submit <at> debbugs.gnu.org; Sat, 03 Jun 2017 13:50:00 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:41918) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <esq@HIDDEN>) id 1dHDBX-0004A7-CU for submit <at> debbugs.gnu.org; Sat, 03 Jun 2017 13:49:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <esq@HIDDEN>) id 1dHDBV-0001Yf-PN for bug-gnu-emacs@HIDDEN; Sat, 03 Jun 2017 13:49:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <esq@HIDDEN>) id 1dHDBQ-00046a-OT for bug-gnu-emacs@HIDDEN; Sat, 03 Jun 2017 13:49:57 -0400 Received: from gateway33.websitewelcome.com ([192.185.146.68]:13630) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <esq@HIDDEN>) id 1dHDBQ-0003sy-Dt for bug-gnu-emacs@HIDDEN; Sat, 03 Jun 2017 13:49:52 -0400 Received: from cm3.websitewelcome.com (unknown [108.167.139.23]) by gateway33.websitewelcome.com (Postfix) with ESMTP id EA00B2A97 for <bug-gnu-emacs@HIDDEN>; Sat, 3 Jun 2017 12:49:38 -0500 (CDT) Received: from gator3053.hostgator.com ([50.87.144.69]) by cm3.websitewelcome.com with id UHpd1v00A1W3Awq01HpeWa; Sat, 03 Jun 2017 12:49:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Ottc+Qm1uVQtGsf86/FZpSN3amBSmIn9eKixLwT2dJc=; b=OXns1CTb8NiRZrmm5M2iTB0RNU NGKOp2g1dKhScO5eLqpMiVJGT6yCFSZdKW/ph0XRgSiVrzNWKNNUqURgkUIYugafyJTOWroDVX+Sh BS7RPsecytQqCMDiYCvMY7z6xjVnLdOqDwF6wQ6KITHBjPLL+VBrrsjFZk+oZUT4optazXnx3Ro33 Puu9Zs0NXyUJtG0ksfiijuneq4IsNqnZJ0i9rhJiC2TIwRo6cRerhtYhGyesBb21IC4XuVQQkH/5o WNjG2tPwysRuL9MiBm3zOOdYUcGU9RSqIDCzZI9/m3PHLqoo9Gh+MXFv039slHvQkCYn1KQL8L1hp Unc/z2rw==; Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50736 helo=server.local) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from <esq@HIDDEN>) id 1dHDBB-0005Mt-0Q for bug-gnu-emacs@HIDDEN; Sat, 03 Jun 2017 12:49:37 -0500 Date: Sat, 03 Jun 2017 10:49:36 -0700 Message-ID: <m2d1aldkr3.wl%esq@HIDDEN> From: Keith David Bershatsky <esq@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Exim-ID: 1dHDBB-0005Mt-0Q X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.local) [45.48.239.195]:50736 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -4.0 (----) In developing a fork of the popular undo-tree.el library (new features, enhancements, and bug-fixes), I found the following areas in `truncate_undo_list` that could use some improvements: 1. User-defined exclusions; e.g., a list of elements that will not be truncated unless the user has crossed the `undo-outer-limit' threshold. EXAMPLE: (defvar truncate-undo-list-exclusions '(undo-tree-canary) "A list of user defined elements that will not be truncated during garbage collection unless the user has reached the `undo-outer-limit`, in which case ....") 2. User-enabled messages/warnings when truncation is occurring due to the `undo-limit`, or the `undo-strong-limit`, and some type of indication as to what was thrown out. EXAMPLE: (defvar truncate-undo-list-warnings t "When non-nil, the internal function `truncate_undo_list' will generate messages letting the user know that he/she has crossed the `undo-limit` or `undo-strong-limit`, along with a shortened (redacted) list of what is being truncated (mentioning the specific limit crossed).) 3. Some type of documentation system enabling a user to read about `truncate_undo_list'; e.g., consolidate the comments that are presently only visible if the user visits the source-code and add some additional information about the new features mentioned above. BACKGROUND: Here is a reprint of the thread that I launched on emacs.stackexchange.com explaining my use-case and thoughts about a potential workaround: https://emacs.stackexchange.com/q/33248/2287 **Q**: How to preserve the last entry in the `buffer-undo-list` when garbage collection occurs? When using `undo-tree.el`, the library relies upon an `undo-tree-canary` being at the end of the `buffer-undo-list`. Emacs performs garbage collection **before** the Lisp code in `undo-tree` does its thing -- i.e.,`truncate_undo_list` in `undo.c` is activated and sometimes the `undo-tree-canary` is truncated. [A good example of this is where there is a programmatic `delete-region` followed by `insert` of significant amounts of different text, such as sorting certain sections of a buffer by `sort-reorder-buffer`, etc.] The default behavior of `undo-tree` is to begin a new `buffer-undo-tree` when a canary cannot be found -- i.e., the user loses all prior saved history. [See `undo-list-transfer-to-tree`.] In looking at the C-source code in `truncate_undo_list` I see the following relevant section from a `while` loop that goes through the `buffer-undo-list` when figuring out whether to truncate before or after an undo-boundary (which is a `nil` entry): /* When we get to a boundary, decide whether to truncate either before or after it. The lower threshold, undo_limit, tells us to truncate after it. If its size pushes past the higher threshold undo_strong_limit, we truncate before it. */ if (NILP (elt)) { if (size_so_far > undo_strong_limit) break; last_boundary = prev; if (size_so_far > undo_limit) break; } The relevant default values are as follows: `undo-limit`: 80000 `undo-strong-limit`: 120000 `undo-outer-limit`: 12000000 It looks like I may be able to set `undo-limit` to *the same value* as `undo-strong-limit` and thereby force truncation to always occur *before* the undo-boundary, but I'm not 100% certain that is the case. Additionally, I am concerned that if I set `undo-limit` to *the same value* as `undo-strong-limit`, that the earliest entries in the `buffer-undo-list` will always be truncated before subsequent entries. If that is the case, then this *may* be a bad thing .... One drastic solution would be to modify `truncate_undo_list` to look for a `symbol` in the list and preserve it; however, that only benefits me if I run a custom version of Emacs. I'm working on developing a fork of `undo-tree.el`, and I'd like a solution that other people can use with the stock version of Emacs. [*CAVEAT*: It is my assumption that the `buffer-undo-tree` that existed prior to garbage collection truncation as discussed above will still be usable after truncation occurs. I hope this is the case, but if that is a wrong assumption on my part, then please let me know. In my mind, I'm thinking of a major reorganization of the buffer where text is deleted and new text is inserted.]
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Keith David Bershatsky <esq@HIDDEN> Subject: bug#27214: Acknowledgement (truncate_undo_list in undo.c: exclusions, warnings, documentation.) Message-ID: <handler.27214.B.14965122098360.ack <at> debbugs.gnu.org> References: <m2d1aldkr3.wl%esq@HIDDEN> X-Gnu-PR-Message: ack 27214 X-Gnu-PR-Package: emacs Reply-To: 27214 <at> debbugs.gnu.org Date: Sat, 03 Jun 2017 17:51:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-gnu-emacs@HIDDEN If you wish to submit further information on this problem, please send it to 27214 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 27214: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D27214 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#27214: truncate_undo_list in undo.c: exclusions, warnings, documentation. References: <m2d1aldkr3.wl%esq@HIDDEN> In-Reply-To: <m2d1aldkr3.wl%esq@HIDDEN> Resent-From: Keith David Bershatsky <esq@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Wed, 05 Jul 2017 14:18:02 +0000 Resent-Message-ID: <handler.27214.B27214.149926423430372 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 27214 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 27214 <at> debbugs.gnu.org Received: via spool by 27214-submit <at> debbugs.gnu.org id=B27214.149926423430372 (code B ref 27214); Wed, 05 Jul 2017 14:18:02 +0000 Received: (at 27214) by debbugs.gnu.org; 5 Jul 2017 14:17:14 +0000 Received: from localhost ([127.0.0.1]:53528 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1dSl7C-0007tn-5o for submit <at> debbugs.gnu.org; Wed, 05 Jul 2017 10:17:14 -0400 Received: from gateway34.websitewelcome.com ([192.185.149.105]:29753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <esq@HIDDEN>) id 1dSl7A-0007tf-77 for 27214 <at> debbugs.gnu.org; Wed, 05 Jul 2017 10:17:12 -0400 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway34.websitewelcome.com (Postfix) with ESMTP id AB078635D8 for <27214 <at> debbugs.gnu.org>; Wed, 5 Jul 2017 09:17:11 -0500 (CDT) Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id Sl73dClS8ZqNPSl73dli20; Wed, 05 Jul 2017 09:17:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=CKtqCoJ0JURngjMlFtV2aOn2Eta7suw5gl4r8ioWiA4=; b=aKu5TeIPX0QOtOi5OyTMdZhIU+ nIdy8RyE5NrSfMj5mI6iU8ZY17CzmY/mGNx1duT2tTVsHA8fdWPysuXzBVqrCud2vMwAStFnoXTiA Z8sBubq0NJocFI+G/Ca7dxdJxAuwGOmpHELFx0yNXHqyNlInbmjnAxIEkkmKDuhovBjTTmuSbYcta nO1Oy/RT2UGo5RvoC5UpGEmukpjw8w25o6IrYSIVED9duMyS2hZEcEX7KZbc8KX54Nca4/NpaNqLz nNjT8/5tIOf8b/dHZeQmrr3tuE3jl7vpqtIHZQqEmFNWRjRtFWzzvzmUrF0R6dzRXCe2NJ6Mb17k5 gw2+XYHg==; Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:49496 helo=server.local) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from <esq@HIDDEN>) id 1dSl77-00378G-DE for 27214 <at> debbugs.gnu.org; Wed, 05 Jul 2017 09:17:09 -0500 Date: Wed, 05 Jul 2017 07:17:08 -0700 Message-ID: <m2r2xvt1cr.wl%esq@HIDDEN> From: Keith David Bershatsky <esq@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Exim-ID: 1dSl77-00378G-DE X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.local) [45.48.239.195]:49496 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.5 (/) Here is an example of how I am modifying `undo.c` for my own usage, which is specifically tailored to the undo-tree.el library and also the fork that I am working on: In the definition for `syms_of_undo`, add the following: DEFSYM (Qundo_tree_canary, "undo-tree-canary"); And, modify `truncate_undo_list` as follows -- the modified section is labeled with an "undo-tree" notation: void truncate_undo_list (struct buffer *b) { Lisp_Object list; Lisp_Object prev, next, last_boundary; EMACS_INT size_so_far = 0; /* Make sure that calling undo-outer-limit-function won't cause another GC. */ ptrdiff_t count = inhibit_garbage_collection (); /* Make the buffer current to get its local values of variables such as undo_limit. Also so that Vundo_outer_limit_function can tell which buffer to operate on. */ record_unwind_current_buffer (); set_buffer_internal (b); list = BVAR (b, undo_list); prev = Qnil; next = list; last_boundary = Qnil; /* If the first element is an undo boundary, skip past it. */ if (CONSP (next) && NILP (XCAR (next))) { /* Add in the space occupied by this element and its chain link. */ size_so_far += sizeof (struct Lisp_Cons); /* Advance to next element. */ prev = next; next = XCDR (next); } /* Always preserve at least the most recent undo record unless it is really horribly big. Skip, skip, skip the undo, skip, skip, skip the undo, Skip, skip, skip the undo, skip to the undo bound'ry. */ while (CONSP (next) && ! NILP (XCAR (next))) { Lisp_Object elt; elt = XCAR (next); /* Add in the space occupied by this element and its chain link. */ size_so_far += sizeof (struct Lisp_Cons); if (CONSP (elt)) { size_so_far += sizeof (struct Lisp_Cons); if (STRINGP (XCAR (elt))) size_so_far += (sizeof (struct Lisp_String) - 1 + SCHARS (XCAR (elt))); } /* Advance to next element. */ prev = next; next = XCDR (next); } /* If by the first boundary we have already passed undo_outer_limit, we're heading for memory full, so offer to clear out the list. */ if (INTEGERP (Vundo_outer_limit) && size_so_far > XINT (Vundo_outer_limit) && !NILP (Vundo_outer_limit_function)) { Lisp_Object tem; /* Normally the function this calls is undo-outer-limit-truncate. */ tem = call1 (Vundo_outer_limit_function, make_number (size_so_far)); if (! NILP (tem)) { /* The function is responsible for making any desired changes in buffer-undo-list. */ unbind_to (count, Qnil); return; } } if (CONSP (next)) last_boundary = prev; /* Keep additional undo data, if it fits in the limits. */ while (CONSP (next)) { Lisp_Object elt; elt = XCAR (next); /* When we get to a boundary, decide whether to truncate either before or after it. The lower threshold, undo_limit, tells us to truncate after it. If its size pushes past the higher threshold undo_strong_limit, we truncate before it. */ if (NILP (elt)) { if (size_so_far > undo_strong_limit) break; last_boundary = prev; if (size_so_far > undo_limit) break; } /* Add in the space occupied by this element and its chain link. */ size_so_far += sizeof (struct Lisp_Cons); if (CONSP (elt)) { size_so_far += sizeof (struct Lisp_Cons); if (STRINGP (XCAR (elt))) size_so_far += (sizeof (struct Lisp_String) - 1 + SCHARS (XCAR (elt))); } /* Advance to next element. */ prev = next; next = XCDR (next); } /* If we scanned the whole list, it is short enough; don't change it. */ if (NILP (next)) ; /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ /* undo-tree */ /* Truncate at the boundary where we decided to truncate. */ else if (!NILP (last_boundary)) { if (Fmemq (Qundo_tree_canary, last_boundary)) { AUTO_STRING (my_string, "truncate_undo_list: %s"); CALLN (Fmessage, my_string, last_boundary); } else XSETCDR (last_boundary, Qnil); } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ /* There's nothing we decided to keep, so clear it out. */ else bset_undo_list (b, Qnil); unbind_to (count, Qnil); }
X-Loop: help-debbugs@HIDDEN Subject: bug#27214: truncate_undo_list in undo.c: exclusions, warnings, documentation. References: <m2d1aldkr3.wl%esq@HIDDEN> In-Reply-To: <m2d1aldkr3.wl%esq@HIDDEN> Resent-From: Keith David Bershatsky <esq@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Wed, 19 Jul 2017 22:42:01 +0000 Resent-Message-ID: <handler.27214.B27214.150050409427660 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 27214 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 27214 <at> debbugs.gnu.org Received: via spool by 27214-submit <at> debbugs.gnu.org id=B27214.150050409427660 (code B ref 27214); Wed, 19 Jul 2017 22:42:01 +0000 Received: (at 27214) by debbugs.gnu.org; 19 Jul 2017 22:41:34 +0000 Received: from localhost ([127.0.0.1]:48284 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1dXxew-0007C3-5r for submit <at> debbugs.gnu.org; Wed, 19 Jul 2017 18:41:34 -0400 Received: from gateway33.websitewelcome.com ([192.185.146.68]:25099) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <esq@HIDDEN>) id 1dXxeu-0007Bv-0M for 27214 <at> debbugs.gnu.org; Wed, 19 Jul 2017 18:41:32 -0400 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 9890086688 for <27214 <at> debbugs.gnu.org>; Wed, 19 Jul 2017 17:41:29 -0500 (CDT) Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id XxfQdyU5mnlKZXxfQd7812; Wed, 19 Jul 2017 17:42:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=mwvUdaP825xrFNLyHohpZkYk7qj1FxqkCR320XTWRG8=; b=k5iR8KHy0/V8beZDwCBShIFER0 oqw/wr+m+uyLogMnmYLifodr+lIw6+1VjbFWTC1lR/fwiBBH5TtFDi8lXLERAtb8X8oqAtjEe3uC6 yU7pQ6oGy+00R4bRw9VtUthCjKGQGvdQ60KJtDbWykGRX0Vc9Xjv+f5leskc7IADV+Owhx5Xs04OW 0SGqyJvr3um2Jcuw0jw8vNWFH/uy6if9XDKbwqQ2bUqF3C2PdFS3RZ25/95Ej54Qz29rQwOxBcCzs 5SZQD5FvTwAkVvUY0e3WsNv02ioLiVfA9HoY7/nRppcrgXq+WCP2IALJar45/Cxp9R2n4b07VWFPi FwScvO9g==; Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50045 helo=server.local) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from <esq@HIDDEN>) id 1dXxeq-0036xZ-S2 for 27214 <at> debbugs.gnu.org; Wed, 19 Jul 2017 17:41:29 -0500 Date: Wed, 19 Jul 2017 15:41:27 -0700 Message-ID: <m2y3rkvylk.wl%esq@HIDDEN> From: Keith David Bershatsky <esq@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Exim-ID: 1dXxeq-0036xZ-S2 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.local) [45.48.239.195]:50045 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.0 (/) I opted to prevent truncate_undo_list from truncating the buffer-undo-list when undo-tree-canary is present, except if the undo-outer-limit is exceeded. Here is the revision: /* At garbage collection time, make an undo list shorter at the end, returning the truncated list. How this is done depends on the variables undo-limit, undo-strong-limit and undo-outer-limit. In some cases this works by calling undo-outer-limit-function. */ void truncate_undo_list (struct buffer *b) { Lisp_Object list; Lisp_Object prev, next, last_boundary; EMACS_INT size_so_far = 0; /* Make sure that calling undo-outer-limit-function won't cause another GC. */ ptrdiff_t count = inhibit_garbage_collection (); /* Make the buffer current to get its local values of variables such as undo_limit. Also so that Vundo_outer_limit_function can tell which buffer to operate on. */ record_unwind_current_buffer (); set_buffer_internal (b); list = BVAR (b, undo_list); prev = Qnil; next = list; last_boundary = Qnil; /* If the first element is an undo boundary, skip past it. */ if (CONSP (next) && NILP (XCAR (next))) { /* Add in the space occupied by this element and its chain link. */ size_so_far += sizeof (struct Lisp_Cons); /* Advance to next element. */ prev = next; next = XCDR (next); } /* Always preserve at least the most recent undo record unless it is really horribly big. Skip, skip, skip the undo, skip, skip, skip the undo, Skip, skip, skip the undo, skip to the undo bound'ry. */ while (CONSP (next) && ! NILP (XCAR (next))) { Lisp_Object elt; elt = XCAR (next); /* Add in the space occupied by this element and its chain link. */ size_so_far += sizeof (struct Lisp_Cons); if (CONSP (elt)) { size_so_far += sizeof (struct Lisp_Cons); if (STRINGP (XCAR (elt))) size_so_far += (sizeof (struct Lisp_String) - 1 + SCHARS (XCAR (elt))); } /* Advance to next element. */ prev = next; next = XCDR (next); } /* If by the first boundary we have already passed undo_outer_limit, we're heading for memory full, so offer to clear out the list. */ if (INTEGERP (Vundo_outer_limit) && size_so_far > XINT (Vundo_outer_limit) && !NILP (Vundo_outer_limit_function)) { Lisp_Object tem; /* Normally the function this calls is undo-outer-limit-truncate. */ tem = call1 (Vundo_outer_limit_function, make_number (size_so_far)); if (! NILP (tem)) { /* The function is responsible for making any desired changes in buffer-undo-list. */ unbind_to (count, Qnil); return; } } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ /* undo-tree */ if (CONSP (list) && ! NILP (Fmemq (Qundo_tree_canary, list))) { unbind_to (count, Qnil); return; } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ if (CONSP (next)) last_boundary = prev; /* Keep additional undo data, if it fits in the limits. */ while (CONSP (next)) { Lisp_Object elt; elt = XCAR (next); /* When we get to a boundary, decide whether to truncate either before or after it. The lower threshold, undo_limit, tells us to truncate after it. If its size pushes past the higher threshold undo_strong_limit, we truncate before it. */ if (NILP (elt)) { if (size_so_far > undo_strong_limit) break; last_boundary = prev; if (size_so_far > undo_limit) break; } /* Add in the space occupied by this element and its chain link. */ size_so_far += sizeof (struct Lisp_Cons); if (CONSP (elt)) { size_so_far += sizeof (struct Lisp_Cons); if (STRINGP (XCAR (elt))) size_so_far += (sizeof (struct Lisp_String) - 1 + SCHARS (XCAR (elt))); } /* Advance to next element. */ prev = next; next = XCDR (next); } /* If we scanned the whole list, it is short enough; don't change it. */ if (NILP (next)) ; /* Truncate at the boundary where we decided to truncate. */ else if (!NILP (last_boundary)) XSETCDR (last_boundary, Qnil); /* There's nothing we decided to keep, so clear it out. */ else bset_undo_list (b, Qnil); unbind_to (count, Qnil); } void syms_of_undo (void) { /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ /* undo-tree */ DEFSYM (Qundo_tree_canary, "undo-tree-canary"); /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ * * *
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.