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

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

[elpa] externals/kiwix 444f686a7f 15/15: Display kiwix library thumbnail


From: ELPA Syncer
Subject: [elpa] externals/kiwix 444f686a7f 15/15: Display kiwix library thumbnail URL image in vertico candidates.
Date: Wed, 7 Dec 2022 19:58:03 -0500 (EST)

branch: externals/kiwix
commit 444f686a7f75db788d54f544b923a3532732eb8b
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>

    Display kiwix library thumbnail URL image in vertico candidates.
---
 kiwix.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/kiwix.el b/kiwix.el
index 732bac31de..0ee4d39461 100644
--- a/kiwix.el
+++ b/kiwix.el
@@ -57,6 +57,7 @@
 
 
 (require 'cl-lib)
+(require 'url)
 (require 'request)
 (require 'subr-x)
 (require 'thingatpt)
@@ -187,7 +188,22 @@ Set it to ‘t’ will use Emacs built-in ‘completing-read’."
                                                                                
  entry-xml)))))
                                                      (library-filename 
(string-trim-left library-link-path "/")))
                                                 (propertize library-filename
-                                                            'display (format 
"%s (%s)" title library-filename)))))
+                                                            'display (concat
+                                                                      
(when-let ((return-buffer (url-retrieve-synchronously thumbnail-url :silent)))
+                                                                        
(unwind-protect
+                                                                            
(let ((image-data (with-current-buffer return-buffer
+                                                                               
                 (goto-char (point-min))
+                                                                               
                 (search-forward "\n\n") ; skip HTTP response headers.
+                                                                               
                 (buffer-substring-no-properties (point) (point-max)))))
+                                                                              
(kill-buffer return-buffer)
+                                                                              
(propertize " "
+                                                                               
           'display (create-image image-data nil t
+                                                                               
                                  :ascent 'center
+                                                                               
                                  :max-height (default-font-height))
+                                                                               
           'read-only t))))
+                                                                      " "
+                                                                      (format 
"%s (%s)" title library-filename))
+                                                            'read-only t))))
                                           xml-data))))))
         :error (cl-function
                 (lambda (&rest args &key error-thrown &allow-other-keys)



reply via email to

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