Org-mode mailing list
 help / color / mirror / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Sebastian Gimeno <changimeno@gmail.com>
Cc: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: Org mode fontification error in #<buffer myfile.org> in python and ipython source blocks
Date: Tue, 3 Nov 2020 10:55:03 -0500
Message-ID: <CAJ51ETpCToO8Y-JY0k4ekQNd-EJMrmXUf9OYZ9eJ_JTHbascHQ@mail.gmail.com> (raw)
In-Reply-To: <CAPUJosCnr-RCoZ-RurkM=pCjWN7gn=NGj4uG4SrRDukSGvaTcg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3145 bytes --]

Does anyone see anything wrong with that snippet? All it should do is
improve font-lock on Python f-strings, and it used to work fine, but now it
doesn't. It isn't real critical for me, so I don't mind commenting it out,
but I neither understand why it stopped working!

John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Tue, Nov 3, 2020 at 4:55 AM Sebastian Gimeno <changimeno@gmail.com>
wrote:

> 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 <numbchild@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]           <Hack this world!>      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 <changimeno@gmail.com>
>> 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: #<subr progn>
>>>
>>> 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!
>>>
>>

[-- Attachment #2: Type: text/html, Size: 5483 bytes --]

  reply	other threads:[~2020-11-03 15:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-31  2:01 Sebastian Gimeno
2020-11-01 20:19 ` Jack Kamm
2020-11-01 23:43   ` Sebastian Gimeno
2020-11-02  0:41     ` Sebastian Gimeno
2020-11-03  5:49 ` stardiviner
2020-11-03  9:53   ` Sebastian Gimeno
2020-11-03 15:55     ` John Kitchin [this message]
2020-11-04  3:10       ` Kyle Meyer
2020-11-04  3:22     ` stardiviner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://orgmode.org

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJ51ETpCToO8Y-JY0k4ekQNd-EJMrmXUf9OYZ9eJ_JTHbascHQ@mail.gmail.com \
    --to=jkitchin@andrew.cmu.edu \
    --cc=changimeno@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git