diff options
author | Vibhav Pant <vibhavp@gmail.com> | 2017-02-13 17:07:36 +0530 |
---|---|---|
committer | Vibhav Pant <vibhavp@gmail.com> | 2017-02-13 17:07:36 +0530 |
commit | cb410433e069b5bb450193353c3fea8593a643a9 (patch) | |
tree | d2f4269781b4841e5a0c27ec57a5a4fbcec386c0 /lisp/xdg.el | |
parent | e742450427007cdde242c11380dfe32a950fab61 (diff) | |
parent | 4b18ef7ba3dd8aae4f3c3bf931365ef7da883baf (diff) | |
download | emacs-feature/byte-switch.tar.gz |
Merge branch 'master' into feature/byte-switchfeature/byte-switch
Diffstat (limited to 'lisp/xdg.el')
-rw-r--r-- | lisp/xdg.el | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lisp/xdg.el b/lisp/xdg.el index b11e104e2b7..4973065f91a 100644 --- a/lisp/xdg.el +++ b/lisp/xdg.el @@ -109,6 +109,12 @@ file:///foo/bar.jpg" (defvar xdg-user-dirs nil "Alist of directory keys and values.") +(defun xdg--substitute-home-env (str) + (if (file-name-absolute-p str) str + (save-match-data + (and (string-match "^$HOME/" str) + (replace-match "~/" t nil str 0))))) + (defun xdg--user-dirs-parse-line () "Return pair of user-dirs key to directory value in LINE, otherwise nil. This should be called at the beginning of a line." @@ -117,7 +123,7 @@ This should be called at the beginning of a line." (looking-at xdg-line-regexp)) (let ((k (match-string 1)) (v (match-string 2))) - (when (and k v) (cons k v))))) + (when (and k v) (cons k (xdg--substitute-home-env v)))))) (defun xdg--user-dirs-parse-file (filename) "Return alist of xdg-user-dirs from FILENAME." @@ -137,7 +143,8 @@ This should be called at the beginning of a line." (setq xdg-user-dirs (xdg--user-dirs-parse-file (expand-file-name "user-dirs.dirs" (xdg-config-home))))) - (cdr (assoc name xdg-user-dirs))) + (let ((dir (cdr (assoc name xdg-user-dirs)))) + (when dir (expand-file-name dir)))) (provide 'xdg) |