reddit / emacs

Outdated python.el (python-mode)

cumburgerdude · 2022-11-21 09:12
Hi there! Recently I was programming in Python and needed to use match/case construction. I found out that Emacs doesn't highlight those words. I thought that they aren't in keywords list and decided to make PR about it onto Emacs git repo. But as it turned out, match/case were already defined as keywords in python.el that was stored in the repo. So I looked at installed on my machine python.el and I saw that it was actually outdated and there were no those words in the list. I'm using latest version of Emacs. Could you tell me please, why is that happened and how to fix that properly (i mean, i shouldn't just manually replace my outdated python.el with newer one, should i?) Also sorry for possible misspellings 'cause English isn't my native language and sorry for stupid question, I'm newbie :) UPD: well, i tried to byte compile python.el from master branch, but it said me that it can't load file from string (require 'treesit). I tried to research what treesit is, but couldn't find anything reasonable. Probably that's something new that's coming out with new release or maybe some already existing package that I couldn't find information about. So I just added "match" and "case" in (defmarco python-rx ...) and (defvar python-font-lock-keywords-level-2 ...) and then byte-compiled it again and replaced files in lisp/progmodes with newer one. Don't know how proper this solution is, but it actually worked for me. Thanks for everybody who responsed!
in-some-other-way · 2022-11-21 13:38
You can either compile from master or wait for a version to cut containing the changes. Latest released version of emacs (28.2) doesn't have the python 3.10 keywords in the font lock list. If neither of these are possible you can update the definition of python-font-lock-keywords to include new keywords, but it's probably more work than you expect.
[deleted] · 2022-11-21 13:56
[deleted]
potpotkettle · 2022-11-21 14:02
It looks like the change was done in [May this year](https://github.com/emacsmirror/emacs/commit/35d0190b0b91c085c73bbe6c2b8e93ea8288b589#diff-f808b0589744f83f41d9f581e8b07001145598d2a2aa07fd40c1d20ee35df762R366) and is not yet released. > (i mean, i shouldn't just manually replace my outdated python.el with newer one, should i?) Maybe you can just try that after backing up the current python.el? I think in the worst case something doesn't work and you can go back to the old file. A lasting side effect is unlikely.
alexjgriffith · 2022-11-21 14:53
It you're not using the master build of emacs I'd recomend just replacing the package with the latest version. You can backup the old python.el if you wish. When replacing the package don't forget to also delete the compiled version (.elc) The latest version can be found at https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/python.el
cumburgerdude · 2022-11-21 22:39
Oh yeah, probably that's the reason. In that case I'll try to just replace it with newer one. Thank you for you answer
cumburgerdude · 2022-11-21 22:41
Thank you for your answer. To be honest, I wanna keep my emacs updated by pacman so I don't really want to compile it by sources. As another comment said, I should really just backup current python.el and replace with newer one. That's what I'll try to do. Otherwise, I can only wait for new version
mkleehammer · 2022-11-22 02:34
Copy the master Python mode file into your .emacs.d directory and load it manually. If you use use-package, it has easy support for doing so using :load-path (or something like that- I’m not at my desk). This is why bundling everything into the official EMacs is such a dumb idea. Language mode release cycles should be synchronized with the languages.
[deleted] · 2022-11-23 20:08
[deleted]