From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 0GzyAjYpoV8mXwAA0tVLHw (envelope-from ) for ; Tue, 03 Nov 2020 09:56:06 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id EKZuOjUpoV8yZwAAbx9fmQ (envelope-from ) for ; Tue, 03 Nov 2020 09:56:05 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5FA019403E6 for ; Tue, 3 Nov 2020 09:56:05 +0000 (UTC) Received: from localhost ([::1]:39218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZt2p-000169-BH for larch@yhetil.org; Tue, 03 Nov 2020 04:56:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZt0q-0007qs-Jm for emacs-orgmode@gnu.org; Tue, 03 Nov 2020 04:54:00 -0500 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]:40365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kZt0o-00063V-ET for emacs-orgmode@gnu.org; Tue, 03 Nov 2020 04:54:00 -0500 Received: by mail-lj1-x22c.google.com with SMTP id 23so18297550ljv.7 for ; Tue, 03 Nov 2020 01:53:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+616G4rcqI0yqgc8FYIRERPPe+P52ASrAVtS1sg68AE=; b=YbCrbErQ8q3jWL4JKa4C+Ggs33X75i2sxErExI3zRX3PpfjalH5qudV/krB0fgabAA PqkBsgQ07lZ9mixEqSiQQNRWRFvWDYeqvyG2zhDFhntYdyy0+KsQp4mzP47TkY/1DbFE x6ViTGSkIXsVGbXmjhEd4lmoB0hIwI6T6mkY25xyiZdDlP8vLdNdGxYlpQLdDM0xgVgv wZnzRsKPMsDdiy6NWRjJuHiN/cErdYAz5mBJWABJuWL7e7NySGIxCPfVt/Wo2keJtkaC Wdw0UrxFcyQusOruj4uHFtQg1cecThxS0U2iSRW++LUUezNH6FPyaepmf6YvznYRMall ZLUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+616G4rcqI0yqgc8FYIRERPPe+P52ASrAVtS1sg68AE=; b=JfNCrRTDZ87MQcUfKC895MgVr7RDl9/AKEYe6wRDkvdyiFuceA344CRF4wLzjQD0/Z cFVhki0BEsCB9TqhITNksM+VtY4/n5sg8x8yRGOUDOTUc245TLzV85ESBNvJ4RhZqwxO LsxP2HcLxwRtQX6HqctRQtlDccr2etnVlDpYSULsc16W2DTG52OLhqIWodvgWaYCXP/n KAHuQ/FgMad4P9SMz+PLJVFqDCKnSvfJJv5nAvm0YAA2JGluArpjvz9z22LjsnkKhb7P vdOwPVmMaTu2WLaLS3Ur6knIDJQT8mTBHOA7iLX3FsEzSonb1b/wK7Kn7NQv43e4zZY4 zJiQ== X-Gm-Message-State: AOAM532mfL9rppXX+71NPhQ1fpSIjzjK8w/8LYcJoUcpjdAeCzuhdEme Ab6i2dzIpwKDgzMmh96SXaCBU6O56dQZp7stKaM= X-Google-Smtp-Source: ABdhPJzfj8PPbEN9zfM5gDrcovsloMFiA35Hf8kRdeoK9PPbYTmX6JsXJjAEyO6+IZ34GOtNC00IzhxFzcIXl/Dv3X8= X-Received: by 2002:a05:651c:1a6:: with SMTP id c6mr6547831ljn.244.1604397235843; Tue, 03 Nov 2020 01:53:55 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sebastian Gimeno Date: Tue, 3 Nov 2020 10:53:44 +0100 Message-ID: Subject: Re: Org mode fontification error in # in python and ipython source blocks To: stardiviner Content-Type: multipart/alternative; boundary="0000000000005234d105b330d73b" Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=changimeno@gmail.com; helo=mail-lj1-x22c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org-mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=YbCrbErQ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: b3qkIQnHI317 --0000000000005234d105b330d73b Content-Type: text/plain; charset="UTF-8" Dear Stardiviner, I used the "scimax" configuration. Scimax's maintainer, John Kitchin, helped me out to find the root cause of the problem, i.e. the following addition to " python-font-lock-keywords": (setq python-font-lock-keywords (append python-font-lock-keywords '(;; this is the full string. ;; group 1 is the quote type and a closing quote is matched ;; group 2 is the string part ( ;; "f\\(['\"]\\{1,3\\}\\)\\([^\\1]+?\\)\\1" "f\\(['\"]\\{1,3\\}\\)\\(.+?\\)\\1" ;; these are the {keywords} ("{[^}]*?}" ;; Pre-match form (progn (goto-char (match-beginning 0)) (match-end 0)) ;; Post-match form (goto-char (match-end 0)) ;; face for this match (0 font-lock-variable-name-face t)))))) Commenting out this code snippet, the fontfying / HTML-export problem goes away. Cheers, sebastian On Tue, Nov 3, 2020 at 6:50 AM stardiviner wrote: > I have same problem sometimes in different babel languages. > I would like to know what caused this problem too. > Can you send me a message after you solved problem? Thanks in advance. :) > smile > > [stardiviner] GPG key ID: 47C32433 > IRC(freeenode): stardiviner Twitter: @numbchild > Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433 > Blog: http://stardiviner.github.io/ > > > On Mon, Nov 2, 2020 at 2:26 AM Sebastian Gimeno > wrote: > >> Hi, >> >> I am using emacs 27.1 and org-plus-contrib 20201026. >> >> I am having problems with the fontification of python and ipython source >> blocks when the code contains curly brackets "{}" (other course blocks are >> ok). For instance, the following snippet >> >> #+BEGIN_SRC python :results drawer >> import matplotlib.pyplot as plt >> plt.plot([1,2,3]) >> plt.show() >> a=1 >> print("a={}".format{a}) >> #+END_SRC >> >> does not fontify correctly in either python or ipython source blocks. >> >> As a consequence, when exporting the org file to HTML (C-c C-e h h), it >> fails with the following message: >> >> font-lock-fontify-keywords-region: Invalid function: # >> >> If changing the code snippet to: >> >> #+BEGIN_SRC python :results drawer >> import matplotlib.pyplot as plt >> plt.plot([1,2,3]) >> plt.show() >> a=1 >> print("a=%s" % a) >> #+END_SRC >> >> the block fontifies and the file is exported to HTML correctly. >> >> Can you reproduce this behaviour? >> >> Many thanks in advance! >> > --0000000000005234d105b330d73b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dear Stardiviner,

