wyuenho / emacs-pet

Tracks down the correct Python tooling executables from your virtualenvs so you can glue the binaries to Emacs and delete code in init.el
GNU General Public License v3.0
105 stars 13 forks source link

Error in installation for newer emacs version #34

Closed tusharhero closed 3 months ago

tusharhero commented 6 months ago

Description Error when installing using use-package to install.

Reproduction steps

  1. Run this:
    (use-package pet
    :config
    (add-hook 'python-base-mode-hook 'pet-mode -10))
  2. Error
    
    ⛔ Error (use-package): pet/:catch: Eager macro-expansion failure: (error "Unsupported QPAT: (\\,@ _)")

**Expected behavior**
PET installs and works.

**PET version**
latest
**Emacs version**
GNU Emacs 30.0.50 (build 16, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0) of 2024-02-28

**Desktop (please complete the following information):**
 - OS: Fedora Kionite
 - Version

**Additional context**
It looks like https://github.com/wyuenho/emacs-pet/blob/main/pet.el#L279C8-L279C45 is using incorrect pcase pattern that happens to work by accident. The newer Emacs notices incorrect pattern and throws an error. AFAIU, you can change the pcase pattern to pcase-let ((`(,_ ,action ,file) event)) 
--- @yantar92
wyuenho commented 6 months ago

Emacs 30 has not been released yet.

tusharhero commented 6 months ago

The fix by yantar92 seems to be simple enough?

yantar92 commented 6 months ago

Jimmy Yuen Ho Wong @.***> writes:

Emacs 30 has not been released yet.

Yes, but the code is still just working by chance; because of undocumented behavior of `pcase-let'.

`(, ,action ,file ,@) pcase pattern is simply invalid.

Let me illustrate using Emacs 28:

(pcase '(foo bar baz test) (`(, ,action ,file ,@) (list action file))) ; => nil

As you can see, the pattern you use does not match what you expect.

The correct pattern would be:

(pcase '(foo bar baz test) (`(, ,action ,file . ,) (list action file))) ; (bar baz)

-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92

wyuenho commented 6 months ago

@tusharhero ^ that doesn't look like your PR

tusharhero commented 6 months ago

Oh yeah, I just did what they had told me would fix it in group chat. I have been using the fork myself and it seems to work. But I will try this fix as well to see if it works.