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

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

[elpa] externals/corfu dc85ee32eb 6/9: Preserve corfu-bar-width and corf


From: ELPA Syncer
Subject: [elpa] externals/corfu dc85ee32eb 6/9: Preserve corfu-bar-width and corfu-bar face for compatibility
Date: Tue, 5 Nov 2024 03:58:06 -0500 (EST)

branch: externals/corfu
commit dc85ee32ebdd59fea86c5696a9f1d28f51b2c7bc
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Preserve corfu-bar-width and corfu-bar face for compatibility
---
 CHANGELOG.org | 10 +++-------
 corfu.el      | 33 +++++++++++++++++++--------------
 2 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index ca2f5ef552..91ed82bbb3 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -5,13 +5,9 @@
 * Development
 
 - Require Emacs 28.1.
-- Use fringe to display scroll bar. Make sure that the scroll bar cannot be
-  pushed outside the child frame by the content. This affects for example
-  ~cape-emoji~.
-- New face ~corfu-scroll-bar~ which replaces the old face ~corfu-bar~. For 
technical
-  reasons the foreground color is used for the scroll bar, and not the
-  background as for the old face.
-- Renamed ~corfu-bar-width~ to ~corfu-scroll-bar-width~ for consistency.
+- Use fringe to display scroll bar. This change improves performance and makes
+  sure that the scroll bar cannot be pushed outside the child frame by the
+  content. This affects for example ~cape-emoji~.
 - Improve suffix alignment.
 
 * Version 1.5 (2024-07-26)
diff --git a/corfu.el b/corfu.el
index 309d0397a9..5bdfbc9432 100644
--- a/corfu.el
+++ b/corfu.el
@@ -136,7 +136,7 @@ separator: Only stay alive if there is no match and
   "Width of the right margin in units of the character width."
   :type 'float)
 
-(defcustom corfu-scroll-bar-width 0.2
+(defcustom corfu-bar-width 0.2
   "Width of the bar in units of the character width."
   :type 'float)
 
@@ -214,11 +214,11 @@ See also the settings `corfu-auto-delay', 
`corfu-auto-prefix' and
     (t :background "blue" :foreground "white" :extend t))
   "Face used to highlight the currently selected candidate.")
 
-(defface corfu-scroll-bar
-  '((((class color) (min-colors 88) (background dark)) :foreground "#a8a8a8")
-    (((class color) (min-colors 88) (background light)) :foreground "#505050")
-    (t :foreground "gray"))
-  "The foreground color is used for the scrollbar indicator.")
+(defface corfu-bar
+  '((((class color) (min-colors 88) (background dark)) :background "#a8a8a8")
+    (((class color) (min-colors 88) (background light)) :background "#505050")
+    (t :background "gray"))
+  "The background color is used for the scrollbar indicator.")
 
 (defface corfu-border
   '((((class color) (min-colors 88) (background dark)) :background "#323232")
@@ -1019,17 +1019,17 @@ A scroll bar is displayed from LO to LO+BAR."
              ;; between 1 and 16. Therefore restrict the fringe width to 16.
              (ml (min 16 (ceiling (* cw corfu-left-margin-width))))
              (mr (min 16 (ceiling (* cw corfu-right-margin-width))))
-             (bw (min mr (ceiling (* cw corfu-scroll-bar-width))))
+             (bw (min mr (ceiling (* cw corfu-bar-width))))
              (fringe (display-graphic-p))
              (marginl (and (not fringe) (propertize " " 'display `(space 
:width (,ml)))))
              (sbar (if fringe
-                       #(" " 0 1 (display (right-fringe corfu--bar 
corfu-scroll-bar)))
-                     (concat (propertize " " 'display `(space :align-to (- 
right (,bw))))
-                             (propertize " " 'face '(:inherit corfu-scroll-bar 
:inverse-video t)
-                                         'display `(space :width (,bw))))))
+                       #(" " 0 1 (display (right-fringe corfu--bar 
corfu--bar)))
+                     (concat
+                      (propertize " " 'display `(space :align-to (- right 
(,bw))))
+                      (propertize " " 'face 'corfu-bar 'display `(space :width 
(,bw))))))
              (cbar (if fringe
                        #("  " 0 1 (display (left-fringe corfu--nil 
corfu-current))
-                         1 2 (display (right-fringe corfu--bar 
corfu--bar-cur)))
+                         1 2 (display (right-fringe corfu--bar corfu--cbar)))
                      sbar))
              (cmargin (and fringe
                            #("  " 0 1 (display (left-fringe corfu--nil 
corfu-current))
@@ -1050,13 +1050,18 @@ A scroll bar is displayed from LO to LO+BAR."
              (row 0)
              (bmp (logxor (1- (ash 1 mr)) (1- (ash 1 bw)))))
         (setq left-fringe-width (if fringe ml 0) right-fringe-width (if fringe 
mr 0))
+        ;; Define an inverted corfu--bar face
+        (unless (equal (and (facep 'corfu--bar) (face-attribute 'corfu--bar 
:foreground))
+                       (face-attribute 'corfu-bar :background))
+          (set-face-attribute (make-face 'corfu--bar) nil
+                              :foreground (face-attribute 'corfu-bar 
:background)))
         (unless (or (= right-fringe-width 0) (eq (get 'corfu--bar 'corfu--bmp) 
bmp))
           (put 'corfu--bar 'corfu--bmp bmp)
           (define-fringe-bitmap 'corfu--bar (vector (lognot bmp)) 1 mr '(top 
periodic))
           (define-fringe-bitmap 'corfu--nil [])
           ;; Fringe bitmaps require symbol face specification, define internal 
face.
-          (set-face-attribute (make-face 'corfu--bar-cur) nil
-                              :inherit '(corfu-scroll-bar corfu-current)))
+          (set-face-attribute (make-face 'corfu--cbar) nil
+                              :inherit '(corfu--bar corfu-current)))
         (with-silent-modifications
           (erase-buffer)
           (apply #'insert



reply via email to

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