Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird interplay with purpose mode #237

Open
xuan-w opened this issue Mar 7, 2024 · 3 comments
Open

Weird interplay with purpose mode #237

xuan-w opened this issue Mar 7, 2024 · 3 comments

Comments

@xuan-w
Copy link

xuan-w commented Mar 7, 2024

When I invoke (gptel) directly, I got the following error:

It seems that this has something to do with purpose mode (I use Spacemacs, it includes purpose mode). Since purpose mode hasn't been updated for 3 years and the only thing I updated was gptel, I guess gptel introduced some changes?

Here is the error I encountered:

Debugger entered--Lisp error: (void-function user-action-sequence)
  user-action-sequence(#<buffer *ChatGPT*> ((user-action-sequence user-action-sequence pop-to-buffer)))
  purpose--action-function(#<buffer *ChatGPT*> nil)
  #<subr display-buffer>(#<buffer *ChatGPT*> ((user-action-sequence pop-to-buffer)) nil)
  purpose-display-buffer-advice(#<subr display-buffer> #<buffer *ChatGPT*> ((user-action-sequence pop-to-buffer)) nil)
  apply(purpose-display-buffer-advice #<subr display-buffer> (#<buffer *ChatGPT*> ((user-action-sequence pop-to-buffer))))
  display-buffer(#<buffer *ChatGPT*> ((user-action-sequence pop-to-buffer)))
  #<subr pop-to-buffer>(#<buffer *ChatGPT*> ((user-action-sequence pop-to-buffer)) nil)
  purpose-pop-to-buffer-advice(#<subr pop-to-buffer> #<buffer *ChatGPT*> ((user-action-sequence pop-to-buffer)) nil)
  apply(purpose-pop-to-buffer-advice #<subr pop-to-buffer> (#<buffer *ChatGPT*> ((user-action-sequence pop-to-buffer))))
  pop-to-buffer(#<buffer *ChatGPT*> ((user-action-sequence pop-to-buffer)))
  purpose--action-function(#<buffer *ChatGPT*> nil)
  #<subr display-buffer>(#<buffer *ChatGPT*> (pop-to-buffer) nil)
  purpose-display-buffer-advice(#<subr display-buffer> #<buffer *ChatGPT*> (pop-to-buffer) nil)
  apply(purpose-display-buffer-advice #<subr display-buffer> (#<buffer *ChatGPT*> (pop-to-buffer)))
  display-buffer(#<buffer *ChatGPT*> (pop-to-buffer))
  gptel("*ChatGPT*" "sk-***********************************************..." nil t)
  funcall-interactively(gptel "*ChatGPT*" "sk-***********************************************..." nil t)
  command-execute(gptel record)
  helm-M-x-execute-command(gptel)

I went back and checked, it seems that gptel Feb 09 version was OK (at least in my memory) and on Feb 10 gptel add a variable to customize the pop up window behavior.

So the old code was

      (pop-to-buffer (current-buffer))

Now it is

      (display-buffer (current-buffer) gptel-display-buffer-action)

Actually got called was (display-buffer (current-buffer) '(pop-to-buffer)) with default value of gptel-display-buffer-action.

It seems that pop-to-buffer actually call display-buffer to do the work (got this from pop-to-buffer doc) so display-buffer is called again (my understanding could be wrong). Somehow with purpose's advice, when display-buffer got called again, an error was throwed.

First time display-buffer got called, it is display-buffer(#<buffer *ChatGPT*> (pop-to-buffer)), which is fine.
Second time, it is #<subr display-buffer>(#<buffer *ChatGPT*> ((user-action-sequence pop-to-buffer)) nil), which doesn't match display-buffer's args.

This is the furthest I can dig, any suggestions? I am not sure if it is purpose mode too old to be compatible with latest Emacs or there is something can make gptel works happily with purpose mode.

Personally, I wrote a custom function in my .emacs to create a chat buffer and call gptel-send so I wasn't affected much. (That is why I only found it out after a month).

@BenedictHW
Copy link

I use Spacemacs, and I can confirm that I have the same bug. However the ChatGPT markdown buffer is created, I can see it when call "list-buffers". It is when I call M-x "gptel" for the second consecutive time that the "user-action-sequence" error pops up.

Great package Karthink, it's been a real pleasure to use.

@mch
Copy link

mch commented Apr 13, 2024

I also have this problem with spacemacs. I don't use the purpose layer, and was able to solve this by excluding the window-purpose package in my .spacemacs file:

   ;; A list of packages that will not be installed and loaded.
   dotspacemacs-excluded-packages '(window-purpose)

It is strange that this package specifically has this problem though.

@karthink
Copy link
Owner

Thank you for the reports. I'll take a look at what purpose-mode is doing when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants