dotfiles/emacs-lisp/windows_and_frames.org
MagicRB cb2f0f93a0
Add new xmonad command for opening Emacs vterm
Signed-off-by: MagicRB <richard@brezak.sk>
2023-10-04 18:07:46 +02:00

1.8 KiB

Windows and Frames

  (add-to-list 'default-frame-alist '(alpha-background . 80))

Disable window changing using the mouse, it saves me from accidental switches.

  (defun cv/mouse-set-point (fun event &optional promote)
    (let ((window (car (car (cdr event)))))
      (when (equal window (selected-window))
        (funcall fun event promote))))
  (advice-add 'mouse-set-point :around 'cv/mouse-set-point)

  (defun cv/mouse-drag-region (fun event)
     (let ((window (car (car (cdr event)))))
       (when (equal window (selected-window))
        (funcall fun event))))
  (advice-add 'mouse-drag-region :around 'cv/mouse-drag-region)

  (defun cv/mouse-set-region (fun event)
     (let ((window (car (car (cdr event)))))
       (when (equal window (selected-window))
        (funcall fun event))))
  (advice-add 'mouse-set-region :around 'cv/mouse-set-region)
  (defun maybe-delete-frame-buffer (frame)
    "When a dedicated FRAME is deleted, also kill its buffer.
  A dedicated frame contains a single window whose buffer is not
  displayed anywhere else."
    (let ((windows (window-list frame)))
      (when (eq 1 (length windows))
        (let ((buffer (window-buffer (car windows))))
          (when (eq 1 (length (get-buffer-window-list buffer nil t)))
            (when (frame-parameter frame 'unsplittable)
              (with-current-buffer buffer
                (when (equal major-mode #'vterm-mode) (message "VTERM") (kill-process (get-buffer-process buffer)))
                (kill-buffer buffer))))))))
  (add-to-list 'delete-frame-functions #'maybe-delete-frame-buffer)