From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#16804: 24.3.50; [PATCH] fix with-silent-modifications Date: Thu, 20 Feb 2014 09:01:08 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1392904935 16630 80.91.229.3 (20 Feb 2014 14:02:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Feb 2014 14:02:15 +0000 (UTC) Cc: 16804@debbugs.gnu.org To: Leo Liu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 20 15:02:22 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WGUCi-0004MA-HJ for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Feb 2014 15:02:20 +0100 Original-Received: from localhost ([::1]:38783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGUCi-0003W8-6U for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Feb 2014 09:02:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGUCY-0003Un-7u for bug-gnu-emacs@gnu.org; Thu, 20 Feb 2014 09:02:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGUCQ-00072o-St for bug-gnu-emacs@gnu.org; Thu, 20 Feb 2014 09:02:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60231) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGUCQ-00072c-QU for bug-gnu-emacs@gnu.org; Thu, 20 Feb 2014 09:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WGUCP-0004il-S4 for bug-gnu-emacs@gnu.org; Thu, 20 Feb 2014 09:02:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 Feb 2014 14:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16804 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 16804-submit@debbugs.gnu.org id=B16804.139290488718084 (code B ref 16804); Thu, 20 Feb 2014 14:02:01 +0000 Original-Received: (at 16804) by debbugs.gnu.org; 20 Feb 2014 14:01:27 +0000 Original-Received: from localhost ([127.0.0.1]:33180 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WGUBq-0004hZ-0Y for submit@debbugs.gnu.org; Thu, 20 Feb 2014 09:01:26 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:27007) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WGUBe-0004h9-Dy for 16804@debbugs.gnu.org; Thu, 20 Feb 2014 09:01:24 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFLd/o4/2dsb2JhbABEuzWDWRdzgh4BAQQBJy8jBQsLDiYSFBgNJIgeBsEtkQoDiGGcGYFegxWBSAIeBAI X-IPAS-Result: Av8EABK/CFFLd/o4/2dsb2JhbABEuzWDWRdzgh4BAQQBJy8jBQsLDiYSFBgNJIgeBsEtkQoDiGGcGYFegxWBSAIeBAI X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="48226638" Original-Received: from 75-119-250-56.dsl.teksavvy.com (HELO pastel.home) ([75.119.250.56]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 20 Feb 2014 09:01:08 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 51D64600EB; Thu, 20 Feb 2014 09:01:08 -0500 (EST) In-Reply-To: (Leo Liu's message of "Thu, 20 Feb 2014 13:57:59 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:85937 Archived-At: >> That doesn't change anything to the fact that calling something like >> sit-for from within a with-silent-modifications is a problem, regardless >> of buffer-file-name. E.g. it will cause the process filter not to mark >> the new text for highlighting, so it can screw up *compilation*. > I see. Could you help document the delicacy of > with-silent-modifications, or people will not correctly use it? Actually, the issue is not with with-silent-modifications but with sit-for and other yielding functions: you should be careful to call them from within the "plainest" context possible, since any dynamic-binding (or other temporary global change, such as moving point) currently active will then leak to any timer/filter/sentinel/redisplay that might be run at that point. >>>> Again, a backtrace would be much more useful. >>> There is no backtrace. >> Of course there is. I know there is no error signaled, but you can >> still get a backtrace by calling (backtrace), or (debug). > Since input-pending-p is changed in 24.4 not to run timers by default, > the backtrace is obtained in 24.3 and as expected: Ah, right, input-pending-p shouldn't be a yield point, which we recently fixed, so it should be OK to call input-pending-p from "anywhere". Can you reproduce the problem in 24.4 (and show the backtrace)? > nxml has both input-pending-p and sit-for, see > rng-validate-while-idle-continue-p in rng-valid.el Indeed, I see (with-silent-modifications (rng-do-some-validation-1 continue-p-function)))) where continue-p-function can be rng-validate-while-idle-continue-p which calls sit-for (to cause a redisplay). So we have a similar bug there. > Is there something better than let-binding buffer-file-name and > buffer-file-truename? I have the patch below for 24.5 which makes it unnecessary for with-silent-modifications to bind buffer-file-name and buffer-file-truename (by strengthening the meaning of inhibit-modification-hooks), but that doesn't magically fix the above problems :-( Stefan === modified file 'lisp/subr.el' --- lisp/subr.el 2014-02-12 19:40:35 +0000 +++ lisp/subr.el 2014-02-19 15:04:50 +0000 @@ -3176,12 +3176,7 @@ `(let* ((,modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) - (inhibit-modification-hooks t) - deactivate-mark - ;; Avoid setting and removing file locks and checking - ;; buffer's uptodate-ness w.r.t the underlying file. - buffer-file-name - buffer-file-truename) + (inhibit-modification-hooks t)) (unwind-protect (progn ,@body) === modified file 'src/insdel.c' --- src/insdel.c 2014-01-01 17:44:48 +0000 +++ src/insdel.c 2014-02-19 15:03:17 +0000 @@ -1829,6 +1829,9 @@ else base_buffer = current_buffer; + if (inhibit_modification_hooks) + return; + #ifdef CLASH_DETECTION if (!NILP (BVAR (base_buffer, file_truename)) /* Make binding buffer-file-name to nil effective. */ @@ -1848,7 +1851,6 @@ /* If `select-active-regions' is non-nil, save the region text. */ /* FIXME: Move this to Elisp (via before-change-functions). */ if (!NILP (BVAR (current_buffer, mark_active)) - && !inhibit_modification_hooks && XMARKER (BVAR (current_buffer, mark))->buffer && NILP (Vsaved_region_selection) && (EQ (Vselect_active_regions, Qonly) @@ -1959,9 +1961,6 @@ ptrdiff_t count = SPECPDL_INDEX (); struct rvoe_arg rvoe_arg; - if (inhibit_modification_hooks) - return; - start = make_number (start_int); end = make_number (end_int); preserve_marker = Qnil;