-
Notifications
You must be signed in to change notification settings - Fork 175
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
Activation of gptel-mode via org-mode-hook slightly misbehaves #440
Comments
To be clear, these issues don't occur when you run I have a couple unrelated comments for you:
|
I managed to work around the issue with flashing for now by using (defun gptel-setup-hook:nordlow ()
"Setup `gptel-mode' in `org-mode' or `markdown-mode' buffers.
Avoids screen flash on activation via use of `run-with-timer'.
See: https://github.com/karthink/gptel/issues/440."
(run-with-timer 0.1 nil (lambda ()
(when (derived-mode-p 'org-mode 'markdown-mode)
(gptel-mode 1)))))
(dolist (hook '(org-mode-hook markdown-mode-hook))
(add-hook hook 'gptel-setup-hook:nordlow)) . |
Ahh, no, no reason at all. Thanks. Will revert that change and see if things improve. Is it preferred to remove that configuration complete or set . In what way does gptel work better with curl, btw? |
That's cool, but it sounds like there might be a bug here, so I'm hoping to address it in gptel. I can't reproduce the screen flash or the duplicate entry -- in particular, turning on Is there anything else in your |
Exactly. |
My current org-mode-hook looks like
. I have a bunch of adjustments in it, yes. The bytecode hooks are from standard org-mode. |
It supports streaming responses, it's better tested, and the processing runs a little faster (at least on Linux). The
|
Ok, thanks. I'm also using (defun gptel-post-response-adjust:nordlow (_begin _end)
;; break long lines
;; (fill-paragraph nil (cons begin end))
;; (fill-region begin end)
(unless visual-line-mode
(visual-line-mode 1))) , btw. So altogether I currently have (defun gptel-post-response-adjust:nordlow (_begin _end)
;; break long lines
;; (fill-paragraph nil (cons begin end))
;; (fill-region begin end)
(unless visual-line-mode
(visual-line-mode 1)))
(defun gptel-setup-hook:nordlow ()
"Setup `gptel-mode' in `org-mode' or `markdown-mode' buffers.
Avoids screen flash on activation via use of `run-with-timer'.
See: https://github.com/karthink/gptel/issues/440."
(run-with-timer 0.1 nil (lambda ()
(when (derived-mode-p 'org-mode 'markdown-mode)
(gptel-mode 1)))))
(use-package gptel ;https://github.com/karthink/gptel
:ensure t :defer t
:custom
(gptel-default-mode 'org-mode)
(gptel-model 'claude-3-sonnet-20240229) ;See `gptel--anthropic-models'.
:config
(dolist (hook '(org-mode-hook markdown-mode-hook))
(add-hook hook 'gptel-setup-hook:nordlow))
(add-hook 'gptel-post-response-functions
'gptel-post-response-adjust:nordlow)
(require 'gptel-gemini nil t)
(when (require 'gptel-anthropic nil t)
(setq gptel-backend (gptel-make-anthropic "Claude"
:stream nil ;TODO: experiment with true
:key anthropic-api-token)))
(global-set-key [(control c) (return)] 'gptel-send)) |
This shouldn't be an issue. (BTW if you were using |
Ok, thanks. The reason why I chose Are you using something lke (defun gptel-post-response-adjust:nordlow (begin end)
(fill-paragraph nil (cons begin end))
) or do you use |
I don't modify or post-process the response in any way.
No, but you can write one. For example: (defun gptel-post-response-adjust:nordflow (beg end)
(save-excursion
(save-restriction
(narrow-to-region beg end)
(org-element-map (org-element-parse-buffer)
'(paragraph)
(lambda (node)
(goto-char (org-element-begin node))
(org-fill-paragraph)))))) This will only fill paragraphs, leaving all blocks and other Org elements alone. |
Doesn't seem like there's anything that should be causing trouble with gptel. Hmm. |
I tried to reproduce this error (duplicate Could you try to reproduce it in stock Emacs, with |
Did you have a chance to try this with |
Is the original issue -- with |
I want to have
gptel
be activated automatically inorg-mode
andmarkdown-mode
buffers when they are opened. I currently am usinggptel-setup-hook:nordlow
in.
But it slightly misbehaves:
gptel-mode
afterorg-mode
has completed loadingorg-mode
properties such as:GPTEL_SYSTEM:
are either duplicated or replacedIs the problem that the org-mode-hook is run too early?
Thanks in advance.
The text was updated successfully, but these errors were encountered: