emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master 2e8003e 04/33: posframe: Add posframe--last-font-height-in


From: Feng Shu
Subject: [elpa] master 2e8003e 04/33: posframe: Add posframe--last-font-height-info.
Date: Fri, 14 Dec 2018 06:21:13 -0500 (EST)

branch: master
commit 2e8003eb7e110ecb011b4fd9966362388c7e16ab
Author: Feng Shu <address@hidden>
Commit: Feng Shu <address@hidden>

    posframe: Add posframe--last-font-height-info.
    
    * posframe.el (posframe--last-font-height-info): New variable.
    (posframe--get-font-height): Use posframe--last-font-height-info.
---
 posframe.el | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/posframe.el b/posframe.el
index 4b76901..393c1c0 100644
--- a/posframe.el
+++ b/posframe.el
@@ -123,6 +123,9 @@
 (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'.
 
@@ -394,15 +397,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.



reply via email to

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