[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/svg-lib a1bfa49 15/32: Add svg-lib-icons-dir
From: |
ELPA Syncer |
Subject: |
[elpa] externals/svg-lib a1bfa49 15/32: Add svg-lib-icons-dir |
Date: |
Mon, 27 Sep 2021 16:57:48 -0400 (EDT) |
branch: externals/svg-lib
commit a1bfa49a5365605f765bd82c76b15f14b25c5ad8
Author: Damon Chan <damon.chan@freshup.com.hk>
Commit: Damon Chan <damon.chan@freshup.com.hk>
Add svg-lib-icons-dir
Icons are downloaded to `svg-lib-icons-dir` rather than cache by
`url-cache`.
Cache by url-cache is not an ideal way for multiple platforms, since the
md5 of same icon on different platform is different.
This commit is downloading the icons to `svg-lib-icons-dir`.
---
svg-lib.el | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/svg-lib.el b/svg-lib.el
index 7a06071..682916a 100644
--- a/svg-lib.el
+++ b/svg-lib.el
@@ -103,6 +103,10 @@ collection (there are way too many to store them)."
:value-type (string :tag "URL"))
:group 'svg-lib)
+(defcustom svg-lib-icons-dir "~/Downloads"
+ "svg-lib icons directory."
+ :group 'svg-lib
+ :type 'directory)
;; Default style for all objects
;; ---------------------------------------------------------------------
@@ -310,13 +314,16 @@ Cached version is returned if it exists unless
FORCE-RELOAD is t."
;; Build url from collection and name without checking for error
(let ((url (format (cdr (assoc collection svg-lib-icon-collections)) name)))
;; Get data from cache
- (let ((buffer (if (or force-reload (not (url-is-cached url)))
- (let ((url-automatic-caching t)
- (filename (url-cache-create-filename url)))
- (with-current-buffer (url-retrieve-synchronously url)
- (write-region (point-min) (point-max) filename)
- (current-buffer)))
- (url-fetch-from-cache url))))
+ (let* ((filename (expand-file-name (format "%s_%s.svg" collection name)
svg-lib-icons-dir))
+ (buffer (if (or force-reload (not (file-exists-p filename)))
+ (with-current-buffer (url-retrieve-synchronously url)
+ (goto-char (point-min))
+ (search-forward "\n\n")
+ (write-region (point) (point-max) filename)
+ (current-buffer))
+ (with-current-buffer (generate-new-buffer " *temp*")
+ (insert-file-contents filename)
+ (current-buffer)))))
(with-current-buffer buffer
(xml-parse-region (point-min) (point-max))))))
- [elpa] branch externals/svg-lib created (now f9e1bbb), ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib f732499 02/32: Updated description, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib 778ef64 04/32: Full rewrite, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib 6a83751 01/32: Initial import, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib 5787149 07/32: Added button object, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib fe5e099 13/32: Do not fetch svg if it is cached, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib a1bfa49 15/32: Add svg-lib-icons-dir,
ELPA Syncer <=
- [elpa] externals/svg-lib 38b0bad 03/32: Typo, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib 004ab08 05/32: Better handling of default style + style simplification, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib a5b06a8 09/32: Forgot screenshot, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib 9115bf7 12/32: Fix string/array nil issue on windows, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib e66a2d0 17/32: Merge pull request #3 from chenyanming/fix-windows-string-or-array-nil-error, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib 461c155 06/32: Update with new style, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib e2d2d68 10/32: Better screenshot, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib 952016b 11/32: Fix tasks status, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib ebde091 22/32: Added progress pies, ELPA Syncer, 2021/09/27
- [elpa] externals/svg-lib b67b120 30/32: Cosmetic changes, ELPA Syncer, 2021/09/27