Emacs: Killing either vterm-scratch or the frame kills the other

This commit is contained in:
Joseph Ferano 2023-08-23 18:20:18 +07:00
parent e55f157b1e
commit c60c7ed631
2 changed files with 12 additions and 12 deletions

View File

@ -1813,28 +1813,28 @@ the right frame, I'm going to use the frame's name to close and remove the hook
(defun joe/kill-frame () (defun joe/kill-frame ()
(when (equal (buffer-name) "Scratch VTerm") (when (equal (buffer-name) "Scratch VTerm")
(remove-hook 'delete-frame-functions #'joe/kill-vterm-scratch)
(remove-hook 'kill-buffer-hook #'joe/kill-frame) (remove-hook 'kill-buffer-hook #'joe/kill-frame)
(remove-function delete-frame-functions #'joe/kill-vterm-scratch)
(delete-frame))) (delete-frame)))
(defun joe/kill-vterm-scratch () (defun joe/kill-vterm-scratch (FRAME)
(let ((kill-buffer-query-functions nil) (let* ((kill-buffer-query-functions nil)
(frame-name (substring-no-properties (cdr (assoc 'name (frame-parameters)))))) (scratch-framep (cdr (assoc 'scratch-frame (frame-parameters))))
(message "Frame Name: %s" frame-name) (vterm-buf (get-buffer "Scratch VTerm")))
(when (equal frame-name "emacs-vterm-scratch") (when (and scratch-framep
(message "VTerm Scratch Buffer? %s" (get-buffer "Scratch VTerm")) vterm-buf)
(kill-buffer (get-buffer "Scratch VTerm")) (kill-buffer vterm-buf)
(message "Did we kill it? %s" (get-buffer "Scratch VTerm")) (remove-hook 'delete-frame-functions #'joe/kill-vterm-scratch)
(remove-function delete-frame-functions #'joe/kill-vterm-scratch)
(remove-hook 'kill-buffer-hook #'joe/kill-frame)))) (remove-hook 'kill-buffer-hook #'joe/kill-frame))))
(defun joe/vterm-scratch () (defun joe/vterm-scratch ()
(interactive) (interactive)
(let* ((vterm-buf (vterm--internal #'switch-to-buffer "Scratch VTerm"))) (let* ((vterm-buf (vterm--internal #'switch-to-buffer "Scratch VTerm")))
(set-frame-parameter nil 'scratch-frame t)
(with-current-buffer vterm-buf (with-current-buffer vterm-buf
(setq popper-popup-status 'raised) (setq popper-popup-status 'raised)
(olivetti-mode) (olivetti-mode)
(add-function :before delete-frame-functions #'joe/kill-vterm-scratch) (add-hook 'delete-frame-functions #'joe/kill-vterm-scratch)
(add-hook 'kill-buffer-hook #'joe/kill-frame)))) (add-hook 'kill-buffer-hook #'joe/kill-frame))))
#+end_src #+end_src

View File

@ -208,7 +208,7 @@ hc rule floatplacement=center
#hc rule class~'(.*[Rr]xvt.*|.*[Tt]erm|Konsole)' focus=on #hc rule class~'(.*[Rr]xvt.*|.*[Tt]erm|Konsole)' focus=on
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' floating=on hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' floating=on
hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on
hc rule title='emacs-run-launcher' floating=on floatplacement=center hc rule title~'emacs-run-.*' floating=on floatplacement=center
hc rule title~'^Glut.*' floating=on floatplacement=center hc rule title~'^Glut.*' floating=on floatplacement=center
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off
hc rule fixedsize floating=on hc rule fixedsize floating=on