aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-profile.el14
-rw-r--r--lisp/mastodon-tl.el47
-rw-r--r--lisp/mastodon-toot.el2
-rw-r--r--lisp/mastodon-views.el60
4 files changed, 61 insertions, 62 deletions
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 0a17a25..093e0a8 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -127,7 +127,7 @@ It contains details of the current user's account.")
"Keymap for `mastodon-profile-update-mode'.")
(persist-defvar mastodon-profile-account-settings nil
- "An alist of account settings saved from the server.
+ "An alist of account settings saved from the server.
Other clients can change these settings on the server at any
time, so this list is not the canonical source for settings. It
is updated on entering mastodon mode and on toggle any setting it
@@ -319,13 +319,13 @@ If value is :json-false, return nil."
(defun mastodon-profile--update-note-count (&rest _args)
"Display the character count of the profile note buffer."
(let* ((inhibit-read-only t)
- (header-region (mastodon-tl--find-property-range 'note-header
+ (header-region (mastodon-tl--find-property-range 'note-header
+ (point-min)))
+ (count-region (mastodon-tl--find-property-range 'note-counter
(point-min)))
- (count-region (mastodon-tl--find-property-range 'note-counter
- (point-min)))
- (count (number-to-string (mastodon-toot--count-toot-chars
- (buffer-substring-no-properties
- (cdr header-region) (point-max))))))
+ (count (number-to-string (mastodon-toot--count-toot-chars
+ (buffer-substring-no-properties
+ (cdr header-region) (point-max))))))
(add-text-properties (car count-region) (cdr count-region)
(list 'display count))))
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index a4d6ec0..0d5d8a9 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -971,16 +971,20 @@ this should be of the form <at-sign><user id>, e.g. \"@Gargon\"."
buffer-text ; no instance suffix for local mention
(concat buffer-text "@" host)))))
-(defun mastodon-tl--hashtag-from-url (url _instance-url)
+(defun mastodon-tl--hashtag-from-url (url instance-url)
"Return the hashtag that URL points to or nil if URL is not a tag link.
INSTANCE-URL is the url of the instance for the toot that the link
came from (tag links always point to a page on the instance publishing
the toot)."
- ;; FIXME: do we rly need to check it against instance-url?
- (let* ((parsed (url-generic-parse-url url))
+ ;; TODO: do we rly need to check it against instance-url?
+ ;; test suggests we might
+ (let* ((instance-host (url-host
+ (url-generic-parse-url instance-url)))
+ (parsed (url-generic-parse-url url))
(path (url-filename parsed))
(split (string-split path "/")))
- (when (string-prefix-p "/tag" path) ;; "/tag/" or "/tags/"
+ (when (and (string= instance-host (url-host parsed))
+ (string-prefix-p "/tag" path)) ;; "/tag/" or "/tags/"
(nth 2 split))))
@@ -1237,12 +1241,12 @@ SENSITIVE is a flag from the item's JSON data."
(if (eq 'hidden (mastodon-tl--property 'sensitive-state :no-move))
;; display:
`( display ,data
- sensitive-state showing))
- ;; hide:
- `( sensitive-state hidden
- display
- ,(create-image
- mastodon-media--sensitive-image-data nil t))))))
+ sensitive-state showing)
+ ;; hide:
+ `( sensitive-state hidden
+ display
+ ,(create-image
+ mastodon-media--sensitive-image-data nil t)))))))
;; POLLS
@@ -1363,19 +1367,18 @@ OPTIONS is an alist."
(defun mastodon-tl--read-poll-option ()
"Read a poll option to vote on a poll."
(let* ((toot (mastodon-tl--property 'item-json))
- (poll (mastodon-tl--field 'poll toot))
- (options (mastodon-tl--field 'options poll))
- (titles (mastodon-tl--map-alist 'title options))
- (number-seq (number-sequence 1 (length options)))
- (numbers (mapcar #'number-to-string number-seq))
- (options-alist (cl-mapcar #'cons numbers titles))
-
- (candidates (mastodon-tl--format-read-poll-option options-alist))
- (choice (completing-read "Poll option to vote for: "
- candidates nil :match)))
+ (poll (mastodon-tl--field 'poll toot)))
(if (null poll)
(user-error "No poll here")
- (list (cdr (assoc choice candidates))))))
+ (let* ((options (mastodon-tl--field 'options poll))
+ (titles (mastodon-tl--map-alist 'title options))
+ (number-seq (number-sequence 1 (length options)))
+ (numbers (mapcar #'number-to-string number-seq))
+ (options-alist (cl-mapcar #'cons numbers titles))
+ (candidates (mastodon-tl--format-read-poll-option options-alist))
+ (choice (completing-read "Poll option to vote for: "
+ candidates nil :match)))
+ (list (cdr (assoc choice candidates)))))))
(defun mastodon-tl--poll-vote (option)
"If there is a poll at point, prompt user for OPTION to vote on it."
@@ -2397,7 +2400,7 @@ LANGS is the accumulated array param alist if we re-run recursively."
(car user-handles)
(completing-read (cond ((or ; TODO: make this "enable/disable notifications"
(equal action "disable")
- (equal action "enable"))
+ (equal action "enable"))
(format "%s notifications when user posts: " action))
((string-suffix-p "boosts" action)
(format "%s by user: " action))
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 7c5472b..5f4116f 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -225,7 +225,7 @@ Takes its form from `window-configuration-to-register'.")
"The text of the toot being composed.")
(persist-defvar mastodon-toot-draft-toots-list nil
- "A list of toots that have been saved as drafts.
+ "A list of toots that have been saved as drafts.
For the moment we just put all composed toots in here, as we want
to also capture toots that are \"sent\" but that don't successfully
send.")
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 1ddb769..9b40541 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -513,7 +513,7 @@ JSON is the data returned by the server."
'item-type 'scheduled ; so we nav here
'face 'font-lock-comment-face
'keymap mastodon-views--scheduled-map
- 'scheduled-json toot
+ 'item-json toot
'id .id)
"\n")))
@@ -529,10 +529,8 @@ If ID, just return that toot."
(defun mastodon-views--reschedule-toot ()
"Reschedule the scheduled toot at point."
(interactive)
- (let ((id (mastodon-tl--property 'id :no-move)))
- (if (null id)
- (user-error "no scheduled toot at point?")
- (mastodon-toot--schedule-toot :reschedule))))
+ (mastodon-tl--do-if-item
+ (mastodon-toot--schedule-toot :reschedule)))
(defun mastodon-views--copy-scheduled-toot-text ()
"Copy the text of the scheduled toot at point."
@@ -547,36 +545,34 @@ If ID, just return that toot."
ID is that of the scheduled toot to cancel.
NO-CONFIRM means there is no ask or message, there is only do."
(interactive)
- (let ((id (or id (mastodon-tl--property 'id :no-move))))
- (if (null id)
- (user-error "no scheduled toot at point?")
- (when (or no-confirm
- (y-or-n-p "Cancel scheduled toot?"))
- (let* ((url (mastodon-http--api (format "scheduled_statuses/%s" id)))
- (response (mastodon-http--delete url)))
- (mastodon-http--triage response
- (lambda (_)
- (mastodon-views--view-scheduled-toots)
- (unless no-confirm
- (message "Toot cancelled!")))))))))
+ (mastodon-tl--do-if-item
+ (when (or no-confirm
+ (y-or-n-p "Cancel scheduled toot?"))
+ (let* ((id (or id (mastodon-tl--property 'id :no-move)))
+ (url (mastodon-http--api (format "scheduled_statuses/%s" id)))
+ (response (mastodon-http--delete url)))
+ (mastodon-http--triage response
+ (lambda (_)
+ (mastodon-views--view-scheduled-toots)
+ (unless no-confirm
+ (message "Toot cancelled!"))))))))
(defun mastodon-views--edit-scheduled-as-new ()
"Edit scheduled status as new toot."
(interactive)
- (let ((id (mastodon-tl--property 'id :no-move)))
- (if (null id)
- (user-error "no scheduled toot at point?")
- (let* ((toot (mastodon-tl--property 'scheduled-json :no-move))
- (scheduled (alist-get 'scheduled_at toot)))
- (let-alist (alist-get 'params toot)
- ;; TODO: preserve polls
- ;; (poll (alist-get 'poll params))
- (mastodon-toot--compose-buffer nil .in_reply_to_id nil .text :edit)
- (goto-char (point-max))
- ;; adopt properties from scheduled toot:
- (mastodon-toot--set-toot-properties
- .in_reply_to_id .visibility .spoiler_text .language
- scheduled id (alist-get 'media_attachments toot)))))))
+ (mastodon-tl--do-if-item
+ (let* ((toot (mastodon-tl--property 'scheduled-json :no-move))
+ (id (mastodon-tl--property 'id :no-move))
+ (scheduled (alist-get 'scheduled_at toot)))
+ (let-alist (alist-get 'params toot)
+ ;; TODO: preserve polls
+ ;; (poll (alist-get 'poll params))
+ (mastodon-toot--compose-buffer nil .in_reply_to_id nil .text :edit)
+ (goto-char (point-max))
+ ;; adopt properties from scheduled toot:
+ (mastodon-toot--set-toot-properties
+ .in_reply_to_id .visibility .spoiler_text .language
+ scheduled id (alist-get 'media_attachments toot))))))
;;; FILTERS
@@ -755,7 +751,7 @@ MISSKEY means the instance is a Misskey or derived server."
(mastodon-tl--do-if-item
(let* ((toot (or (and (mastodon-tl--profile-buffer-p)
(mastodon-tl--property 'profile-json)) ; either profile
- (mastodon-tl--property 'item-json)) ; or toot or user listing
+ (mastodon-tl--property 'item-json))) ; or toot or user listing
(reblog (alist-get 'reblog toot))
(account (or (alist-get 'account reblog)
(alist-get 'account toot)