summary refs log tree commit diff
path: root/modules/term/eat/autoload.el
blob: 1c078b30a196ed22d5d9aa6285905b11da01a0d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
;;; term/eat/autoload.el -*- lexical-binding: t; -*-

;;;###autoload
(defun +eat/toggle (arg &optional)
  (interactive "P")
  (let* ((default-directory (project-root (project-current t)))
         (eat-kill-buffer-on-exit 't)
         (eat-buffer-name (format "*doom:eat-popup:%s*"
                                  (if (bound-and-true-p persp-mode)
                                      (safe-persp-name (get-current-persp))
                                    "main"))))
    (eat-other-window nil arg)))

;;;###autoload
(defvar +eat-frame-parameters
  `((width . 110)
    (height . 35)
    (minibuffer . nil)
    (transient . t)
    ,@(when IS-LINUX
        `((window-system . ,(if (boundp 'pgtk-initialized) 'pgtk 'x))
          (display . ,(or (getenv "WAYLAND_DISPLAY")
                          (getenv "DISPLAY")
                          ":0"))))
    ,(if IS-MAC '(menu-bar-lines . 1)))
  "TODO")

;;;###autoload
(defun +eat/open-frame ()
  (interactive)
  (let* ((frame-title-format "")
         (frame (make-frame +eat-frame-parameters)))
    (select-frame-set-input-focus frame)
    (with-selected-frame frame
      (switch-to-buffer (doom-fallback-buffer))
      (let* ((eat-kill-buffer-on-exit 't)
             (default-directory "~")
             (eat-mode-hook (cons (lambda ()
                                    (add-hook 'eat-exit-hook (lambda (_process) (delete-frame)) 91 t)
                                    ;; Disabling the modeline causes emacs to stop calling this function.
                                    ;; Replace with advising eat--t-set-title instead.
                                    (add-to-list 'mode-line-process '(:eval (when-let* ((eat-terminal)
                                                                                        (title (eat-term-title eat-terminal)))
                                                                              (modify-frame-parameters nil `((name . ,title)))
                                                                              "")))) eat-mode-hook)))
        (eat nil t)))))

;; These clobber vterm bindings, so will need to pick alternatives.
(map! :leader
      (:prefix-map ("o" . "open")
       :desc "Toggle Eat popup" "t" #'+eat/toggle
       :desc "Open Eat here" "T" #'eat-project))