parent
c17bf49ea3
commit
07e8032291
1 changed files with 15 additions and 16 deletions
|
@ -57,20 +57,19 @@ If PREFIX is nil, will prompt whether or not to download. NAME is informational
|
||||||
only. URL-FORMAT is a format string that should be a url and have a single %s,
|
only. URL-FORMAT is a format string that should be a url and have a single %s,
|
||||||
which is expanded for each font in FONTS-ALIST. FONTS-ALIST should be the
|
which is expanded for each font in FONTS-ALIST. FONTS-ALIST should be the
|
||||||
filename of each font. It is used as the source and destination filename."
|
filename of each font. It is used as the source and destination filename."
|
||||||
(or prefix
|
(unless (or prefix
|
||||||
(yes-or-no-p
|
(yes-or-no-p
|
||||||
(format "This will download and install the %s fonts, are you sure you want to do this?"
|
(format "This will download and install the %s fonts, continue?"
|
||||||
name))
|
name)))
|
||||||
(user-error "Aborted"))
|
(user-error "Aborted"))
|
||||||
(let* ((font-dest
|
(let* ((font-dest
|
||||||
(pcase window-system
|
(cond (IS-LINUX
|
||||||
(`x
|
(expand-file-name
|
||||||
(expand-file-name
|
"fonts/" (or (getenv "XDG_DATA_HOME")
|
||||||
"fonts/" (or (getenv "XDG_DATA_HOME")
|
"~/.local/share")))
|
||||||
"~/.local/share")))
|
(IS-MAC
|
||||||
((or `mac `ns)
|
(expand-file-name "~/Library/Fonts/"))))
|
||||||
(expand-file-name "~/Library/Fonts/"))))
|
(known-dest-p (stringp font-dest))
|
||||||
(known-dest? (stringp font-dest))
|
|
||||||
(font-dest (or font-dest (read-directory-name "Font installation directory: " "~/"))))
|
(font-dest (or font-dest (read-directory-name "Font installation directory: " "~/"))))
|
||||||
(unless (file-directory-p font-dest)
|
(unless (file-directory-p font-dest)
|
||||||
(mkdir font-dest t))
|
(mkdir font-dest t))
|
||||||
|
@ -78,11 +77,11 @@ filename of each font. It is used as the source and destination filename."
|
||||||
(url-copy-file (format url-format font)
|
(url-copy-file (format url-format font)
|
||||||
(expand-file-name font font-dest)
|
(expand-file-name font font-dest)
|
||||||
t))
|
t))
|
||||||
(when known-dest?
|
(when known-dest-p
|
||||||
(message "Font downloaded, updating font cache... <fc-cache -f -v> ")
|
(message "Font downloaded, updating font cache... <fc-cache -f -v> ")
|
||||||
(shell-command-to-string "fc-cache -f -v"))
|
(shell-command-to-string "fc-cache -f -v"))
|
||||||
(message "Successfully %s `%s' fonts to `%s'!%s"
|
(message "Successfully %s `%s' fonts to `%s'!%s"
|
||||||
(if known-dest? "installed" "downloaded")
|
(if known-dest-p "installed" "downloaded")
|
||||||
name font-dest)))
|
name font-dest)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
@ -95,5 +94,5 @@ When PREFIX is non-nil, ignore the prompt and just install it."
|
||||||
(mapcar #'car +pretty-code-font-alist))))
|
(mapcar #'car +pretty-code-font-alist))))
|
||||||
(if-let (font-files (cdr (assoc font-name +pretty-code-font-alist)))
|
(if-let (font-files (cdr (assoc font-name +pretty-code-font-alist)))
|
||||||
(cl-destructuring-bind (&key url files) font-files
|
(cl-destructuring-bind (&key url files) font-files
|
||||||
(+pretty-code--install-font prefix font-name url font-files))
|
(+pretty-code--install-font prefix font-name url files))
|
||||||
(user-error "%S is not a valid font")))
|
(user-error "%S is not a valid font")))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue