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

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

[elpa] externals/company 0ae10dc 1/2: Enable icons by default for everyb


From: ELPA Syncer
Subject: [elpa] externals/company 0ae10dc 1/2: Enable icons by default for everybody
Date: Sun, 2 May 2021 21:57:09 -0400 (EDT)

branch: externals/company
commit 0ae10dc3609546d0fe80a7c72b3e4c6e5ef4a3d7
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Enable icons by default for everybody
---
 NEWS.md    | 6 ++++--
 company.el | 9 ++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index de78499..ccd6512 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -10,8 +10,10 @@
 * Added support for icons
   ([#1070](https://github.com/company-mode/company-mode/pull/1070)), disabled 
by
   default. New user option `company-format-margin-function`. New backend 
command
-  `kind`. Both built-in options for `company-format-margin-function` require
-  Emacs compiled with SVG support.
+  `kind`. There are two built-in icon sets, one for light and another for dark
+  icons. Both use SVG. The default behavior is to choose the best one for the
+  current theme automatically, or if the current frame is non-graphical or
+  simply does not support rendering SVG images, fall back to text-based 
"icons".
 * New user option `company-abort-on-unique-match`
   ([#1046](https://github.com/company-mode/company-mode/issues/1046)).
 * `company-select-mouse` is a new frontend action
diff --git a/company.el b/company.el
index e1647ba..0dfc49b 100644
--- a/company.el
+++ b/company.el
@@ -1582,16 +1582,15 @@ Only affects `company-text-icons-margin'."
     (propertize company-dot-icons-format 'face face)))
 
 (defun company-detect-icons-margin (candidate selected)
-  "Margin function which picks from vscodes icons or unicode icons
-based on `display-graphic-p'."
-  (if (display-graphic-p)
-      ;; Default to dark because who in their right mind uses light 😜
+  "Margin function which picks the appropriate icon set automatically."
+  (if (and (display-graphic-p)
+           (image-type-available-p 'svg))
       (cl-case (frame-parameter nil 'background-mode)
         ('light (company-vscode-light-icons-margin candidate selected))
         (t (company-vscode-dark-icons-margin candidate selected)))
     (company-text-icons-margin candidate selected)))
 
-(defcustom company-format-margin-function nil
+(defcustom company-format-margin-function #'company-detect-icons-margin
   "Function to format the margin.
 It accepts 2 params `candidate' and `selected' and can be used for
 inserting prefix/image before the completion items. Typically, the



reply via email to

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