refactor(mu4e): use doom-call-process to check XDG

This is a bit safer than shell-command-to-string, and we also now check
that the command exited successfully, and fall back if not.
This commit is contained in:
TEC 2021-09-15 02:41:02 +08:00
parent 7ab825157f
commit 083c81e44b
No known key found for this signature in database
GPG key ID: 779591AFDB81F06C

View file

@ -53,13 +53,14 @@
(t #'ido-completing-read)) (t #'ido-completing-read))
mu4e-attachment-dir mu4e-attachment-dir
(concat (concat
(if (executable-find "xdg-user-dir") (if-let ((xdg-download-query (and (executable-find "xdg-user-dir")
;; remove trailing newline (doom-call-process "xdg-user-dir" "DOWNLOAD")))
(substring (shell-command-to-string "xdg-user-dir DOWNLOAD") 0 -1) (xdg-download-dir (and (= 0 (car xdg-download-query)) (cdr xdg-download-query))))
xdg-download-dir
(expand-file-name (or (getenv "XDG_DOWNLOAD_DIR") (expand-file-name (or (getenv "XDG_DOWNLOAD_DIR")
"Downloads") "Downloads")
"~")) "~"))
"/") "/") ; a trailing / makes it easier to change directory in `read-file-name'
;; no need to ask ;; no need to ask
mu4e-confirm-quit nil mu4e-confirm-quit nil
mu4e-headers-thread-single-orphan-prefix '("─>" . "─▶") mu4e-headers-thread-single-orphan-prefix '("─>" . "─▶")