From 87705c415d6ec3bbf2ed13b844d9c8d1400f1fa4 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 5 Sep 2022 12:50:07 +0200 Subject: use seq-empty-p and string-empty-p calls --- lisp/mastodon-http.el | 2 +- lisp/mastodon-notifications.el | 2 +- lisp/mastodon-profile.el | 4 ++-- lisp/mastodon-search.el | 2 +- lisp/mastodon-tl.el | 20 ++++++++++---------- lisp/mastodon-toot.el | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index af1a9da..086dcec 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -155,7 +155,7 @@ Pass response buffer to CALLBACK function." (buffer-substring-no-properties (point) (point-max)) 'utf-8))) (kill-buffer) - (unless (or (string-equal "" json-string) (null json-string)) + (unless (or (string-empty-p json-string) (null json-string)) (json-read-from-string json-string)))) (defun mastodon-http--delete (url) diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 32cc4ee..c0ca684 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -255,7 +255,7 @@ of the toot responded to." (defun mastodon-notifications--timeline (json) "Format JSON in Emacs buffer." - (if (equal json '[]) + (if (seq-empty-p json) (message "Looks like you have no (more) notifications for the moment.") (mapc #'mastodon-notifications--by-type json) (goto-char (point-min)))) diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 00ffedd..cf27732 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -201,7 +201,7 @@ JSON is the data returned by the server." (mastodon-tl--set-face "[a/r - accept/reject request at point\n n/p - go to next/prev request]\n\n" 'font-lock-comment-face)) - (if (equal json '[]) + (if (seq-empty-p json) (insert (propertize "Looks like you have no follow requests for now." 'face font-lock-comment-face @@ -538,7 +538,7 @@ Also insert their profile note. Used to view a user's followers and those they're following." ;;FIXME change the name of this fun now that we've edited what it does! (let ((inhibit-read-only t)) - (when (not (equal tootv '[])) + (unless (seq-empty-p tootv) (mapc (lambda (toot) (let ((start-pos (point))) (insert "\n" diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index c7658ba..d161544 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -208,7 +208,7 @@ user's profile note. This is also called by (defun mastodon-search--get-user-info (account) "Get user handle, display name, account URL and profile note from ACCOUNT." - (list (if (not (equal "" (alist-get 'display_name account))) + (list (if (not (string-empty-p (alist-get 'display_name account))) (alist-get 'display_name account) (alist-get 'username account)) (alist-get 'acct account) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 4b0bd9f..db8ce20 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -271,7 +271,7 @@ text, i.e. hidden spoiler text." (interactive) (let* ((word (or (word-at-point) "")) (input (read-string (format "Load timeline for tag (%s): " word))) - (tag (if (equal input "") word input))) + (tag (if (string-empty-p input) word input))) (message "Loading timeline for #%s..." tag) (mastodon-tl--show-tag-timeline tag))) @@ -338,7 +338,7 @@ Used on initializing a timeline or thread." "Propertize author of TOOT." (let* ((account (alist-get 'account toot)) (handle (alist-get 'acct account)) - (name (if (not (string= "" (alist-get 'display_name account))) + (name (if (not (string-empty-p (alist-get 'display_name account))) (alist-get 'display_name account) (alist-get 'username account))) (profile-url (alist-get 'url account)) @@ -370,12 +370,12 @@ Used on initializing a timeline or thread." (propertize (concat "@" handle) 'face 'mastodon-handle-face 'mouse-face 'highlight - 'mastodon-tab-stop 'user-handle + 'mastodon-tab-stop 'user-handle 'account account - 'shr-url profile-url - 'keymap mastodon-tl--link-keymap + 'shr-url profile-url + 'keymap mastodon-tl--link-keymap 'mastodon-handle (concat "@" handle) - 'help-echo (concat "Browse user profile of @" handle)) + 'help-echo (concat "Browse user profile of @" handle)) ")"))) (defun mastodon-tl--format-faves-count (toot) @@ -878,7 +878,7 @@ message is a link which unhides/hides the main body." (concat "Media::" preview-url "\n")))) media-attachements ""))) (if (not (and mastodon-tl--display-media-p - (equal media-string ""))) + (string-empty-p media-string))) (concat "\n" media-string) ""))) @@ -1272,7 +1272,7 @@ Prompt for a context, must be a list containting at least one of \"home\", (format "Word(s) to filter (%s): " (or (current-word) "")) nil nil (or (current-word) ""))) (contexts - (if (equal "" word) + (if (string-empty-p word) (error "You must select at least one word for a filter") (completing-read-multiple "Contexts to filter [TAB for options]:" @@ -1316,7 +1316,7 @@ JSON is what is returned by by the server." (mastodon-tl--set-face "[c - create filter\n d - delete filter at point\n n/p - go to next/prev filter]\n\n" 'font-lock-comment-face)) - (if (equal json '[]) + (if (seq-empty-p json) (insert (propertize "Looks like you have no filters for now." 'face font-lock-comment-face @@ -1654,7 +1654,7 @@ NOTIFY is only non-nil when called by `mastodon-tl--follow-user'." (mastodon-profile--lookup-account-in-status user-handle (mastodon-profile--toot-json)))) (user-id (mastodon-profile--account-field account 'id)) - (name (if (not (equal "" (mastodon-profile--account-field account 'display_name))) + (name (if (not (string-empty-p (mastodon-profile--account-field account 'display_name))) (mastodon-profile--account-field account 'display_name) (mastodon-profile--account-field account 'username))) (url (mastodon-http--api diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7f867fe..4cbc92e 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -415,7 +415,7 @@ NO-REDRAFT means delete toot only." (defun mastodon-toot-set-cw (&optional cw) "Set content warning to CW if it is non-nil." - (unless (equal cw "") + (unless (string-empty-p cw) (setq mastodon-toot--content-warning t) (setq mastodon-toot--content-warning-from-reply-or-redraft cw))) @@ -444,7 +444,7 @@ REPLY-ID, TOOT-VISIBILITY, and TOOT-CW of deleted toot are preseved." (interactive) (let* ((toot (mastodon-toot--remove-docs)) (empty-toot-p (and (not mastodon-toot--media-attachments) - (string= "" (mastodon-tl--clean-tabs-and-nl toot))))) + (string-empty-p (mastodon-tl--clean-tabs-and-nl toot))))) (if empty-toot-p (mastodon-toot--kill) (when (y-or-n-p "Discard draft toot? ") @@ -547,7 +547,7 @@ If media items have been attached and uploaded with (interactive) (let* ((toot (mastodon-toot--remove-docs)) (empty-toot-p (and (not mastodon-toot--media-attachments) - (string= "" (mastodon-tl--clean-tabs-and-nl toot)))) + (string-empty-p (mastodon-tl--clean-tabs-and-nl toot)))) (endpoint (mastodon-http--api "statuses")) (spoiler (when (and (not empty-toot-p) mastodon-toot--content-warning) -- cgit v1.2.3