Fix permission-error on +pretty-code/install-patched-font #2807

This commit is contained in:
Henrik Lissner 2020-04-02 05:10:42 -04:00
parent 74f64c63f0
commit a8f34f0f81
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -59,17 +59,17 @@ 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 (or prefix
(yes-or-no-p (yes-or-no-p
(format "This will download and install the %s fonts, are you (format "This will download and install the %s fonts, are you sure you want to do this?"
sure you want to do this?" name)) name))
(user-error "Aborted")) (user-error "Aborted"))
(let* ((font-dest (let* ((font-dest
(pcase window-system (pcase window-system
(`x (`x
(expand-file-name (expand-file-name
"/fonts/" (or (getenv "XDG_DATA_HOME") "fonts/" (or (getenv "XDG_DATA_HOME")
(concat (getenv "HOME") "/.local/share")))) "~/.local/share")))
((or `mac `ns) ((or `mac `ns)
(expand-file-name "~/Library/Fonts/" )))) (expand-file-name "~/Library/Fonts/"))))
(known-dest? (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)
@ -80,11 +80,10 @@ sure you want to do this?" name))
t)) t))
(when known-dest? (when known-dest?
(message "Font downloaded, updating font cache... <fc-cache -f -v> ") (message "Font downloaded, updating font cache... <fc-cache -f -v> ")
(shell-command-to-string (format "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? "installed" "downloaded")
name name font-dest)))
font-dest)))
;;;###autoload ;;;###autoload
(defun +pretty-code/install-patched-font (font-name &optional prefix) (defun +pretty-code/install-patched-font (font-name &optional prefix)