I used the "scimax" configuration. Scimax's maintainer= , John Kitchin, helped me out to find the root cause of the problem, i.e. t= he following addition to " python-font-lock-keywords":
<= br>
(setq python-font-lock-keywords=C2=A0 =C2=A0 =C2=A0 (append python-font-lock-keywords
=C2=A0 =C2=A0 = =C2=A0'(;; this is the full string.
;; group 1 is the quote type a= nd a closing quote is matched
;; group 2 is the string part
(
= ;; "f\\(['\"]\\{1,3\\}\\)\\([^\\1]+?\\)\\1"
&qu= ot;f\\(['\"]\\{1,3\\}\\)\\(.+?\\)\\1"
;; these are the = {keywords}
("{[^}]*?}"
=C2=A0;; Pre-match form
= =C2=A0(progn (goto-char (match-beginning 0)) (match-end 0))
=C2=A0;; = Post-match form
=C2=A0(goto-char (match-end 0))
=C2=A0;; face f= or this match
=C2=A0(0 font-lock-variable-name-face t))))))
=

Commenting out this code snippet, the fontfying / HTML-= export problem goes away.

Cheers,
sebast= ian




On Tue, Nov 3, = 2020 at 6:50 AM stardiviner <numb= child@gmail.com> wrote:
I have same problem sometimes in different = babel languages.
I would like to know what caused this problem too.
Can you send me a message after you solved problem? Thanks in advance. := ) smile

[stardiviner]=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 <Hack this world!>=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 GPG key ID: 47C32433
IRC(freeenode): stardiviner =C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 Twitter:=C2=A0 @numbchild
Key fingerprint = =3D 9BAA 92BC CDDD B9EF 3B36=C2=A0 CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.gi= thub.io/


On Mon, Nov 2, 2020 at 2:= 26 AM Sebastian Gimeno <changimeno@gmail.com> wrote:
Hi,
<= br>
I am using emacs 27.1 and=20 org-plus-contrib 20201026.

I am having problems with the fontification o= f python and ipython source blocks when the code = contains curly brackets "{}" (other course blocks are ok). For in= stance, the following snippet
#+BEGIN_SRC python :results drawer
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()
a=3D1
print("a=3D{}".format{a})
#+END_SRC

does not fontify correctly in either python or ipytho= n source blocks.

As a consequence, when exporting the org file to HTML (C-c C-e h h), it = fails with the following message:

font-lock-fontify-keywords-region: Invalid function: #<subr p=
rogn>

If changing the code snippet to:

#+BEGIN_SRC python :results drawer
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()
a=3D1
print("a=3D%s" % a)
#+END_SRC

the block fontifies and the file is exported to HTML correctly.

Can you reproduce this behaviour?

Many thanks in advance!

--0000000000005234d105b330d73b--