mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-29 11:36:16 +01:00
97941f8724
Signed-off-by: magic_rb <magic_rb@redalder.org>
91 lines
2.8 KiB
Org Mode
91 lines
2.8 KiB
Org Mode
:PROPERTIES:
|
|
:header-args:emacs-lisp: :comments link :results none
|
|
:ID: 940c2ee1-96ef-4c91-abef-c53787ea1c05
|
|
:END:
|
|
#+title: Windows and Frames
|
|
#+filetags: emacs-load
|
|
|
|
#+begin_src emacs-lisp
|
|
(add-to-list 'default-frame-alist '(alpha-background . 80))
|
|
#+end_src
|
|
|
|
Disable changing windows by mouse clicks. Advise ~mouse-set-point~, ~mouse-drag-region~, and ~mouse-set-region~ and prevent them from executing if the current window and target window are different.
|
|
|
|
#+begin_src emacs-lisp
|
|
(defun cv/mouse-set-point (fun event &optional promote)
|
|
(let ((window (posn-window (event-start 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-end (posn-window (event-end event))))
|
|
(when (equal window-end (selected-window))
|
|
(funcall fun event))))
|
|
(advice-add 'mouse-drag-region :around 'cv/mouse-drag-region)
|
|
|
|
(defun cv/mouse-set-region (fun event)
|
|
(let ((window (posn-window (event-start event))))
|
|
(when (equal window (selected-window))
|
|
(funcall fun event))))
|
|
(advice-add 'mouse-set-region :around 'cv/mouse-set-region)
|
|
#+end_src
|
|
|
|
When a frame is deleted, check whether it is dedicated and if it is, delete its buffer too.
|
|
|
|
#+begin_src emacs-lisp
|
|
(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) (kill-process (get-buffer-process buffer)))
|
|
(kill-buffer buffer))))))))
|
|
(add-to-list 'delete-frame-functions #'maybe-delete-frame-buffer)
|
|
#+end_src
|
|
|
|
* Mouse Interaction
|
|
|
|
Don't use the dialog box for asking questions when triggered by the mouse.
|
|
|
|
#+begin_src emacs-lisp
|
|
(setq use-dialog-box nil)
|
|
#+end_src
|
|
|
|
|
|
Don't ask for files using the file dialog.
|
|
|
|
#+begin_src emacs-lisp
|
|
(setq use-file-dialog nil)
|
|
#+end_src
|
|
|
|
* Buffers
|
|
|
|
Don't allow the deletion of the ~*scratch*~ and ~*Messages*~ buffers.
|
|
|
|
#+begin_src emacs-lisp
|
|
(with-current-buffer "*scratch*" (emacs-lock-mode 'kill))
|
|
(with-current-buffer "*Messages*" (emacs-lock-mode 'kill))
|
|
#+end_src
|
|
|
|
* Scrolling
|
|
|
|
#+begin_src emacs-lisp
|
|
(use-package scrolling
|
|
:no-require t
|
|
:ensure nil
|
|
:custom
|
|
(auto-window-vscroll nil)
|
|
(hscroll-margin 5)
|
|
(hscroll-step 0)
|
|
(scroll-margin 5)
|
|
(scroll-step 0)
|
|
(scroll-preserve-screen-position t))
|
|
#+end_src
|
|
|