Function: posframe--create-posframe
posframe--create-posframe is a byte-compiled function defined in
posframe.el.
Signature
(posframe--create-posframe BUFFER-OR-NAME &key POSITION PARENT-FRAME FOREGROUND-COLOR BACKGROUND-COLOR LEFT-FRINGE RIGHT-FRINGE BORDER-WIDTH BORDER-COLOR INTERNAL-BORDER-WIDTH INTERNAL-BORDER-COLOR FONT CURSOR TTY-NON-SELECTED-CURSOR KEEP-RATIO LINES-TRUNCATE OVERRIDE-PARAMETERS RESPECT-HEADER-LINE RESPECT-MODE-LINE ACCEPT-FOCUS PARENT-TEXT-SCALE-MODE-AMOUNT)
Documentation
Create and return a posframe child frame.
This posframe's buffer is BUFFER-OR-NAME.
The below optional arguments are similar to posframe-show's:
PARENT-FRAME, FOREGROUND-COLOR, BACKGROUND-COLOR, LEFT-FRINGE,
RIGHT-FRINGE, BORDER-WIDTH, BORDER-COLOR, INTERNAL-BORDER-WIDTH,
INTERNAL-BORDER-COLOR, FONT, KEEP-RATIO, LINES-TRUNCATE,
OVERRIDE-PARAMETERS, RESPECT-HEADER-LINE, RESPECT-MODE-LINE,
ACCEPT-FOCUS.
Source Code
;; Defined in ~/.emacs.d/elpa/posframe-20260415.14/posframe.el
(cl-defun posframe--create-posframe (buffer-or-name
&key
position
parent-frame
foreground-color
background-color
left-fringe
right-fringe
border-width
border-color
internal-border-width
internal-border-color
font
cursor
tty-non-selected-cursor
keep-ratio
lines-truncate
override-parameters
respect-header-line
respect-mode-line
accept-focus
parent-text-scale-mode-amount)
"Create and return a posframe child frame.
This posframe's buffer is BUFFER-OR-NAME.
The below optional arguments are similar to `posframe-show''s:
PARENT-FRAME, FOREGROUND-COLOR, BACKGROUND-COLOR, LEFT-FRINGE,
RIGHT-FRINGE, BORDER-WIDTH, BORDER-COLOR, INTERNAL-BORDER-WIDTH,
INTERNAL-BORDER-COLOR, FONT, KEEP-RATIO, LINES-TRUNCATE,
OVERRIDE-PARAMETERS, RESPECT-HEADER-LINE, RESPECT-MODE-LINE,
ACCEPT-FOCUS."
(let ((left-fringe (or left-fringe 0))
(right-fringe (or right-fringe 0))
;; See emacs.git: Add distinct controls for child frames' borders (Bug#45620)
;; http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ff7b1a133bfa7f2614650f8551824ffaef13fadc
(border-width (or border-width internal-border-width 0))
(border-color (or border-color internal-border-color))
(buffer (get-buffer-create buffer-or-name))
(after-make-frame-functions nil)
(x-gtk-resize-child-frames posframe-gtk-resize-child-frames)
(args (list "args"
(display-graphic-p)
foreground-color
background-color
right-fringe
left-fringe
border-width
border-color
internal-border-width
internal-border-color
font
keep-ratio
override-parameters
respect-header-line
respect-mode-line
accept-focus)))
(with-current-buffer buffer
;; Many variables take effect after call `set-window-buffer'
(setq-local display-line-numbers nil)
(setq-local frame-title-format "")
(setq-local left-margin-width nil)
(setq-local right-margin-width nil)
(setq-local left-fringe-width nil)
(setq-local right-fringe-width nil)
(setq-local fringes-outside-margins 0)
(setq-local fringe-indicator-alist nil)
;; Need to use `lines-truncate' as our keyword variable instead
;; of `truncate-lines' so we don't shadow the variable that we
;; are trying to set.
(setq-local truncate-lines lines-truncate)
(setq-local show-trailing-whitespace nil)
(setq-local posframe--accept-focus accept-focus)
(unless respect-mode-line
(setq-local mode-line-format nil))
(unless respect-header-line
(setq-local header-line-format nil))
(if cursor
(progn
(setq-local cursor-type cursor)
(setq-local cursor-in-non-selected-windows cursor))
(setq-local cursor-type nil)
(setq-local cursor-in-non-selected-windows nil))
;; Find existing posframe: buffer-local variables used by
;; posframe can be cleaned by other packages, so we should find
;; existing posframe first if possible.
(unless (or posframe--frame posframe--last-args)
(setq-local posframe--frame
(posframe--find-existing-posframe buffer args))
(setq-local posframe--last-args args))
;; Create child-frame
(unless (and posframe--frame
(frame-live-p posframe--frame)
;; For speed reason, posframe will reuse
;; existing frame at possible, but when
;; user change args, recreating frame
;; is needed.
(equal posframe--last-args args))
(posframe-delete-frame buffer)
(setq-local posframe--last-args args)
(setq-local posframe--last-posframe-pixel-position nil)
(setq-local posframe--last-posframe-size nil)
(setq-local posframe--frame
(make-frame
`(,@override-parameters
,(when foreground-color
(cons 'foreground-color foreground-color))
,(when background-color
(cons 'background-color background-color))
(title . "posframe")
(parent-frame . ,parent-frame)
(keep-ratio ,keep-ratio)
(posframe-buffer . ,(cons (buffer-name buffer)
buffer))
(fullscreen . nil)
(no-accept-focus . ,(not accept-focus))
(min-width . 0)
(min-height . 0)
(border-width . 0)
(internal-border-width . ,border-width)
(child-frame-border-width . ,border-width)
(vertical-scroll-bars . nil)
(horizontal-scroll-bars . nil)
(left-fringe . ,left-fringe)
(right-fringe . ,right-fringe)
(menu-bar-lines . 0)
(tool-bar-lines . 0)
(tab-bar-lines . 0)
(line-spacing . 0)
(unsplittable . t)
(no-other-frame . t)
;; NOTE: TTY child frame use undecorated to control border.
(undecorated . ,(or (display-graphic-p)
(not (and (> border-width 0)
(featurep 'tty-child-frames)))))
(visibility . nil)
(cursor-type . ,cursor)
(tty-non-selected-cursor . ,tty-non-selected-cursor)
(minibuffer . ,(minibuffer-window parent-frame))
(left . ,(if (consp position) (car position) 0))
(top . ,(if (consp position) (cdr position) 0))
(width . 1)
(height . 1)
(no-special-glyphs . t)
(skip-taskbar . t)
(inhibit-double-buffering . ,posframe-inhibit-double-buffering)
;; Do not save child-frame when use desktop.el
(desktop-dont-save . t))))
(set-frame-parameter posframe--frame 'last-args args)
(set-frame-parameter
posframe--frame 'font
(or font (face-attribute 'default :font parent-frame)))
(when border-color
(if parent-frame
(set-face-background
(if (facep 'child-frame-border)
'child-frame-border
'internal-border)
border-color posframe--frame)
;; NOTE: when use refposhander feature, parent-frame will be
;; nil, we should use internal-border instead.
(set-face-background
'internal-border
border-color posframe--frame))
;; HACK: Set face background after border color, otherwise the
;; border is not updated (BUG!).
(when (version< emacs-version "28.0")
(set-frame-parameter
posframe--frame 'background-color
(or background-color (face-attribute 'default :background)))))
(let ((posframe-window (frame-root-window posframe--frame)))
;; This method is more stable than 'setq mode/header-line-format nil'
(unless respect-mode-line
(set-window-parameter posframe-window 'mode-line-format 'none))
(unless respect-header-line
(set-window-parameter posframe-window 'header-line-format 'none))
(set-window-buffer posframe-window buffer)
;; When the buffer of posframe is killed, the child-frame of
;; this posframe will be deleted too.
(set-window-dedicated-p posframe-window t)))
;; Remove tab-bar always.
;; NOTE: if we do not test the value of frame parameter
;; 'tab-bar-lines before set it, posframe will flicker when
;; scroll.
(unless (equal (frame-parameter posframe--frame 'tab-bar-lines) 0)
(set-frame-parameter posframe--frame 'tab-bar-lines 0))
(when (version< "27.0" emacs-version)
(setq-local tab-line-format nil))
;; If user set 'parent-frame to nil after run posframe-show.
;; for cache reason, next call to posframe-show will be affected.
;; so we should force set parent-frame again in this place.
(set-frame-parameter posframe--frame 'parent-frame parent-frame)
;; Set text scale based on the parent frame text scale.
(text-scale-set
(funcall posframe-text-scale-factor-function parent-text-scale-mode-amount))
posframe--frame)))