diff options
author | Holger Dürer <me@hdurer.net> | 2021-11-05 17:57:55 +0100 |
---|---|---|
committer | Holger Dürer <me@hdurer.net> | 2021-11-06 16:15:34 +0100 |
commit | f67114cc6c5c167db7327b6b965839236e0466aa (patch) | |
tree | 592134c4a6f395019c78ed71ad13b4322cf459f2 /lisp/mastodon-toot.el | |
parent | d0bf4f196a9a30ea4e19b0b6fa5f9c5bfaf695b3 (diff) |
Use portable filename component functions.
Apparently one should not rely on "/" being the directory separator
and use the funtions from
https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Name-Components.html#File-Name-Components
instead.
The new version seems strictly better in that it won't create paths
with double slashes when `emojify-emojis-dir` already ends in a slash.
This also refines the test for `emojify-emojis-dir` to actually check
it is an existing directoy and not just an existing file, dir, or
symlink.
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r-- | lisp/mastodon-toot.el | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 9acdb2a..d5f4d78 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -366,23 +366,25 @@ To use the downloaded emoji, run `mastodon-toot--enable-custom-emoji'." (interactive) (let ((custom-emoji (mastodon-http--get-json (mastodon-http--api "custom_emojis"))) - (mastodon-custom-emoji-dir (concat (expand-file-name - emojify-emojis-dir) - "/mastodon-custom-emojis/"))) - (if (not (file-exists-p emojify-emojis-dir)) + (mastodon-custom-emoji-dir (file-name-as-directory + (concat (file-name-as-directory + (expand-file-name + emojify-emojis-dir)) + "mastodon-custom-emojis")))) + (if (not (file-directory-p emojify-emojis-dir)) (message "Looks like you need to set up emojify first.") (progn (unless (file-directory-p mastodon-custom-emoji-dir) (make-directory mastodon-custom-emoji-dir nil)) ; no add parent (mapc (lambda (x) - (url-copy-file (alist-get 'url x) - (concat - mastodon-custom-emoji-dir - (alist-get 'shortcode x) - "." - (file-name-extension (alist-get 'url x))) - t)) - custom-emoji) + (url-copy-file (alist-get 'url x) + (concat + mastodon-custom-emoji-dir + (alist-get 'shortcode x) + "." + (file-name-extension (alist-get 'url x))) + t)) + custom-emoji) (message "Custom emoji for %s downloaded to %s" mastodon-instance-url mastodon-custom-emoji-dir))))) |