No more git fullscreen?
This commit is contained in:
@@ -1087,40 +1087,40 @@ windows. I place windows in the bottom or on the right mostly depending on how w
|
||||
content to be.
|
||||
|
||||
#+BEGIN_SRC elisp
|
||||
(defun jf/window-children (window)
|
||||
(let ((result nil)
|
||||
(child (window-child window)))
|
||||
(while child
|
||||
(push child result)
|
||||
(setq child (window-next-sibling child)))
|
||||
(reverse result)))
|
||||
(defun jf/window-children (window)
|
||||
(let ((result nil)
|
||||
(child (window-child window)))
|
||||
(while child
|
||||
(push child result)
|
||||
(setq child (window-next-sibling child)))
|
||||
(reverse result)))
|
||||
|
||||
(defun jf/window-main-root (&optional frame)
|
||||
"Return FRAME's main (non-side) window or window subtree."
|
||||
(let* ((root (frame-root-window (or frame (selected-frame))))
|
||||
(children (jf/window-children root)))
|
||||
(if (seq-some (lambda (w) (window-parameter w 'window-side)) children)
|
||||
(seq-find (lambda (w) (not (window-parameter w 'window-side))) children)
|
||||
root)))
|
||||
(defun jf/window-main-root (&optional frame)
|
||||
"Return FRAME's main (non-side) window or window subtree."
|
||||
(let* ((root (frame-root-window (or frame (selected-frame))))
|
||||
(children (jf/window-children root)))
|
||||
(if (seq-some (lambda (w) (window-parameter w 'window-side)) children)
|
||||
(seq-find (lambda (w) (not (window-parameter w 'window-side))) children)
|
||||
root)))
|
||||
|
||||
(defun jf/window-leaves (window)
|
||||
"Return the live leaf windows in WINDOW's subtree."
|
||||
(if (window-live-p window)
|
||||
(list window)
|
||||
(mapcan #'jf/window-leaves (jf/window-children window))))
|
||||
(defun jf/window-leaves (window)
|
||||
"Return the live leaf windows in WINDOW's subtree."
|
||||
(if (window-live-p window)
|
||||
(list window)
|
||||
(mapcan #'jf/window-leaves (jf/window-children window))))
|
||||
|
||||
(defun jf/topright-window (windows)
|
||||
"Return whichever of WINDOWS sits furthest up, then furthest right."
|
||||
(car (sort (copy-sequence windows)
|
||||
(lambda (a b)
|
||||
(let ((top-a (nth 1 (window-edges a)))
|
||||
(top-b (nth 1 (window-edges b))))
|
||||
(if (= top-a top-b)
|
||||
(> (nth 0 (window-edges a)) (nth 0 (window-edges b)))
|
||||
(< top-a top-b)))))))
|
||||
(defun jf/topright-window (windows)
|
||||
"Return whichever of WINDOWS sits furthest up, then furthest right."
|
||||
(car (sort (copy-sequence windows)
|
||||
(lambda (a b)
|
||||
(let ((top-a (nth 1 (window-edges a)))
|
||||
(top-b (nth 1 (window-edges b))))
|
||||
(if (= top-a top-b)
|
||||
(> (nth 0 (window-edges a)) (nth 0 (window-edges b)))
|
||||
(< top-a top-b)))))))
|
||||
|
||||
(defun jf/display-buffer-right (buffer alist)
|
||||
"Display BUFFER on the right of the main editing area.
|
||||
(defun jf/display-buffer-right (buffer alist)
|
||||
"Display BUFFER on the right of the main editing area.
|
||||
|
||||
Applies three rules, based on the shape of the frame's non-side windows:
|
||||
1. One window -> split it and show BUFFER in the new right window.
|
||||
@@ -1128,92 +1128,92 @@ content to be.
|
||||
right window is selected, swap the two windows first (keeping
|
||||
focus on the buffer that was active) so BUFFER doesn't evict it.
|
||||
3. Any other layout -> show BUFFER in the upper-rightmost window."
|
||||
(let ((main (jf/window-main-root)))
|
||||
(cond
|
||||
((window-live-p main)
|
||||
(let* ((new (split-window main nil 'right))
|
||||
(width (max 1 (- (frame-width) 120)))
|
||||
(delta (window-resizable new (- width (window-width new)) t)))
|
||||
(window-resize new delta t)
|
||||
(window--display-buffer buffer new 'window alist)))
|
||||
((and (window-left-child main)
|
||||
(= (length (jf/window-children main)) 2)
|
||||
(seq-every-p #'window-live-p (jf/window-children main)))
|
||||
(let* ((left (window-left-child main))
|
||||
(right (window-next-sibling left)))
|
||||
(when (eq (selected-window) right)
|
||||
(window-swap-states left right)
|
||||
(select-window left))
|
||||
(window--display-buffer buffer right 'reuse alist)))
|
||||
(t
|
||||
(window--display-buffer buffer (jf/topright-window (jf/window-leaves main)) 'reuse alist)))))
|
||||
(let ((main (jf/window-main-root)))
|
||||
(cond
|
||||
((window-live-p main)
|
||||
(let* ((new (split-window main nil 'right))
|
||||
(width (max 1 (- (frame-width) 120)))
|
||||
(delta (window-resizable new (- width (window-width new)) t)))
|
||||
(window-resize new delta t)
|
||||
(window--display-buffer buffer new 'window alist)))
|
||||
((and (window-left-child main)
|
||||
(= (length (jf/window-children main)) 2)
|
||||
(seq-every-p #'window-live-p (jf/window-children main)))
|
||||
(let* ((left (window-left-child main))
|
||||
(right (window-next-sibling left)))
|
||||
(when (eq (selected-window) right)
|
||||
(window-swap-states left right)
|
||||
(select-window left))
|
||||
(window--display-buffer buffer right 'reuse alist)))
|
||||
(t
|
||||
(window--display-buffer buffer (jf/topright-window (jf/window-leaves main)) 'reuse alist)))))
|
||||
|
||||
|
||||
(setopt popper-reference-buffers
|
||||
'("\\*Flymake diagnostics .*"
|
||||
"\\*Embark Export: .*"
|
||||
"\\*Embark Collect .*"
|
||||
"\\*xref\\*"
|
||||
"\\*compilation\\*"
|
||||
"\\*pnpm:.*"
|
||||
"\\*sly-mrepl *"
|
||||
"\\*lispy-message\\*"
|
||||
"\\*occur\\*"
|
||||
".*eshell\\*"
|
||||
"\\*SQL: .*"
|
||||
"magit-revision: .*"
|
||||
"\\*Help\\*"
|
||||
"\\*rustfmt\\*"
|
||||
"\\*slack: .*"
|
||||
"\\*forge: .*"
|
||||
"new-pullreq"
|
||||
"\\*claude:.*"
|
||||
"\\*Man .*"
|
||||
"\\*List .*"
|
||||
"\\*eldoc\\*"))
|
||||
(setopt popper-display-control nil)
|
||||
(setopt popper-reference-buffers
|
||||
'("\\*Flymake diagnostics .*"
|
||||
"\\*Embark Export: .*"
|
||||
"\\*Embark Collect .*"
|
||||
"\\*xref\\*"
|
||||
"\\*compilation\\*"
|
||||
"\\*pnpm:.*"
|
||||
"\\*sly-mrepl *"
|
||||
"\\*lispy-message\\*"
|
||||
"\\*occur\\*"
|
||||
".*eshell\\*"
|
||||
"\\*SQL: .*"
|
||||
"magit-revision: .*"
|
||||
"\\*Help\\*"
|
||||
"\\*rustfmt\\*"
|
||||
"\\*slack: .*"
|
||||
"\\*forge: .*"
|
||||
"new-pullreq"
|
||||
"\\*claude:.*"
|
||||
"\\*Man .*"
|
||||
"\\*List .*"
|
||||
"\\*eldoc\\*"))
|
||||
(setopt popper-display-control nil)
|
||||
|
||||
(popper-mode)
|
||||
(popper-echo-mode)
|
||||
(popper-mode)
|
||||
(popper-echo-mode)
|
||||
|
||||
(bind-keys ("C-q" . popper-toggle)
|
||||
("C-;" . popper-cycle))
|
||||
(bind-keys ("C-q" . popper-toggle)
|
||||
("C-;" . popper-cycle))
|
||||
|
||||
(defvar jf/fullscreen-popup--param 'jf/fullscreen-saved-configuration
|
||||
"Key used to stash the window configuration a fullscreen popup replaced.
|
||||
(defvar jf/fullscreen-popup--param 'jf/fullscreen-saved-configuration
|
||||
"Key used to stash the window configuration a fullscreen popup replaced.
|
||||
Stored per-tab when `tab-bar-mode' is active, otherwise as a plain frame
|
||||
parameter; see `jf/tab-or-frame-parameter'.")
|
||||
|
||||
(defvar-local jf/fullscreen-popup-p nil
|
||||
"Non-nil in a buffer currently being displayed as a fullscreen popup.")
|
||||
(defvar-local jf/fullscreen-popup-p nil
|
||||
"Non-nil in a buffer currently being displayed as a fullscreen popup.")
|
||||
|
||||
(defun jf/current-tab-cell (&optional frame)
|
||||
"Return FRAME's current tab's raw data cell, or nil without `tab-bar-mode'."
|
||||
(and (bound-and-true-p tab-bar-mode)
|
||||
(assq 'current-tab (tab-bar-tabs frame))))
|
||||
(defun jf/current-tab-cell (&optional frame)
|
||||
"Return FRAME's current tab's raw data cell, or nil without `tab-bar-mode'."
|
||||
(and (bound-and-true-p tab-bar-mode)
|
||||
(assq 'current-tab (tab-bar-tabs frame))))
|
||||
|
||||
(defun jf/tab-or-frame-parameter (parameter &optional frame)
|
||||
"Like `frame-parameter', but scoped to FRAME's selected tab when tabs are in use.
|
||||
(defun jf/tab-or-frame-parameter (parameter &optional frame)
|
||||
"Like `frame-parameter', but scoped to FRAME's selected tab when tabs are in use.
|
||||
|
||||
A plain frame parameter is shared by every tab on that frame, which is wrong
|
||||
for state like `jf/fullscreen-popup--param': switching tabs swaps in an
|
||||
entirely different window layout, so \"the layout to restore\" has to travel
|
||||
with the tab, not the frame."
|
||||
(if-let ((tab (jf/current-tab-cell frame)))
|
||||
(alist-get parameter tab)
|
||||
(frame-parameter frame parameter)))
|
||||
(if-let ((tab (jf/current-tab-cell frame)))
|
||||
(alist-get parameter tab)
|
||||
(frame-parameter frame parameter)))
|
||||
|
||||
(defun jf/set-tab-or-frame-parameter (parameter value &optional frame)
|
||||
"Set PARAMETER to VALUE, scoped like `jf/tab-or-frame-parameter'."
|
||||
(if-let ((tab (jf/current-tab-cell frame)))
|
||||
(let ((cell (assq parameter tab)))
|
||||
(if cell
|
||||
(setcdr cell value)
|
||||
(setcdr tab (cons (cons parameter value) (cdr tab)))))
|
||||
(set-frame-parameter frame parameter value)))
|
||||
(defun jf/set-tab-or-frame-parameter (parameter value &optional frame)
|
||||
"Set PARAMETER to VALUE, scoped like `jf/tab-or-frame-parameter'."
|
||||
(if-let ((tab (jf/current-tab-cell frame)))
|
||||
(let ((cell (assq parameter tab)))
|
||||
(if cell
|
||||
(setcdr cell value)
|
||||
(setcdr tab (cons (cons parameter value) (cdr tab)))))
|
||||
(set-frame-parameter frame parameter value)))
|
||||
|
||||
(defun jf/display-buffer-fullscreen (buffer alist)
|
||||
"Display BUFFER, deleting other windows, saving the prior layout.
|
||||
(defun jf/display-buffer-fullscreen (buffer alist)
|
||||
"Display BUFFER, deleting other windows, saving the prior layout.
|
||||
|
||||
Intended for use in `display-buffer-alist' for popups (e.g. Magit
|
||||
status/log) that should take over the frame while displayed, but
|
||||
@@ -1221,21 +1221,21 @@ content to be.
|
||||
`q' or `popper-toggle' -- both end up calling `quit-window', which
|
||||
is where the restore actually happens; see
|
||||
`jf/quit-window-restore-fullscreen'."
|
||||
(unless (jf/tab-or-frame-parameter jf/fullscreen-popup--param)
|
||||
(jf/set-tab-or-frame-parameter jf/fullscreen-popup--param
|
||||
(current-window-configuration)))
|
||||
(when-let ((window (or (display-buffer-reuse-window buffer alist)
|
||||
(display-buffer-same-window buffer alist)
|
||||
(display-buffer-pop-up-window buffer alist)
|
||||
(display-buffer-use-some-window buffer alist))))
|
||||
(let ((ignore-window-parameters t))
|
||||
(delete-other-windows window))
|
||||
(with-current-buffer buffer
|
||||
(setq jf/fullscreen-popup-p t))
|
||||
window))
|
||||
(unless (jf/tab-or-frame-parameter jf/fullscreen-popup--param)
|
||||
(jf/set-tab-or-frame-parameter jf/fullscreen-popup--param
|
||||
(current-window-configuration)))
|
||||
(when-let ((window (or (display-buffer-reuse-window buffer alist)
|
||||
(display-buffer-same-window buffer alist)
|
||||
(display-buffer-pop-up-window buffer alist)
|
||||
(display-buffer-use-some-window buffer alist))))
|
||||
(let ((ignore-window-parameters t))
|
||||
(delete-other-windows window))
|
||||
(with-current-buffer buffer
|
||||
(setq jf/fullscreen-popup-p t))
|
||||
window))
|
||||
|
||||
(defun jf/quit-window-restore-fullscreen (orig-fn &optional kill window)
|
||||
"Restore the saved window configuration after quitting a fullscreen popup.
|
||||
(defun jf/quit-window-restore-fullscreen (orig-fn &optional kill window)
|
||||
"Restore the saved window configuration after quitting a fullscreen popup.
|
||||
|
||||
Advice around `quit-window' so both `q' (which Magit and other
|
||||
special-mode buffers bind to buffer-quitting commands that call
|
||||
@@ -1244,70 +1244,69 @@ content to be.
|
||||
last fullscreen popup on the tab (or frame, without `tab-bar-mode')
|
||||
has closed, so opening one fullscreen popup from within another
|
||||
falls back to the outer one first."
|
||||
(let* ((window (or window (selected-window)))
|
||||
(was-fullscreen (buffer-local-value 'jf/fullscreen-popup-p
|
||||
(window-buffer window)))
|
||||
(frame (window-frame window)))
|
||||
(funcall orig-fn kill window)
|
||||
(when (and was-fullscreen
|
||||
(not (and (window-live-p window)
|
||||
(buffer-local-value 'jf/fullscreen-popup-p
|
||||
(window-buffer window))))
|
||||
(jf/tab-or-frame-parameter jf/fullscreen-popup--param frame))
|
||||
(let ((conf (jf/tab-or-frame-parameter jf/fullscreen-popup--param frame)))
|
||||
(jf/set-tab-or-frame-parameter jf/fullscreen-popup--param nil frame)
|
||||
(set-window-configuration conf)))))
|
||||
(let* ((window (or window (selected-window)))
|
||||
(was-fullscreen (buffer-local-value 'jf/fullscreen-popup-p
|
||||
(window-buffer window)))
|
||||
(frame (window-frame window)))
|
||||
(funcall orig-fn kill window)
|
||||
(when (and was-fullscreen
|
||||
(not (and (window-live-p window)
|
||||
(buffer-local-value 'jf/fullscreen-popup-p
|
||||
(window-buffer window))))
|
||||
(jf/tab-or-frame-parameter jf/fullscreen-popup--param frame))
|
||||
(let ((conf (jf/tab-or-frame-parameter jf/fullscreen-popup--param frame)))
|
||||
(jf/set-tab-or-frame-parameter jf/fullscreen-popup--param nil frame)
|
||||
(set-window-configuration conf)))))
|
||||
|
||||
(advice-add 'quit-window :around #'jf/quit-window-restore-fullscreen)
|
||||
(advice-add 'quit-window :around #'jf/quit-window-restore-fullscreen)
|
||||
|
||||
(setopt split-width-threshold 200)
|
||||
(setopt split-height-threshold nil)
|
||||
(setopt display-buffer-base-action
|
||||
'((display-buffer-reuse-window display-buffer-same-window
|
||||
display-buffer-in-previous-window
|
||||
display-buffer-use-some-window)))
|
||||
'((display-buffer-reuse-window
|
||||
display-buffer-reuse-mode-window
|
||||
display-buffer-use-some-window)))
|
||||
|
||||
(setq display-buffer-alist
|
||||
'(((or "magit: *"
|
||||
"magit-log*"
|
||||
"\\*Messages\\*"
|
||||
"\\*trace-output\\*"
|
||||
"\\*EGLOT connections\\*")
|
||||
(jf/display-buffer-fullscreen))
|
||||
((or "\\*Flymake diagnostics .*"
|
||||
"\\*Embark Export: .*"
|
||||
"\\*Embark Collect .*"
|
||||
"\\*xref\\*"
|
||||
"\\*compilation\\*"
|
||||
"\\*pnpm:.*"
|
||||
"\\*sly-mrepl *"
|
||||
"\\*lispy-message\\*"
|
||||
"\\*occur\\*"
|
||||
".*eshell\\*"
|
||||
"\\*SQL: .*")
|
||||
(display-buffer-in-side-window)
|
||||
(side . bottom)
|
||||
(slot . 0)
|
||||
(window-height . 0.33)
|
||||
(window-parameters (no-delete-other-windows . t)
|
||||
(no-other-window . t)))
|
||||
((or "magit-revision: .*"
|
||||
"\\*Help\\*"
|
||||
"\\*rustfmt\\*"
|
||||
"\\*slack: .*"
|
||||
"\\*forge: .*"
|
||||
"new-pullreq"
|
||||
"\\*claude:.*"
|
||||
"\\*Man .*"
|
||||
"\\*List .*"
|
||||
"\\*Embark Actions\\*"
|
||||
"\\*eldoc\\*")
|
||||
(jf/display-buffer-right))))
|
||||
(setq display-buffer-alist
|
||||
'(((or "\\*Flymake diagnostics .*"
|
||||
"\\*Embark Export: .*"
|
||||
"\\*Embark Collect .*"
|
||||
"\\*xref\\*"
|
||||
"\\*compilation\\*"
|
||||
"\\*pnpm:.*"
|
||||
"\\*sly-mrepl *"
|
||||
"\\*lispy-message\\*"
|
||||
"\\*occur\\*"
|
||||
".*eshell\\*"
|
||||
"\\*SQL: .*")
|
||||
(display-buffer-in-side-window)
|
||||
(side . bottom)
|
||||
(slot . 0)
|
||||
(window-height . 0.33))
|
||||
((or "magit: *"
|
||||
"magit-log*"
|
||||
"\\*Messages\\*"
|
||||
"\\*trace-output\\*"
|
||||
"\\*EGLOT connections\\*"
|
||||
"magit-revision: .*"
|
||||
"\\*Help\\*"
|
||||
"\\*rustfmt\\*"
|
||||
"\\*slack: .*"
|
||||
"\\*forge: .*"
|
||||
"new-pullreq"
|
||||
"\\*claude:.*"
|
||||
"\\*Man .*"
|
||||
"\\*List .*"
|
||||
"\\*Embark Actions\\*"
|
||||
"\\*eldoc\\*")
|
||||
(display-buffer-reuse-window
|
||||
display-buffer-reuse-mode-window
|
||||
jf/display-buffer-right))))
|
||||
|
||||
(setopt window-persistent-parameters
|
||||
(cl-list* '(no-delete-other-windows . writable)
|
||||
'(no-other-window . writable)
|
||||
window-persistent-parameters))
|
||||
(setopt window-persistent-parameters
|
||||
(cl-list* '(no-delete-other-windows . writable)
|
||||
'(no-other-window . writable)
|
||||
window-persistent-parameters))
|
||||
#+END_SRC
|
||||
|
||||
|
||||
@@ -1323,10 +1322,10 @@ This configuration affects general text editing, across all modes. First, some p
|
||||
programs.emacs = {
|
||||
enable = true;
|
||||
extraPackages = epkgs: with epkgs; [
|
||||
apheleia
|
||||
avy
|
||||
edit-indirect
|
||||
embark
|
||||
format-all
|
||||
god-mode
|
||||
# evil
|
||||
# evil-collection
|
||||
@@ -1440,6 +1439,12 @@ Just "silently" wrap when searching at the bottom of a document.
|
||||
(bind-keys ("C-x 4 n" . edit-indirect-region))
|
||||
#+END_SRC
|
||||
|
||||
Some auto-formatting stuff
|
||||
|
||||
#+begin_src elisp
|
||||
(push '(prisma-format "prisma" "format" "--schema" filepath) apheleia-formatters)
|
||||
#+end_src
|
||||
|
||||
** Workflow
|
||||
:PROPERTIES:
|
||||
:header-args:elisp: :tangle target/desktop/emacs-workflow.el
|
||||
|
||||
Reference in New Issue
Block a user