diff options
author | marty hiatt <martianhiatus@riseup.net> | 2024-05-21 13:02:20 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus@riseup.net> | 2024-05-21 13:02:20 +0200 |
commit | 18e44cd82313952d35be7d8b8c5ca86a885d4703 (patch) | |
tree | 1c6bf2829dd23cba54f4e2b831b6edfc9d8c78cf | |
parent | d54aa9aa3e4276b9519ff9123e9dc0c123d9dd3b (diff) | |
parent | e6bdc008ed3f66fd5c6903c491e1cf6d4dafd2f3 (diff) |
Merge branch 'develop'
-rw-r--r-- | lisp/mastodon-auth.el | 30 | ||||
-rw-r--r-- | lisp/mastodon-media.el | 1 | ||||
-rw-r--r-- | lisp/mastodon-profile.el | 31 | ||||
-rw-r--r-- | lisp/mastodon-tl.el | 10 | ||||
-rw-r--r-- | lisp/mastodon-toot.el | 9 | ||||
-rw-r--r-- | lisp/mastodon.el | 2 |
6 files changed, 58 insertions, 25 deletions
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index 9f9d128..404dd57 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -112,18 +112,24 @@ When optional argument ASK is given which should be a string, use ASK as the minibuffer prompt. Return whatever user types in response to the prompt. When ASK is absent return nil." - (if ask - (read-string ask) - (let ((buffer (get-buffer-create buffer-name)) - (inhibit-read-only t)) - (set-buffer buffer) - (erase-buffer) - (insert notice) - (fill-region (point-min) (point-max)) - (read-only-mode) - (prog1 nil - (pop-to-buffer buffer '(display-buffer-in-side-window - (side . left) (window-width . 0.5))))))) + (let ((buffer (get-buffer-create buffer-name)) + (inhibit-read-only t) + ask-value window) + (set-buffer buffer) + (erase-buffer) + (insert notice) + (fill-region (point-min) (point-max)) + (read-only-mode) + + (setq window (select-window + (split-window (frame-root-window) nil 'below) + t)) + (switch-to-buffer buffer t) + (when ask + (setq ask-value (read-string ask)) + (kill-buffer buffer) + (delete-window window)) + ask-value)) (defun mastodon-auth--request-authorization-code () "Ask authorization code and return it." diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index bc902aa..3f6d0df 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -35,6 +35,7 @@ ;;; Code: (require 'url-cache) (require 'mm-decode) +(require 'image-mode) (autoload 'mastodon-tl--propertize-img-str-or-url "mastodon-tl") diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 7b5a700..fc318e2 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -37,6 +37,7 @@ (require 'cl-lib) (require 'persist) (require 'parse-time) +(require 'mastodon-http) (eval-when-compile (require 'mastodon-tl)) @@ -141,11 +142,12 @@ contains") (mastodon-tl--property 'item-json)) (defun mastodon-profile--make-author-buffer - (account &optional no-reblogs no-replies) + (account &optional no-reblogs no-replies only-media) "Take an ACCOUNT json and insert a user account into a new buffer. NO-REBLOGS means do not display boosts in statuses." (mastodon-profile--make-profile-buffer-for - account "statuses" #'mastodon-tl--timeline no-reblogs nil no-replies)) + account "statuses" #'mastodon-tl--timeline no-reblogs nil + no-replies only-media)) ;; TODO: we shd just load all views' data then switch coz this is slow af: (defun mastodon-profile--account-view-cycle () @@ -156,6 +158,8 @@ NO-REBLOGS means do not display boosts in statuses." ((mastodon-tl--buffer-type-eq 'profile-statuses-no-boosts) (mastodon-profile--open-statuses-no-replies)) ((mastodon-tl--buffer-type-eq 'profile-statuses-no-replies) + (mastodon-profile--open-statuses-only-media)) + ((mastodon-tl--buffer-type-eq 'profile-statuses-only-media) (mastodon-profile--open-followers)) ((mastodon-tl--buffer-type-eq 'profile-followers) (mastodon-profile--open-following)) @@ -178,6 +182,14 @@ NO-REBLOGS means do not display boosts in statuses." mastodon-profile--account :no-reblogs) (user-error "Not in a mastodon profile"))) +(defun mastodon-profile--open-statuses-only-media () + "Open a profile buffer showing only statuses with media." + (interactive) + (if mastodon-profile--account + (mastodon-profile--make-author-buffer + mastodon-profile--account nil nil :only-media) + (user-error "Not in a mastodon profile"))) + (defun mastodon-profile--open-following () "Open a profile buffer showing the accounts that current profile follows." (interactive) @@ -566,7 +578,7 @@ FIELDS means provide a fields vector fetched by other means." (defun mastodon-profile--make-profile-buffer-for (account endpoint-type update-function - &optional no-reblogs headers no-replies) + &optional no-reblogs headers no-replies only-media) "Display profile of ACCOUNT, using ENDPOINT-TYPE and UPDATE-FUNCTION. NO-REBLOGS means do not display boosts in statuses. HEADERS means also fetch link headers for pagination." @@ -576,17 +588,18 @@ HEADERS means also fetch link headers for pagination." (push '("exclude_reblogs" . "t") args)) (no-replies (push '("exclude_replies" . "t") args)) + (only-media + (push '("only_media" . "t") args)) (t args))) (endpoint (format "accounts/%s/%s" .id endpoint-type)) (url (mastodon-http--api endpoint)) (buffer (concat "*mastodon-" .acct "-" - (cond (no-reblogs - (concat endpoint-type "-no-boosts")) - (no-replies - (concat endpoint-type "-no-replies")) - (t - endpoint-type)) + (concat endpoint-type + (cond (no-reblogs "-no-boosts") + (no-replies "-no-replies") + (only-media "-only-media") + (t ""))) "*")) (response (if headers (mastodon-http--get-response url args) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 4c0375d..6c444d4 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1434,7 +1434,8 @@ THREAD means the status will be displayed in a thread view." (reply-to-id (alist-get 'in_reply_to_id toot)) (after-reply-status-p (when (and thread reply-to-id) - (mastodon-tl--after-reply-status reply-to-id)))) + (mastodon-tl--after-reply-status reply-to-id))) + (type (alist-get 'type toot))) (insert (propertize (concat @@ -1461,7 +1462,8 @@ THREAD means the status will be displayed in a thread view." toot)) ; else normal toot with reblog check 'item-json toot 'base-toot base-toot - 'cursor-face 'mastodon-cursor-highlight-face) + 'cursor-face 'mastodon-cursor-highlight-face + 'notification-type type) "\n") (when mastodon-tl--display-media-p (mastodon-media--inline-images start-pos (point))))) @@ -1675,6 +1677,8 @@ call this function after it is set or use something else." 'profile-statuses-no-boosts) ((string-suffix-p "no-replies*" buffer-name) 'profile-statuses-no-replies) + ((string-suffix-p "only-media*" buffer-name) + 'profile-statuses-only-media) ((mastodon-tl--endpoint-str-= "statuses" :suffix) 'profile-statuses) ;; profile followers @@ -1803,6 +1807,8 @@ Move forward (down) the timeline unless NO-MOVE is non-nil. BACKWARD means move backward (up) the timeline." (if no-move (get-text-property (point) prop) + ;; NB: this doesn't differentiate absence of property from + ;; property set to zero, making flag props fraught: (or (get-text-property (point) prop) (save-excursion (if backward diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index a48d5d9..aff201d 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -459,7 +459,14 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement." (interactive) (mastodon-tl--do-if-item-strict (let* ((id (mastodon-tl--property 'base-item-id)) - (bookmarked-p (mastodon-tl--property 'bookmarked-p)) + (bookmarked-p + (mastodon-tl--property + 'bookmarked-p + (if (mastodon-tl--property 'byline :no-move) + ;; no move if not in byline, the idea being if in body, we do + ;; move forward to byline to toggle correctly. + ;; alternatively we could bookmarked-p whole posts. + :no-move))) (byline-region (when id (mastodon-tl--find-property-range 'byline (point)))) (action (if bookmarked-p "unbookmark" "bookmark")) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 70ab73c..1d071f7 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -370,8 +370,8 @@ If a status or account is found, load it in `mastodon.el', if not, just browse the URL in the normal fashion." (interactive) (let* ((query (or query-url - (thing-at-point-url-at-point) (mastodon-tl--property 'shr-url :no-move) + (thing-at-point-url-at-point) (read-string "Lookup URL: ")))) (if (and (not force) (not (mastodon--fedi-url-p query))) |