[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/posframe 2c5f390 16/40: 'posframe-buffer-frame': New fu

From: Feng Shu
Subject: [elpa] externals/posframe 2c5f390 16/40: 'posframe-buffer-frame': New function to get a buffer's posframe
Date: Wed, 5 Feb 2020 04:27:19 -0500 (EST)

branch: externals/posframe
commit 2c5f3905df8c4a6def766196759a00eb249163de
Author: Štěpán Němec <address@hidden>
Commit: Štěpán Němec <address@hidden>

    'posframe-buffer-frame': New function to get a buffer's posframe
    Use it in 'posframe-hide'.
    The main motivation for adding the function is convenience for users
    of the library (it was the first thing I missed in my own
 posframe.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/posframe.el b/posframe.el
index ea0892f..d82c9cc 100644
--- a/posframe.el
+++ b/posframe.el
@@ -664,13 +664,16 @@ WIDTH and MIN-WIDTH."
                           frame height min-height width min-width)))
                    posframe height min-height width min-width)))))
+(defun posframe-buffer-frame (buffer-or-name)
+  "Return the posframe pertaining to BUFFER-OR-NAME.
+BUFFER-OR-NAME can be a buffer or a buffer name."
+  (when-let ((buffer (get-buffer buffer-or-name)))
+    (with-current-buffer buffer posframe--frame)))
 (defun posframe-hide (buffer-or-name)
   "Hide posframe pertaining to BUFFER-OR-NAME."
-  (dolist (frame (frame-list))
-    (let ((buffer-info (frame-parameter frame 'posframe-buffer)))
-      (when (or (equal buffer-or-name (car buffer-info))
-                (equal buffer-or-name (cdr buffer-info)))
-        (posframe--make-frame-invisible frame)))))
+  (when-let ((frame (posframe-buffer-frame buffer-or-name)))
+    (posframe--make-frame-invisible frame)))
 (defun posframe-delete (buffer-or-name)
   "Delete posframe which buffer BUFFER-OR-NAME."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]