summaryrefslogtreecommitdiff
path: root/emacs/libs/center-helm-buffer.el
diff options
context:
space:
mode:
authorMatias Linares <matias.linares@comprandoengrupo.net>2023-09-25 09:33:17 -0300
committerMatias Linares <matias.linares@comprandoengrupo.net>2023-09-25 09:33:17 -0300
commit0f873d646031971dd37824181b65ce457576749e (patch)
tree4c897c8af19d50aa6746ec0c08b90b7b57046c4d /emacs/libs/center-helm-buffer.el
parent6c4c5513618105ea4ce081b04e0545c7c05431d8 (diff)
downloaddotfiles-0f873d646031971dd37824181b65ce457576749e.tar.gz
Add emacs configuration
Diffstat (limited to 'emacs/libs/center-helm-buffer.el')
-rw-r--r--emacs/libs/center-helm-buffer.el55
1 files changed, 55 insertions, 0 deletions
diff --git a/emacs/libs/center-helm-buffer.el b/emacs/libs/center-helm-buffer.el
new file mode 100644
index 0000000..85f8438
--- /dev/null
+++ b/emacs/libs/center-helm-buffer.el
@@ -0,0 +1,55 @@
+;;; package --- Center the helm buffer to the emacs window
+;;; Commentary:
+
+;;; Code:
+
+(defun my-helm-display-frame-center (buffer &optional resume)
+ "Display `BUFFER' in a separate frame which centered in parent frame.
+
+I don't know what's RESUME."
+ (if (not (display-graphic-p))
+ ;; Fallback to default when frames are not usable.
+ (helm-default-display-buffer buffer)
+ (setq helm--buffer-in-new-frame-p t)
+ (let* ((parent (selected-frame))
+ (frame-pos (frame-position parent))
+ (parent-left (car frame-pos))
+ (parent-top (cdr frame-pos))
+ (width (/ (frame-width parent) 2))
+ (height (/ (frame-height parent) 3))
+ tab-bar-mode
+ (default-frame-alist
+ (if resume
+ (buffer-local-value 'helm--last-frame-parameters
+ (get-buffer buffer))
+ `((parent . ,parent)
+ (width . ,width)
+ (height . ,height)
+ (undecorated . ,helm-use-undecorated-frame-option)
+ (left-fringe . 0)
+ (right-fringe . 0)
+ (tool-bar-lines . 0)
+ (line-spacing . 0)
+ (desktop-dont-save . t)
+ (no-special-glyphs . t)
+ (inhibit-double-buffering . t)
+ (tool-bar-lines . 0)
+ (left . ,(+ parent-left (/ (* (frame-char-width parent) (frame-width parent)) 4)))
+ (top . ,(+ parent-top (/ (* (frame-char-width parent) (frame-height parent)) 2)))
+ (title . "Helm")
+ (vertical-scroll-bars . nil)
+ (menu-bar-lines . 0)
+ (fullscreen . nil)
+ (visible . ,(null helm-display-buffer-reuse-frame))
+ ;; (internal-border-width . ,(if IS-MAC 1 0))
+ )))
+ display-buffer-alist)
+ (set-face-background 'internal-border (face-foreground 'default))
+ (helm-display-buffer-popup-frame buffer default-frame-alist))
+ (helm-log-run-hook 'helm-window-configuration-hook)))
+
+(setq helm-display-function 'my-helm-display-frame-center)
+
+
+(provide 'center-helm-buffer)
+;;; center-helm-buffer.el ends here