From mboxrd@z Thu Jan 1 00:00:00 1970 From: npostavs@users.sourceforge.net Subject: bug#25132: 26.0.50; emacs hangs when loading org file with python source blocks Date: Sat, 07 Jan 2017 16:20:16 -0500 Message-ID: <87eg0e36un.fsf@users.sourceforge.net> References: <4aa23451-b6cd-88b0-369e-99f6fe5f2175@gmail.com> <87y3yn2x4j.fsf@users.sourceforge.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPyPF-0000G4-N2 for emacs-orgmode@gnu.org; Sat, 07 Jan 2017 16:20:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPyPC-0005E2-Gb for emacs-orgmode@gnu.org; Sat, 07 Jan 2017 16:20:05 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87y3yn2x4j.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Sat, 07 Jan 2017 01:38:04 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: David Dynerman Cc: Glenn Morris , 25132@debbugs.gnu.org, =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel --=-=-= Content-Type: text/plain tags 25132 patch quit npostavs@users.sourceforge.net writes: > The problem is that org updates its temporary fontification buffer from > its fontify rules which are called by jit-lock-function, which means > that inhibit-modification-hooks is bound to t. Therefore, when > org-src-font-lock-fontify-block calls delete-region to remove leftover text from > the previous source block fontification, the `before-change-functions' > are not run. In this case `syntax-ppss-flush-cache' is the important > function that doesn't get run, so `syntax-propertize--done' is still set > from before and messes up python.el's fontification routines. I think with-silent-modifications should let-bind inhibit-modification-hooks buffer locally: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Inhibit-modification-hooks-buffer-locally.patch Content-Description: patch for master >From da4f1c0338b2b98f97a553568c4b80872484ee97 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 7 Jan 2017 15:47:37 -0500 Subject: [PATCH v1] Inhibit modification hooks buffer locally `with-silent-modifications' let-binds `inhibit-modification-hooks' to t globally. So modifications to other buffers don't trigger modication hooks. This causes unexpected results when functions called from `jit-lock-function' use temporary buffers and modifies them (Bug#25132). * lisp/subr.el (with-silent-modifications): Bind inhibit-modification-hooks buffer locally. --- lisp/subr.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/subr.el b/lisp/subr.el index 5377416..fe20d68 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3298,7 +3298,8 @@ with-silent-modifications `(let* ((,modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) - (inhibit-modification-hooks t)) + (inhibit-modification-hooks + (progn (make-local-variable 'inhibit-modification-hooks) t))) (unwind-protect (progn ,@body) -- 2.9.3 --=-=-= Content-Type: text/plain Perhaps the other variables it binds should be buffer local as well? This bug is new in Emacs 25.1, but changing with-silent-modifications is a bit risky. Therefore, I propose the following for the emacs-25 branch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Call-modification-hooks-in-org-src-fontify-buffer.patch Content-Description: patch for emacs-25 >From 338aa0c37eba0401616e8e02f0143a57edffd486 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 7 Jan 2017 16:05:19 -0500 Subject: [PATCH v1] Call modification hooks in org-src fontify buffers * lisp/org/org-src.el (org-src-font-lock-fontify-block): Let-bind `inhibit-modification-hooks' to nil, since this function can be called from jit-lock-function which binds that variable to t (Bug#25132). --- lisp/org/org-src.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el index d01f108..9b66907 100644 --- a/lisp/org/org-src.el +++ b/lisp/org/org-src.el @@ -913,8 +913,9 @@ org-src-font-lock-fontify-block (with-current-buffer (get-buffer-create (concat " org-src-fontification:" (symbol-name lang-mode))) - (delete-region (point-min) (point-max)) - (insert string " ") ;; so there's a final property change + (let ((inhibit-modification-hooks nil)) ; Avoid Bug#25132. + (delete-region (point-min) (point-max)) + (insert string " ")) ;; so there's a final property change (unless (eq major-mode lang-mode) (funcall lang-mode)) (org-font-lock-ensure) (setq pos (point-min)) -- 2.9.3 --=-=-=--