xenodium / chatgpt-shell

A multi-llm Emacs shell (ChatGPT, Claude, Gemini, Kagi, Ollama, Perplexity) + editing integrations
https://lmno.lol/alvaro
GNU General Public License v3.0
868 stars 77 forks source link

How to recenter? #51

Closed agzam closed 1 year ago

agzam commented 1 year ago

Whenever I press <RET>, the text in *chatgpt* buffer shifts downwards, I'd like to recenter it. I couldn't find any dedicated hooks in the package source. I'm thinking about advising, which function do you think would be the best to override, or set :after/:before function at?

xenodium commented 1 year ago

Whenever I press , the text in chatgpt buffer shifts downwards

Can you share a bit more? Is this not typically expected?

Do you happen to have the behaviour you'd like in another shell? Maybe show how that one is configured?

In terms of hooks, chatgpt-shell is comint-based, so all same hooks should available there too.

agzam commented 1 year ago

Can you share a bit more? Is this not typically expected?

I'm not entirely sure as I've just started using the package, but I've noticed that the prompt always ends up at the bottom. For some reason, I think I might prefer it to be (recenter)ed. However, I could be wrong, and I plan to experiment with it some more. By the way, I probably should have added a disclaimer that this is not an actual issue or complaint. I opened it as a means for discussion.

xenodium commented 1 year ago

but I've noticed that the prompt always ends up at the bottom.

A benefit is that with ChatGPT giving long answers, keeping the prompt at the bottom increases the amount of readable output/response text. Having said that, prolly just user preference.

I think I might prefer it to be (recenter)ed

With the latest, you should be able to do something like

(defun my/chatgpt-shell-recenter (_command _output)
  (recenter))

(add-hook 'chatgpt-shell-after-command-functions
          'my/chatgpt-shell-recenter)

I've just renamed the variable to behave like an abnormal hook. Lemme know if you run into issues.

By the way, I probably should have added a disclaimer that this is not an actual issue or complaint. I opened it as a means for discussion.

No worries! Didn't think it was a coimplaint.

agzam commented 1 year ago

Very nice. Thank you. I have started using other commands like chatgp-shell-proofreading-doc more, and I'm not typing directly in the "chatgpt repl" as much as before. And I still can't decide which way I prefer better: the default or recentered. But having multiple choices is great. I appreciate you taking the time to add the hook. Honestly, I didn't expect you to respond with new code so quickly. I'll try to be careful next time with expressing what I wish for 😄

xenodium commented 1 year ago

I appreciate you taking the time to add the hook. Honestly, I didn't expect you to respond with new code so quickly.

👍

I'll try to be careful next time with expressing what I wish for 😄

All good. Looks like we can close this issue now. Please reopen if otherwise.