aboutsummaryrefslogtreecommitdiff
path: root/pearl.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-27 18:26:58 -0500
committerCraig Jennings <c@cjennings.net>2026-05-27 18:26:58 -0500
commit73f7656d02f916c361fc0da06d97d9bdaf9062a0 (patch)
tree5b3f3e4a1412462ce888b65829e4312f3dfc670f /pearl.el
parent34b4e5ecd8468129cb97e870987fc8bb8d27d6e2 (diff)
downloadpearl-73f7656d02f916c361fc0da06d97d9bdaf9062a0.tar.gz
pearl-73f7656d02f916c361fc0da06d97d9bdaf9062a0.zip
feat(compose): open compose and conflict buffers in a configurable side window
The compose buffers (edit-description, add-comment) and the smerge conflict buffer popped wherever display-buffer happened to put them. Now they open in a side window, defaulting to the bottom at 30% of the frame, with two defcustoms to control it: pearl-compose-window-side (bottom / top / left / right) and pearl-compose-window-size (a fraction of the frame, or an absolute line/column count). pearl--compose-display-action builds the display-buffer-in-side-window action and both pop sites pass it through pop-to-buffer, so Pearl always applies the side window over any display-buffer-alist entry for these buffers.
Diffstat (limited to 'pearl.el')
-rw-r--r--pearl.el32
1 files changed, 30 insertions, 2 deletions
diff --git a/pearl.el b/pearl.el
index 3ade6dc..f08f636 100644
--- a/pearl.el
+++ b/pearl.el
@@ -146,6 +146,34 @@ With the default nil, `pearl-surface-buffer' shows the buffer via
:type 'boolean
:group 'pearl)
+(defcustom pearl-compose-window-side 'bottom
+ "Side of the frame Pearl's compose and conflict buffers open from.
+One of `bottom', `top', `left', or `right'. Pearl always applies this side
+window when popping a compose buffer, overriding any `display-buffer-alist'
+entry for those buffers."
+ :type '(choice (const bottom) (const top) (const left) (const right))
+ :group 'pearl)
+
+(defcustom pearl-compose-window-size 0.3
+ "Size of Pearl's compose and conflict side window.
+A float below 1 is a fraction of the frame (0.3 = 30%); an integer is an
+absolute size in lines (for `bottom'/`top') or columns (for `left'/`right').
+Paired with `pearl-compose-window-side'."
+ :type 'number
+ :group 'pearl)
+
+(defun pearl--compose-display-action ()
+ "Return the `display-buffer' action for a compose or conflict buffer.
+A side window on `pearl-compose-window-side', sized by
+`pearl-compose-window-size' -- `window-width' for the left/right sides,
+`window-height' for top/bottom."
+ (cons '(display-buffer-in-side-window)
+ (list (cons 'side pearl-compose-window-side)
+ (cons (if (memq pearl-compose-window-side '(left right))
+ 'window-width
+ 'window-height)
+ pearl-compose-window-size))))
+
(defun pearl--surface-buffer (buffer)
"Bring BUFFER to a window after a command updated it, unless already shown.
No-op when `pearl-surface-buffer' is nil, BUFFER is dead, or BUFFER is already
@@ -2136,7 +2164,7 @@ sibling of `pearl--resolve-conflict-in-smerge'."
(local-set-key (kbd "C-c C-c") #'pearl--compose-submit)
(local-set-key (kbd "C-c C-k") #'pearl--compose-abort)
(goto-char (point-max)))
- (pop-to-buffer buf)
+ (pop-to-buffer buf (pearl--compose-display-action))
buf))
(defvar-local pearl--conflict-on-finish nil
@@ -2171,7 +2199,7 @@ given, is a thunk run on abort so the save engine can report the outcome."
(setq-local header-line-format
(substitute-command-keys
"Resolve the conflict, then \\[pearl--conflict-commit] to push, \\[pearl--conflict-abort] to abort")))
- (pop-to-buffer buf)))
+ (pop-to-buffer buf (pearl--compose-display-action))))
(defun pearl--conflict-commit ()
"Finish the current pearl conflict buffer, pushing the reconciled text.