aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Dürer <me@hdurer.net>2021-11-05 18:33:16 +0100
committerHolger Dürer <me@hdurer.net>2021-11-06 16:15:34 +0100
commit65f80fd810793638beb6f146b25919bca5c21cfc (patch)
tree6489b585e2f9bdd69b9febfb4bf737d8b96356ff
parentf67114cc6c5c167db7327b6b965839236e0466aa (diff)
Do a bit if `if` and `progn` sanitizing.
- A `progn` with a single form is redundant - `when` doesn't need a `progn` body - `if` has an implicit `progn` for the consequences - I converted one cascade of `if`s into a `cond`.
-rw-r--r--lisp/mastodon-async.el7
-rw-r--r--lisp/mastodon-auth.el1
-rw-r--r--lisp/mastodon-http.el24
-rw-r--r--lisp/mastodon-profile.el11
-rw-r--r--lisp/mastodon-toot.el29
5 files changed, 34 insertions, 38 deletions
diff --git a/lisp/mastodon-async.el b/lisp/mastodon-async.el
index 1fee9ef..524e13d 100644
--- a/lisp/mastodon-async.el
+++ b/lisp/mastodon-async.el
@@ -205,9 +205,10 @@ ENPOINT is the endpoint for the stream and timeline."
mastodon-instance-url "*"))
;; if user stream, we need "timelines/home" not "timelines/user"
;; if notifs, we need "notifications" not "timelines/notifications"
- (endpoint (if (equal name "notifications") "notifications"
- (if (equal name "home") "timelines/home"
- (format "timelines/%s" endpoint)))))
+ (endpoint (cond
+ ((equal name "notifications") "notifications")
+ ((equal name "home") "timelines/home")
+ (t (format "timelines/%s" endpoint)))))
(mastodon-async--set-local-variables buffer-name http-buffer
buffer-name queue-name)
;; Similar to timeline init.
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el
index e5767f1..8d0d7c6 100644
--- a/lisp/mastodon-auth.el
+++ b/lisp/mastodon-auth.el
@@ -136,7 +136,6 @@ Otherwise, generate a token and pass it to
`mastodon-auth--handle-token-reponse'."
(if-let ((token (cdr (assoc mastodon-instance-url mastodon-auth--token-alist))))
token
-
(mastodon-auth--handle-token-response (mastodon-auth--get-token))))
(defun mastodon-auth--handle-token-response (response)
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index a45b4ed..1ec0dc0 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -85,10 +85,9 @@ Message status and JSON error from RESPONSE if unsuccessful."
(mastodon-http--status))))
(if (string-prefix-p "2" status)
(funcall success)
- (progn
- (switch-to-buffer response)
- (let ((json-response (mastodon-http--process-json)))
- (message "Error %s: %s" status (alist-get 'error json-response)))))))
+ (switch-to-buffer response)
+ (let ((json-response (mastodon-http--process-json)))
+ (message "Error %s: %s" status (alist-get 'error json-response))))))
(defun mastodon-http--read-file-as-string (filename)
"Read a file FILENAME as a string. Used to generate image preview."
@@ -266,15 +265,14 @@ item uploaded, and `mastodon-toot--update-status-fields' is run."
:success (cl-function
(lambda (&key data &allow-other-keys)
(when data
- (progn
- (push (alist-get 'id data)
- mastodon-toot--media-attachment-ids) ; add ID to list
- (message "%s file %s with id %S and caption '%s' uploaded!"
- (capitalize (alist-get 'type data))
- file
- (alist-get 'id data)
- (alist-get 'description data))
- (mastodon-toot--update-status-fields)))))
+ (push (alist-get 'id data)
+ mastodon-toot--media-attachment-ids) ; add ID to list
+ (message "%s file %s with id %S and caption '%s' uploaded!"
+ (capitalize (alist-get 'type data))
+ file
+ (alist-get 'id data)
+ (alist-get 'description data))
+ (mastodon-toot--update-status-fields))))
:error (cl-function
(lambda (&key error-thrown &allow-other-keys)
(cond
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index c4bec38..81ab837 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -349,12 +349,11 @@ Returns a list of lists."
(mastodon-tl--render-text note account)
;; account here to enable tab-stops in profile note
(if fields
- (progn
- (concat "\n"
- (mastodon-tl--set-face
- (mastodon-profile--fields-insert fields)
- 'success)
- "\n"))
+ (concat "\n"
+ (mastodon-tl--set-face
+ (mastodon-profile--fields-insert fields)
+ 'success)
+ "\n")
"")
;; insert counts
(mastodon-tl--set-face
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index d5f4d78..885db1d 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -373,21 +373,20 @@ To use the downloaded emoji, run `mastodon-toot--enable-custom-emoji'."
"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)
- (message "Custom emoji for %s downloaded to %s"
- mastodon-instance-url
- mastodon-custom-emoji-dir)))))
+ (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)
+ (message "Custom emoji for %s downloaded to %s"
+ mastodon-instance-url
+ mastodon-custom-emoji-dir))))
(defun mastodon-toot--collect-custom-emoji ()
"Return a list of `mastodon-instance-url's custom emoji.