aboutsummaryrefslogtreecommitdiff
path: root/gui/conf
diff options
context:
space:
mode:
Diffstat (limited to 'gui/conf')
-rw-r--r--gui/conf/init.el30
1 files changed, 26 insertions, 4 deletions
diff --git a/gui/conf/init.el b/gui/conf/init.el
index 567b1cf..d69e77b 100644
--- a/gui/conf/init.el
+++ b/gui/conf/init.el
@@ -323,6 +323,25 @@
(use-package ob-async
:ensure t)
+(defun custom/gptel-menu-org-fix (orig-fun &rest args)
+ "Temporarily unbind <return> in Evil-Org normal state so Transient can catch it."
+ (if (not (eq major-mode 'org-mode))
+ (apply orig-fun args)
+ ;; 1. Get the specific Evil keymap for Org Normal state
+ (let* ((aux-map (evil-get-auxiliary-keymap org-mode-map 'normal))
+ (old-binding (lookup-key aux-map (kbd "<return>"))))
+ ;; 2. Unbind <return> immediately
+ (define-key aux-map (kbd "<return>") nil)
+ ;; 3. Define restoration logic
+ (defun custom/gptel-restore-binding ()
+ "Restore the original binding and remove hook."
+ (when (bound-and-true-p aux-map)
+ (define-key aux-map (kbd "<return>") old-binding))
+ (remove-hook 'transient-exit-hook #'custom/gptel-restore-binding))
+ ;; 4. Add hook and run the menu
+ (add-hook 'transient-exit-hook #'custom/gptel-restore-binding)
+ (apply orig-fun args))))
+
(use-package gptel
:ensure t
:config
@@ -352,6 +371,7 @@
:key (lambda () (gptel--read-key-file "~/.kit-ai-key"))
:models '("azure.gpt-5")))
(setq gptel-default-model "Google:gemini-flash-latest"))
+ (advice-add 'gptel-menu :around #'custom/gptel-menu-org-fix))
(use-package ob-gptel
:ensure t
@@ -429,10 +449,12 @@
"m" 'hydra-org-mode-local/body
(kbd "<return>") (lambda ()
(interactive)
- (if current-prefix-arg
- (let ((browse-url-browser-function browse-url-secondary-browser-function))
- (call-interactively 'org-open-at-point))
- (call-interactively 'org-open-at-point))))
+ (if (eq transient-current-command 'gptel-menu)
+ (gptel-send)
+ (if current-prefix-arg
+ (let ((browse-url-browser-function browse-url-secondary-browser-function))
+ (call-interactively 'org-open-at-point))
+ (call-interactively 'org-open-at-point)))))
(use-package helm
:ensure t