branch: master commit 769adaaaef6d8266c269e6bab799b5c337fbe5b0 Merge: d461e05 09e3f19 Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
Merge commit '09e3f1937d19243cfb02178540aaf5c78f2e2939' --- packages/posframe/README.md | 75 +++++---- packages/posframe/posframe.el | 362 +++++++++++++++++++++++++++++------------- 2 files changed, 294 insertions(+), 143 deletions(-) diff --git a/packages/posframe/README.md b/packages/posframe/README.md index 3f227e5..8648b3b 100644 --- a/packages/posframe/README.md +++ b/packages/posframe/README.md @@ -1,23 +1,25 @@ +Note: this file is auto converted from posframe.el by [el2org](https://github.com/tumashu/el2org), please do not edit it by hand!!! + # 目录 -1. [Posframe README](#org53f6910) - 1. [What is posframe](#org5cf1be8) - 2. [Installation](#org5f830e9) - 3. [Usage](#org40db1ee) - 1. [Create a posframe](#org6f36699) - 2. [Hide a posframe](#orgcd529fe) - 3. [Hide all posframes](#org4e71a28) - 4. [Delete a posframe](#org0f069f2) - 5. [Delete all posframes](#org853d491) +1. [Posframe README](#org83cbaa0) + 1. [What is posframe](#org3ce725d) + 2. [Installation](#org545827a) + 3. [Usage](#orgdac766b) + 1. [Create a posframe](#orgea6aecd) + 2. [Hide a posframe](#orga5310b9) + 3. [Hide all posframes](#orgbf09855) + 4. [Delete a posframe](#org68db811) + 5. [Delete all posframes](#org12f2467) -<a id="org53f6910"></a> +<a id="org83cbaa0"></a> # Posframe README -<a id="org5cf1be8"></a> +<a id="org3ce725d"></a> ## What is posframe @@ -29,58 +31,77 @@ The main advantages are: 1. It is fast enough for daily usage :-) 2. It works well with CJK language. -NOTE: For MacOS users, posframe need emacs (version >= 26.0.91) +NOTE: For MacOS users, posframe need Emacs (version >= 26.0.91)  -<a id="org5f830e9"></a> +<a id="org545827a"></a> ## Installation (require 'posframe) -<a id="org40db1ee"></a> +<a id="orgdac766b"></a> ## Usage -<a id="org6f36699"></a> +<a id="orgea6aecd"></a> ### Create a posframe - (posframe-show " *my-posframe-buffer*" - :string "This is a test" - :position (point)) +1. Simple way + + NOTE: buffers prefixed with space will be not showed in buffer-list. + (posframe-show " *my-posframe-buffer*" + :string "This is a test" + :position (point)) + +2. Advanced way + + (defvar my-posframe-buffer " *my-posframe-buffer*") + + (with-current-buffer (get-buffer-create my-posframe-buffer) + (erase-buffer) + (insert "Hello world")) + + (posframe-show my-posframe-buffer + :position (point)) -Arguments documents: +3. Arguments - C-h f posframe-show + C-h f posframe-show -<a id="orgcd529fe"></a> +<a id="orga5310b9"></a> ### Hide a posframe (posframe-hide " *my-posframe-buffer*") -<a id="org4e71a28"></a> +<a id="orgbf09855"></a> ### Hide all posframes M-x posframe-hide-all -<a id="org0f069f2"></a> +<a id="org68db811"></a> ### Delete a posframe - (posframe-delete " *my-posframe-buffer*") +1. Delete posframe and its buffer + (posframe-delete " *my-posframe-buffer*") +2. Only delete posframe's frame -<a id="org853d491"></a> + (posframe-delete-frame " *my-posframe-buffer*") + + +<a id="org12f2467"></a> ### Delete all posframes @@ -89,7 +110,3 @@ Arguments documents: Note: this command will delete all posframe buffers, suggest not run this command if you are sharing a buffer between posframe and other packages. - - - -Converted from posframe.el by [el2org](https://github.com/tumashu/el2org) . \ No newline at end of file diff --git a/packages/posframe/posframe.el b/packages/posframe/posframe.el index 9a7a73f..2c165d4 100644 --- a/packages/posframe/posframe.el +++ b/packages/posframe/posframe.el @@ -5,7 +5,7 @@ ;; Author: Feng Shu <tuma...@163.com> ;; Maintainer: Feng Shu <tuma...@163.com> ;; URL: https://github.com/tumashu/posframe -;; Version: 0.3.0 +;; Version: 0.4.2 ;; Keywords: tooltip ;; Package-Requires: ((emacs "26")) @@ -50,13 +50,28 @@ ;; *** Create a posframe +;; **** Simple way ;; #+BEGIN_EXAMPLE +;; ;; NOTE: buffers prefixed with space will be not showed in buffer-list. ;; (posframe-show " *my-posframe-buffer*" ;; :string "This is a test" ;; :position (point)) ;; #+END_EXAMPLE -;; Arguments documents: +;; **** Advanced way +;; #+BEGIN_EXAMPLE +;; (defvar my-posframe-buffer " *my-posframe-buffer*") + +;; (with-current-buffer (get-buffer-create my-posframe-buffer) +;; (erase-buffer) +;; (insert "Hello world")) + +;; (posframe-show my-posframe-buffer +;; :position (point)) +;; #+END_EXAMPLE + +;; **** Arguments + ;; #+BEGIN_EXAMPLE ;; C-h f posframe-show ;; #+END_EXAMPLE @@ -98,7 +113,7 @@ :group 'lisp :prefix "posframe-") -(defcustom posframe-mouse-banish t +(defcustom posframe-mouse-banish (not (eq system-type 'darwin)) "Mouse will be moved to (0 , 0) when it is non-nil." :group 'posframe :type 'boolean) @@ -108,10 +123,17 @@ :group 'posframe :type 'boolean) +(defcustom posframe-default-initialize-function nil + "The default :initialize function of `posframe-show'. + +If :initialize argument of `posframe-show' is nil, this function +will be called as fallback." + :type 'function) + (defvar-local posframe--frame nil "Record posframe's frame.") -(defvar-local posframe--last-position nil +(defvar-local posframe--last-posframe-pixel-position nil "Record the last pixel position of posframe's frame.") (defvar-local posframe--last-posframe-size nil @@ -120,6 +142,12 @@ (defvar-local posframe--last-parent-frame-size nil "Record the last size of posframe's parent-frame.") +(defvar-local posframe--last-poshandler-info nil + "Record the last poshandler info.") + +(defvar-local posframe--last-font-height-info nil + "Record the last font height info.") + (defvar-local posframe--last-args nil "Record the last arguments of `posframe--create-posframe'. @@ -132,6 +160,8 @@ frame.") (defvar-local posframe--refresh-timer nil "Record the timer to deal with refresh argument of `posframe-show'.") +(defvar-local posframe--initialized-p nil + "Record initialize status of `posframe-show'.") (cl-defun posframe--create-posframe (posframe-buffer &key @@ -140,15 +170,18 @@ frame.") background-color left-fringe right-fringe + internal-border-width font keep-ratio override-parameters respect-header-line - respect-mode-line) + respect-mode-line + face-remap) "Create a child-frame for posframe. This posframe's buffer is POSFRAME-BUFFER." (let ((left-fringe (or left-fringe 0)) (right-fringe (or right-fringe 0)) + (internal-border-width (or internal-border-width 0)) (posframe-buffer (get-buffer-create posframe-buffer)) (after-make-frame-functions nil) (args (list parent-frame @@ -156,13 +189,16 @@ This posframe's buffer is POSFRAME-BUFFER." background-color right-fringe left-fringe + internal-border-width font keep-ratio override-parameters respect-header-line - respect-mode-line))) + respect-mode-line + face-remap))) (with-current-buffer posframe-buffer ;; Many variables take effect after call `set-window-buffer' + (setq-local frame-title-format "") (setq-local left-fringe-width nil) (setq-local right-fringe-width nil) (setq-local fringes-outside-margins 0) @@ -170,6 +206,7 @@ This posframe's buffer is POSFRAME-BUFFER." (setq-local cursor-type nil) (setq-local cursor-in-non-selected-windows nil) (setq-local show-trailing-whitespace nil) + (setq-local face-remapping-alist face-remap) (unless respect-mode-line (setq-local mode-line-format nil)) (unless respect-header-line @@ -184,7 +221,7 @@ This posframe's buffer is POSFRAME-BUFFER." (equal posframe--last-args args)) (posframe-delete-frame posframe-buffer) (setq-local posframe--last-args args) - (setq-local posframe--last-position nil) + (setq-local posframe--last-posframe-pixel-position nil) (setq-local posframe--last-posframe-size nil) (setq-local posframe--frame (make-frame @@ -199,11 +236,12 @@ This posframe's buffer is POSFRAME-BUFFER." (keep-ratio ,keep-ratio) (posframe-buffer . ,(cons (buffer-name posframe-buffer) posframe-buffer)) + (fullscreen . nil) (no-accept-focus . t) (min-width . 0) (min-height . 0) (border-width . 0) - (internal-border-width . 0) + (internal-border-width . ,internal-border-width) (vertical-scroll-bars . nil) (horizontal-scroll-bars . nil) (left-fringe . ,left-fringe) @@ -245,11 +283,14 @@ This posframe's buffer is POSFRAME-BUFFER." y-pixel-offset left-fringe right-fringe + internal-border-width font foreground-color background-color respect-header-line respect-mode-line + face-remap + initialize no-properties keep-ratio override-parameters @@ -266,26 +307,46 @@ POSITION can be: POSHANDLER is a function with one argument, and return a real position. its argument is a plist, which like - (:position xxx :poshandler xxx - :font-height xxx :font-width xxx - :posframe xxx :posframe-buffer xxx - :parent-frame xxx :parent-window xxx - :x-pixel-offset xxx :y-pixel-offset xxx) + (:position xxx + :position-info xxx + :poshandler xxx + :font-height xxx + :font-width xxx + :posframe xxx + :posframe-width xxx + :posframe-height xxx + :posframe-buffer xxx + :parent-frame xxx + :parent-window-left xxx + :parent-window-top xxx + :parent-frame-width xxx + :parent-frame-height xxx + :parent-window xxx + :parent-window-width xxx + :parent-window-height xxx + :minibuffer-height + :mode-line-height + :header-line-height + :x-pixel-offset xxx + :y-pixel-offset xxx) by default, poshandler is auto selected based on POSITION's type, but user can *force* set one with the help of POSHANDLER argument. the below are buildin poshandler functions: -1. `posframe-poshandler-frame-center' -2. `posframe-poshandler-frame-bottom-left-corner' -3. `posframe-poshandler-frame-bottom-right-corner' -4. `posframe-poshandler-window-center' -5. `posframe-poshandler-window-top-left-corner' -6. `posframe-poshandler-window-top-right-corner' -7. `posframe-poshandler-window-bottom-left-corner' -8. `posframe-poshandler-window-bottom-right-corner' -9. `posframe-poshandler-point-top-left-corner' -9. `posframe-poshandler-point-bottom-left-corner' +1. `posframe-poshandler-frame-center' +2. `posframe-poshandler-frame-top-center' +3. `posframe-poshandler-frame-top-left-corner' +4. `posframe-poshandler-frame-top-right-corner' +5. `posframe-poshandler-frame-bottom-left-corner' +6. `posframe-poshandler-frame-bottom-right-corner' +7. `posframe-poshandler-window-center' +8. `posframe-poshandler-window-top-left-corner' +9. `posframe-poshandler-window-top-right-corner' +10. `posframe-poshandler-window-bottom-left-corner' +11. `posframe-poshandler-window-bottom-right-corner' +12. `posframe-poshandler-point-top-left-corner' +13. `posframe-poshandler-point-bottom-left-corner' This posframe's buffer is POSFRAME-BUFFER. @@ -300,6 +361,11 @@ size too small, MIN-WIDTH and MIN-HEIGTH will be useful If LEFT-FRINGE or RIGHT-FRINGE is a number, Left fringe or right fringe with be showed with number width. +By default, posframe shows no border, user can let border +showed by setting INTERNAL-BORDER-WIDTH to a postive number, +by the way, border's color is specified by the background of +the ‘internal-border’ face. + By default, posframe's font is deriverd from current frame user can set posframe's font with FONT argument. @@ -311,6 +377,17 @@ By default, posframe will force hide header-line and mode-line If user want to show header-line or mode-line in posframe, set RESPECT-HEADER-LINE or RESPECT-MODE-LINE to t. +If user want to let posframe use different faces from other frame. +user can set FACE-REMAP, more setting details can be found: + + C-h v face-remapping-alist + +INITIALIZE is a function with no argument, it will run when +posframe buffer is first selected with `with-current-buffer' +in posframe-show, and only run once for speed reason, If INITIALIZE +is nil, `posframe-default-initialize-function' will be used as +fallback, user can use this variable to global set posframe buffer. + OVERRIDE-PARAMETERS is very powful, *all* the frame parameters used by posframe's frame can be overrided by it. @@ -328,15 +405,31 @@ you can use `posframe-delete-all' to delete all posframes." (min-width (or min-width 1)) (min-height (or min-height 1)) (parent-window (selected-window)) + (parent-window-top (window-pixel-top parent-window)) + (parent-window-left (window-pixel-left parent-window)) + (parent-window-width (window-pixel-width parent-window)) + (parent-window-height (window-pixel-height parent-window)) + (position-info (posn-at-point position parent-window)) (parent-frame (window-frame parent-window)) (parent-frame-width (frame-pixel-width parent-frame)) (parent-frame-height (frame-pixel-height parent-frame)) (font-width (default-font-width)) (font-height (posframe--get-font-height position)) + (mode-line-height (window-mode-line-height)) + (minibuffer-height (window-pixel-height (minibuffer-window))) + (header-line-height (window-header-line-height parent-window)) (frame-resize-pixelwise t) posframe) (with-current-buffer posframe-buffer + + ;; Initialize + (unless posframe--initialized-p + (let ((func (or initialize posframe-default-initialize-function))) + (when (functionp func) + (funcall func) + (setq posframe--initialized-p t)))) + ;; Move mouse to (0 . 0) (posframe--mouse-banish parent-frame) @@ -348,11 +441,13 @@ you can use `posframe-delete-all' to delete all posframes." :parent-frame parent-frame :left-fringe left-fringe :right-fringe right-fringe + :internal-border-width internal-border-width :foreground-color foreground-color :background-color background-color :keep-ratio keep-ratio :respect-header-line respect-header-line :respect-mode-line respect-mode-line + :face-remap face-remap :override-parameters override-parameters)) ;; Insert string to posframe-buffer. @@ -368,13 +463,25 @@ you can use `posframe-delete-all' to delete all posframes." (posframe-run-poshandler `(;All poshandlers will get info from this plist. :position ,position + :position-info ,position-info :poshandler ,poshandler :font-height ,font-height :font-width ,font-width :posframe ,posframe + :posframe-width ,(frame-pixel-width posframe) + :posframe-height ,(frame-pixel-height posframe) :posframe-buffer ,posframe-buffer :parent-frame ,parent-frame + :parent-frame-width ,parent-frame-width + :parent-frame-height ,parent-frame-height :parent-window ,parent-window + :parent-window-top ,parent-window-top + :parent-window-left ,parent-window-left + :parent-window-width ,parent-window-width + :parent-window-height ,parent-window-height + :mode-line-height ,mode-line-height + :minibuffer-height ,minibuffer-height + :header-line-height ,header-line-height :x-pixel-offset ,x-pixel-offset :y-pixel-offset ,y-pixel-offset)) parent-frame-width parent-frame-height) @@ -391,15 +498,20 @@ you can use `posframe-delete-all' to delete all posframes." (defun posframe--get-font-height (position) "Get the font's height at POSITION." - (when (integerp position) - (if (= position 1) - (default-line-height) - (aref (font-info - (font-at - (if (and (= position (point-max))) - (- position 1) - position))) - 3)))) + (if (eq position (car posframe--last-font-height-info)) + (cdr posframe--last-font-height-info) + (let ((height (when (integerp position) + (if (= position 1) + (default-line-height) + (aref (font-info + (font-at + (if (and (= position (point-max))) + (- position 1) + position))) + 3))))) + (setq posframe--last-font-height-info + (cons position height)) + height))) (defun posframe--mouse-banish (frame) "Banish mouse to the (0 . 0) of FRAME. @@ -442,13 +554,13 @@ WIDTH and MIN-WIDTH." parent-frame-height) "Move POSFRAME to POSITION. This need PARENT-FRAME-WIDTH and PARENT-FRAME-HEIGHT" - (unless (and (equal position posframe--last-position) + (unless (and (equal position posframe--last-posframe-pixel-position) ;; When working frame's size change, re-posit ;; the posframe. (equal posframe--last-parent-frame-size (cons parent-frame-width parent-frame-height))) (set-frame-position posframe (car position) (cdr position)) - (setq-local posframe--last-position position) + (setq-local posframe--last-posframe-pixel-position position) (setq-local posframe--last-parent-frame-size (cons parent-frame-width parent-frame-height))) ;; Make posframe's posframe--frame visible @@ -462,7 +574,12 @@ This need PARENT-FRAME-WIDTH and PARENT-FRAME-HEIGHT" (cancel-timer posframe--timeout-timer)) (setq-local posframe--timeout-timer (run-with-timer - secs nil #'make-frame-invisible posframe)))) + secs nil #'posframe--make-frame-invisible posframe)))) + +(defun posframe--make-frame-invisible (frame) + "This function used to instead `make-frame-invisible' to make hide frame safely." + (when (frame-live-p frame) + (make-frame-invisible frame))) (defun posframe--run-refresh-timer (posframe repeat height min-height @@ -490,7 +607,7 @@ WIDTH and MIN-WIDTH." (let ((buffer-info (frame-parameter frame 'posframe-buffer))) (when (or (equal posframe-buffer (car buffer-info)) (equal posframe-buffer (cdr buffer-info))) - (make-frame-invisible frame))))) + (posframe--make-frame-invisible frame))))) (defun posframe-delete (posframe-buffer) "Delete posframe which buffer POSFRAME-BUFFER." @@ -524,7 +641,7 @@ This posframe's buffer is POSFRAME-BUFFER." (interactive) (dolist (frame (frame-list)) (let ((buffer-info (frame-parameter frame 'posframe-buffer))) - (when buffer-info (make-frame-invisible frame))))) + (when buffer-info (posframe--make-frame-invisible frame))))) ;;;###autoload (defun posframe-delete-all () @@ -552,17 +669,20 @@ This function is used by `kill-buffer-hook'." the structure of INFO can be found in docstring of `posframe-show'." - (funcall - (or (plist-get info :poshandler) - (let ((position (plist-get info :position))) - (cond ((integerp position) - #'posframe-poshandler-point-bottom-left-corner) - ((and (consp position) - (integerp (car position)) - (integerp (cdr position))) - #'posframe-poshandler-absolute-x-y) - (t (error "Posframe: have no valid poshandler"))))) - info)) + (if (equal info posframe--last-poshandler-info) + posframe--last-posframe-pixel-position + (setq posframe--last-poshandler-info info) + (funcall + (or (plist-get info :poshandler) + (let ((position (plist-get info :position))) + (cond ((integerp position) + #'posframe-poshandler-point-bottom-left-corner) + ((and (consp position) + (integerp (car position)) + (integerp (cdr position))) + #'posframe-poshandler-absolute-x-y) + (t (error "Posframe: have no valid poshandler"))))) + info))) (defun posframe-poshandler-absolute-x-y (info) "Posframe's position hanlder. @@ -584,29 +704,25 @@ the structure of INFO can be found in docstring of `posframe-show'. Optional argument FONT-HEIGHT ." - (let* ((position (plist-get info :position)) - (x-pixel-offset (plist-get info :x-pixel-offset)) + (let* ((x-pixel-offset (plist-get info :x-pixel-offset)) (y-pixel-offset (plist-get info :y-pixel-offset)) - (posframe-width (frame-pixel-width - (plist-get info :posframe))) - (posframe-height (frame-pixel-height - (plist-get info :posframe))) + (posframe-width (plist-get info :posframe-width)) + (posframe-height (plist-get info :posframe-height)) (window (plist-get info :parent-window)) - (frame (plist-get info :parent-frame)) - (xmax (frame-pixel-width frame)) - (ymax (frame-pixel-height frame)) - (header-line-height (window-header-line-height window)) - (posn-top-left (posn-at-point position window)) + (xmax (plist-get info :parent-frame-width)) + (ymax (plist-get info :parent-frame-height)) + (position-info (plist-get info :position-info)) + (header-line-height (plist-get info :header-line-height)) (x (+ (car (window-inside-pixel-edges window)) - (- (or (car (posn-x-y posn-top-left)) 0) - (or (car (posn-object-x-y posn-top-left)) 0)) + (- (or (car (posn-x-y position-info)) 0) + (or (car (posn-object-x-y position-info)) 0)) x-pixel-offset)) (y-top (+ (cadr (window-pixel-edges window)) header-line-height - (- (or (cdr (posn-x-y posn-top-left)) 0) + (- (or (cdr (posn-x-y position-info)) 0) ;; Fix the conflict with flycheck ;; http://lists.gnu.org/archive/html/emacs-devel/2018-01/msg00537.html - (or (cdr (posn-object-x-y posn-top-left)) 0)) + (or (cdr (posn-object-x-y position-info)) 0)) y-pixel-offset)) (font-height (or font-height (plist-get info :font-height))) (y-bottom (+ y-top font-height))) @@ -630,34 +746,61 @@ of `posframe-show'." Get a position which let posframe stay onto its parent-frame's center. The structure of INFO can be found in docstring of `posframe-show'." - (let* ((posframe (plist-get info :posframe)) - (parent-frame (plist-get info :parent-frame))) - (cons (/ (- (frame-pixel-width parent-frame) - (frame-pixel-width posframe)) - 2) - (/ (- (frame-pixel-height parent-frame) - (frame-pixel-height posframe)) - 2)))) - -(defun posframe-poshandler-frame-bottom-left-corner (_info) + (cons (/ (- (plist-get info :parent-frame-width) + (plist-get info :posframe-width)) + 2) + (/ (- (plist-get info :parent-frame-height) + (plist-get info :posframe-height)) + 2))) + + +(defun posframe-poshandler-frame-top-center (info) + "Posframe's position handler. + +Get a position which let posframe stay onto its +parent-frame's top center. The structure of INFO can +be found in docstring of `posframe-show'." + (cons (/ (- (plist-get info :parent-frame-width) + (plist-get info :posframe-width)) + 2) + 0)) + +(defun posframe-poshandler-frame-top-left-corner (_info) + "Posframe's position handler. + +Get a position which let posframe stay onto its parent-frame's +top left corner. The structure of INFO can be found +in docstring of `posframe-show'." + '(0 . 0)) + +(defun posframe-poshandler-frame-top-right-corner (_info) + "Posframe's position handler. + +Get a position which let posframe stay onto its parent-frame's +top right corner. The structure of INFO can be found +in docstring of `posframe-show'." + '(-1 . 0)) + + +(defun posframe-poshandler-frame-bottom-left-corner (info) "Posframe's position handler. Get a position which let posframe stay onto its parent-frame's bottom left corner. The structure of INFO can be found in docstring of `posframe-show'." (cons 0 (- 0 - (window-mode-line-height) - (window-pixel-height (minibuffer-window))))) + (plist-get info :mode-line-height) + (plist-get info :minibuffer-height)))) -(defun posframe-poshandler-frame-bottom-right-corner (_info) +(defun posframe-poshandler-frame-bottom-right-corner (info) "Posframe's position handler. Get a position which let posframe stay onto its parent-frame's bottom right corner. The structure of INFO can be found in docstring of `posframe-show'." (cons -1 (- 0 - (window-mode-line-height) - (window-pixel-height (minibuffer-window))))) + (plist-get info :mode-line-height) + (plist-get info :minibuffer-height)))) (defun posframe-poshandler-window-center (info) "Posframe's position handler. @@ -665,14 +808,12 @@ in docstring of `posframe-show'." Get a position which let posframe stay onto current window's center. The structure of INFO can be found in docstring of `posframe-show'." - (let* ((posframe (plist-get info :posframe)) - (parent-window (plist-get info :parent-window)) - (window-left (window-pixel-left parent-window)) - (window-top (window-pixel-top parent-window)) - (window-width (window-pixel-width parent-window)) - (window-height (window-pixel-height parent-window)) - (posframe-width (frame-pixel-width posframe)) - (posframe-height (frame-pixel-height posframe))) + (let* ((window-left (plist-get info :parent-window-left)) + (window-top (plist-get info :parent-window-top)) + (window-width (plist-get info :parent-window-width)) + (window-height (plist-get info :parent-window-height)) + (posframe-width (plist-get info :posframe-width)) + (posframe-height (plist-get info :posframe-height))) (cons (+ window-left (/ (- window-width posframe-width) 2)) (+ window-top (/ (- window-height posframe-height) 2))))) @@ -682,9 +823,8 @@ of `posframe-show'." Get a position which let posframe stay onto current window's top left corner. The structure of INFO can be found in docstring of `posframe-show'." - (let* ((parent-window (plist-get info :parent-window)) - (window-left (window-pixel-left parent-window)) - (window-top (window-pixel-top parent-window))) + (let* ((window-left (plist-get info :parent-window-left)) + (window-top (plist-get info :parent-window-top))) (cons window-left window-top))) @@ -694,12 +834,10 @@ docstring of `posframe-show'." Get a position which let posframe stay onto current window's top right corner. The structure of INFO can be found in docstring of `posframe-show'." - (let* ((posframe (plist-get info :posframe)) - (window (plist-get info :parent-window)) - (window-left (window-pixel-left window)) - (window-top (window-pixel-top window)) - (window-width (window-pixel-width window)) - (posframe-width (frame-pixel-width posframe))) + (let* ((window-left (plist-get info :parent-window-left)) + (window-top (plist-get info :parent-window-top)) + (window-width (plist-get info :parent-window-width)) + (posframe-width (plist-get info :posframe-width))) (cons (+ window-left window-width (- 0 posframe-width)) window-top))) @@ -710,16 +848,14 @@ docstring of `posframe-show'." Get a position which let posframe stay onto current window's bottom left corner. The structure of INFO can be found in docstring of `posframe-show'." - (let* ((posframe (plist-get info :posframe)) - (window (plist-get info :parent-window)) - (window-left (window-pixel-left window)) - (window-top (window-pixel-top window)) - (window-height (window-pixel-height window)) - (posframe-height (frame-pixel-height posframe)) - (modeline-height (window-mode-line-height))) + (let* ((window-left (plist-get info :parent-window-left)) + (window-top (plist-get info :parent-window-top)) + (window-height (plist-get info :parent-window-height)) + (posframe-height (plist-get info :posframe-height)) + (mode-line-height (plist-get info :mode-line-height))) (cons window-left (+ window-top window-height - (- 0 modeline-height posframe-height))))) + (- 0 mode-line-height posframe-height))))) (defun posframe-poshandler-window-bottom-right-corner (info) "Posframe's position handler. @@ -727,24 +863,22 @@ docstring of `posframe-show'." Get a position which let posframe stay onto current window's bottom right corner. The structure of INFO can be found in docstring of `posframe-show'." - (let* ((posframe (plist-get info :posframe)) - (window (plist-get info :parent-window)) - (window-left (window-pixel-left window)) - (window-top (window-pixel-top window)) - (window-width (window-pixel-width window)) - (window-height (window-pixel-height window)) - (posframe-width (frame-pixel-width posframe)) - (posframe-height (frame-pixel-height posframe)) - (modeline-height (window-mode-line-height))) + (let* ((window-left (plist-get info :parent-window-left)) + (window-top (plist-get info :parent-window-top)) + (window-width (plist-get info :parent-window-width)) + (window-height (plist-get info :parent-window-height)) + (posframe-width (plist-get info :posframe-width)) + (posframe-height (plist-get info :posframe-height)) + (mode-line-height (plist-get info :mode-line-height))) (cons (+ window-left window-width (- 0 posframe-width)) (+ window-top window-height - (- 0 modeline-height posframe-height))))) + (- 0 mode-line-height posframe-height))))) (provide 'posframe) ;; Local Variables: -;; coding: utf-8-unix +;; coding: utf-8 ;; End: ;;; posframe.el ends here