From 47eaa7a194fa38bc39c45fbd5e3f86a01d78755f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 30 Dec 2022 10:23:43 +1100 Subject: docstrings --- lisp/mastodon-toot.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index c18f751..3406ec4 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -844,8 +844,8 @@ Buffer-local variable `mastodon-toot-previous-window-config' holds the config." (goto-char (cadr config))) (defun mastodon-toot--mentions-to-string (mentions) - "Applies mastodon-toot--process-local function to each mention, -removes empty string (self) from result and joins the sequence with whitespace \" \"." + "Apply `mastodon-toot--process-local' function to each mention in MENTIONS. +Remove empty string (self) from result and joins the sequence with whitespace." (mapconcat (lambda(mention) mention) (remove "" (mapcar (lambda(x) (mastodon-toot--process-local x)) mentions)) -- cgit v1.2.3 From baa5ae92733ce95ea5036ca6b18575ebfa80af9b Mon Sep 17 00:00:00 2001 From: Moha Date: Sat, 31 Dec 2022 18:02:44 +0100 Subject: Add option to set the default reply visibility This change introduces a new option `mastodon-toot-default-reply-visibility`. The default is set to "Public". Replies will be defaulted to the value of this parameter unless the original toot has a more restrictive visiblity. For example: with `mastodon-toot--default-reply-visibility` set to "unlisted" - Original post visibility: public - Reply default visibility: unlinsted - Original post visbility: private (only-followers) - Repy default visibility: private --- README.org | 3 +++ lisp/mastodon-toot.el | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-toot.el') diff --git a/README.org b/README.org index 85ff179..35ebb99 100644 --- a/README.org +++ b/README.org @@ -263,6 +263,9 @@ work without first loading =mastodon.el=: - =mastodon-profile--account-sensitive-toggle=: Toggle whether your posts are marked as sensitive (nsfw) by default. +- =mastodon-toot--default-reply-visibility=: Set the default visibility for replies. + This visibility is used only when the original post has less restrictive visibility. + *** Customization See =M-x customize-group RET mastodon= to view all customize options. diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index c18f751..9e8a2cc 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -140,6 +140,16 @@ You need to install company yourself to use this." :group 'mastodon-toot :type 'integer) +(defcustom mastodon-toot--default-reply-visibility "public" + "Default visibility settings when replying. +If the original toot visibility is different we use the more restricted one." + :group 'mastodon-toot + :type '(choice + (const :tag "public" "public") + (const :tag "unlisted" "unlisted") + (const :tag "followers only" "private") + (const :tag "direct" "direct"))) + (defcustom mastodon-toot--enable-custom-instance-emoji nil "Whether to enable your instance's custom emoji by default." :group 'mastodon-toot @@ -1348,11 +1358,23 @@ REPLY-TEXT is the text of the toot being replied to." 'read-only "Edit your message below." 'toot-post-header t)))) +(defun mastodon-toot--most-restrictive-visibility (reply-visibility) + "Return REPLY-VISIBILITY or default visibility, whichever is more restrictive. +The default is given by `mastodon-toot--default-reply-visibility'." + (unless (null reply-visibility) + (let ((less-restrictive (member (intern mastodon-toot--default-reply-visibility) + mastodon-toot-visibility-list))) + (insert (format "%s" reply-visibility)) + (if (member (intern reply-visibility) less-restrictive) + mastodon-toot--default-reply-visibility reply-visibility)))) + (defun mastodon-toot--setup-as-reply (reply-to-user reply-to-id reply-json) "If REPLY-TO-USER is provided, inject their handle into the message. If REPLY-TO-ID is provided, set `mastodon-toot--reply-to-id'. REPLY-JSON is the full JSON of the toot being replied to." - (let ((reply-visibility (alist-get 'visibility reply-json)) + (let ((reply-visibility + (mastodon-toot--most-restrictive-visibility + (alist-get 'visibility reply-json))) (reply-cw (alist-get 'spoiler_text reply-json))) (when reply-to-user (insert (format "%s " reply-to-user)) -- cgit v1.2.3 From 77bc927b3dbb7c97463815b5e03084cf47c57adf Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 7 Jan 2023 09:44:14 +1100 Subject: tl--action-success: only move point if it was on byline FIX #326 --- lisp/mastodon-toot.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 3406ec4..56ad4ed 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -285,7 +285,8 @@ modified. Remove MARKER if REMOVE is non-nil, otherwise add it." (let ((inhibit-read-only t) (bol (car byline-region)) - (eol (cdr byline-region))) + (eol (cdr byline-region)) + (at-byline-p (eq (get-text-property (point) 'byline) t))) (save-excursion (when remove (goto-char bol) @@ -297,9 +298,10 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." (goto-char bol) (insert (format "(%s) " (propertize marker 'face 'success))))) + (when at-byline-p ;; leave point after the marker: - (unless remove - (mastodon-tl--goto-next-toot)))) + (unless remove + (mastodon-tl--goto-next-toot))))) (defun mastodon-toot--action (action callback) "Take ACTION on toot at point, then execute CALLBACK. -- cgit v1.2.3 From 5d1e5edd0709a70c81a9fc846ff3292a9a270544 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 9 Jan 2023 16:06:20 +1100 Subject: remove first empty line in docstrings --- lisp/mastodon-async.el | 6 ------ lisp/mastodon-http.el | 3 --- lisp/mastodon-media.el | 8 ++------ lisp/mastodon-notifications.el | 1 - lisp/mastodon-search.el | 2 -- lisp/mastodon-tl.el | 31 ++----------------------------- lisp/mastodon-toot.el | 6 +----- lisp/mastodon.el | 4 ---- 8 files changed, 5 insertions(+), 56 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-async.el b/lisp/mastodon-async.el index 58e7b93..a352ffc 100644 --- a/lisp/mastodon-async.el +++ b/lisp/mastodon-async.el @@ -131,7 +131,6 @@ (defun mastodon-async--mastodon (endpoint timeline name filter) "Make sure that the previous async process has been closed. - Then start an async stream at ENDPOINT filtering toots using FILTER. TIMELINE is a specific target, such as federated or home. @@ -157,7 +156,6 @@ NAME is the center portion of the buffer name for (defun mastodon-async--set-http-buffer (buffer http-buffer) "Initialize for BUFFER a local variable `mastodon-async--http-buffer'. - HTTP-BUFFER is the initializing value. Use this funcion if HTTP-BUFFER is not known when `mastodon-async--setup-buffer' is called." (with-current-buffer (get-buffer-create buffer) @@ -178,7 +176,6 @@ is not known when `mastodon-async--setup-buffer' is called." (defun mastodon-async--setup-http (http-buffer name) "Add local variables to HTTP-BUFFER. - NAME is used to generate the display buffer and the queue." (let ((queue-name (concat " *mastodon-async-queue-" name "-" mastodon-instance-url "*")) @@ -200,7 +197,6 @@ NAME is used to generate the display buffer and the queue." (defun mastodon-async--setup-buffer (http-buffer name endpoint) "Set up the buffer timeline like `mastodon-tl--init'. - HTTP-BUFFER the name of the http-buffer, if unknown, set to... NAME is the name of the stream for the buffer name. ENDPOINT is the endpoint for the stream and timeline." @@ -334,7 +330,6 @@ NAME is used for the queue and display buffer." (defun mastodon-async--cycle-queue (string) "Append the most recent STRING from http buffer to queue buffer. - Then determine if a full message has been recived. If so return it. Full messages are seperated by two newlines" (with-current-buffer mastodon-async--queue @@ -350,7 +345,6 @@ Full messages are seperated by two newlines" (defun mastodon-async--http-layer (proc data) "Passes PROC and DATA to ‘url-http-generic-filter’. - It then processes its output." (with-current-buffer (process-buffer proc) (let ((start (max 1 (- (point-max) 2)))) diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 9ef7aec..3cc5511 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -73,7 +73,6 @@ (defun mastodon-http--url-retrieve-synchronously (url &optional silent) "Retrieve URL asynchronously. - This is a thin abstraction over the system `url-retrieve-synchronously'. Depending on which version of this is available we will call it with or without a timeout. @@ -84,7 +83,6 @@ SILENT means don't message." (defun mastodon-http--triage (response success) "Determine if RESPONSE was successful. Call SUCCESS if successful. - Message status and JSON error from RESPONSE if unsuccessful." (let ((status (with-current-buffer response (mastodon-http--status)))) @@ -136,7 +134,6 @@ Used for API form data parameters that take an array." (defun mastodon-http--post (url &optional params headers unauthenticated-p) "POST synchronously to URL, optionally with PARAMS and HEADERS. - Authorization header is included by default unless UNAUTHENTICATED-P is non-nil." (mastodon-http--authorized-request "POST" diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index 4e50dbc..3fb10b0 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -144,7 +144,6 @@ fKRJkmVZjAQwh78A6vCRWJE8K+8AAAAASUVORK5CYII=") (defun mastodon-media--process-image-response (status-plist marker image-options region-length url) "Callback function processing the url retrieve response for URL. - STATUS-PLIST is the usual plist of status events as per `url-retrieve'. IMAGE-OPTIONS are the precomputed options to apply to the image. MARKER is the marker to where the response should be visible. @@ -186,7 +185,6 @@ with the image." (defun mastodon-media--load-image-from-url (url media-type start region-length) "Take a URL and MEDIA-TYPE and load the image asynchronously. - MEDIA-TYPE is a symbol and either 'avatar or 'media-link. START is the position where we start loading the image. REGION-LENGTH is the range from start to propertize." @@ -199,8 +197,8 @@ REGION-LENGTH is the range from start to propertize." `(:max-height ,mastodon-media--preview-max-height)))))) (let ((buffer (current-buffer)) (marker (copy-marker start)) - ;; Keep url.el from spamming us with messages about connecting to hosts: - (url-show-status nil)) + ;; Keep url.el from spamming us with messages about connecting to hosts: + (url-show-status nil)) (condition-case nil ;; catch any errors in url-retrieve so as to not abort ;; whatever called us @@ -226,7 +224,6 @@ REGION-LENGTH is the range from start to propertize." (defun mastodon-media--select-next-media-line (end-pos) "Find coordinates of the next media to load before END-POS. - Returns the list of (`start' . `end', `media-symbol') points of that line and string found or nil no more media links were found." @@ -249,7 +246,6 @@ found." (defun mastodon-media--valid-link-p (link) "Check if LINK is valid. - Checks to make sure the missing string has not been returned." (and link (> (length link) 8) diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index b7fe038..a36b99e 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -244,7 +244,6 @@ Status notifications are given when author-byline action-byline id &optional base-toot) "Display the content and byline of timeline element TOOT. - BODY will form the section of the toot above the byline. AUTHOR-BYLINE is an optional function for adding the author diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 1aed676..24ddfb3 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -230,13 +230,11 @@ user's profile note. This is also called by (defun mastodon-search--get-id-from-status (status) "Fetch the id from a STATUS returned by a search call to the server. - We use this to fetch the complete status from the server." (alist-get 'id status)) (defun mastodon-search--fetch-full-status-from-id (id) "Fetch the full status with id ID from the server. - This allows us to access the full account etc. details and to render them properly." (let* ((url (concat mastodon-instance-url "/api/v1/statuses/" (mastodon-tl--as-string id))) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 9f21bf9..0d93b8d 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -103,7 +103,6 @@ (defcustom mastodon-tl--enable-relative-timestamps t "Whether to show relative (to the current time) timestamps. - This will require periodic updates of a timeline buffer to keep the timestamps current as time progresses." :group 'mastodon-tl @@ -111,7 +110,6 @@ keep the timestamps current as time progresses." (defcustom mastodon-tl--enable-proportional-fonts nil "Nonnil to enable using proportional fonts when rendering HTML. - By default fixed width fonts are used." :group 'mastodon-tl :type '(boolean :tag "Enable using proportional rather than fixed \ @@ -161,7 +159,6 @@ Valid values are: (defvar-local mastodon-tl--update-point nil "When updating a mastodon buffer this is where new toots will be inserted. - If nil `(point-min)' is used instead.") (defvar-local mastodon-tl--after-update-marker nil @@ -185,7 +182,6 @@ If nil `(point-min)' is used instead.") (define-key map [follow-link] 'mouse-face) (keymap-canonicalize map)) "The keymap for link-like things in buffer (except for shr.el generate links). - This will make the region of text act like like a link with mouse highlighting, mouse click action tabbing to next/previous link etc.") @@ -201,7 +197,6 @@ etc.") (define-key map [remap shr-browse-url] 'mastodon-url-lookup) (keymap-canonicalize map)) "The keymap to be set for shr.el generated links that are not images. - We need to override the keymap so tabbing will navigate to all types of mastodon links and not just shr.el-generated ones.") @@ -224,7 +219,6 @@ types of mastodon links and not just shr.el-generated ones.") (define-key map (kbd "") 'mastodon-tl--mpv-play-video-at-point) (keymap-canonicalize map)) "The keymap to be set for shr.el generated image links. - We need to override the keymap so tabbing will navigate to all types of mastodon links and not just shr.el-generated ones.") @@ -305,7 +299,6 @@ NAME is not part of the symbol table, '?' is returned." (defun mastodon-tl--next-tab-item () "Move to the next interesting item. - This could be the next toot, link, or image; whichever comes first. Don't move if nothing else to move to is found, i.e. near the end of the buffer. This also skips tab items in invisible text, i.e. hidden spoiler text." @@ -326,7 +319,6 @@ This also skips tab items in invisible text, i.e. hidden spoiler text." (defun mastodon-tl--previous-tab-item () "Move to the previous interesting item. - This could be the previous toot, link, or image; whichever comes first. Don't move if nothing else to move to is found, i.e. near the start of the buffer. This also skips tab items in invisible @@ -569,14 +561,12 @@ The result is added as an attachments property to author-byline." (defun mastodon-tl--field (field toot) "Return FIELD from TOOT. - Return value from boosted content if available." (or (alist-get field (alist-get 'reblog toot)) (alist-get field toot))) (defun mastodon-tl--relative-time-details (timestamp &optional current-time) "Return cons of (descriptive string . next change) for the TIMESTAMP. - Use the optional CURRENT-TIME as the current time (only used for reliable testing). @@ -631,7 +621,6 @@ TIMESTAMP is assumed to be in the past." (defun mastodon-tl--relative-time-description (timestamp &optional current-time) "Return a string with a human readable TIMESTAMP relative to the current time. - Use the optional CURRENT-TIME as the current time (only used for reliable testing). @@ -641,7 +630,6 @@ TIME-STAMP is assumed to be in the past." (defun mastodon-tl--byline (toot author-byline action-byline &optional detailed-p) "Generate byline for TOOT. - AUTHOR-BYLINE is a function for adding the author portion of the byline that takes one variable. ACTION-BYLINE is a function for adding an action, such as boosting, @@ -784,7 +772,6 @@ LETTER is a string, F for favourited, B for boosted, or K for bookmarked." (defun mastodon-tl--render-text (string &optional toot) "Return a propertized text rendering the given HTML string STRING. - The contents comes from the given TOOT which is used in parsing links in the text. If TOOT is nil no parsing occurs." (when string ; handle rare empty notif server bug @@ -896,7 +883,6 @@ Return nil if no matching element" (defun mastodon-tl--extract-userhandle-from-url (url buffer-text) "Return the user hande the URL points to or nil if it is not a profile link. - BUFFER-TEXT is the text covered by the link with URL, for a user profile this should be of the form , e.g. \"@Gargon\"." (let* ((parsed-url (url-generic-parse-url url)) @@ -912,7 +898,6 @@ this should be of the form , e.g. \"@Gargon\"." (defun mastodon-tl--extract-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)." @@ -963,7 +948,6 @@ the toot)." (defun mastodon-tl--make-link (string link-type) "Return a propertized version of STRING that will act like link. - LINK-TYPE is the type of link to produce." (let ((help-text (cond ((eq link-type 'content-warning) @@ -1020,7 +1004,6 @@ Used for a mouse-click EVENT on a link." (defun mastodon-tl--has-spoiler (toot) "Check if the given TOOT has a spoiler text. - Spoiler text should initially be shown only while the main content should be hidden." (let ((spoiler (mastodon-tl--field 'spoiler_text toot))) @@ -1033,7 +1016,6 @@ content should be hidden." (defun mastodon-tl--spoiler (toot) "Render TOOT with spoiler message. - This assumes TOOT is a toot with a spoiler message. The main body gets hidden and only the spoiler text and the content warning message are displayed. The content warning @@ -1111,7 +1093,6 @@ message is a link which unhides/hides the main body." (defun mastodon-tl--propertize-img-str-or-url (str media-url full-remote-url type help-echo &optional display face) "Propertize an media placeholder string \"[img]\" or media URL. - STR is the string to propertize, MEDIA-URL is the preview link, FULL-REMOTE-URL is the link to the full resolution image on the server, TYPE is the media type. @@ -1150,11 +1131,11 @@ Runs `mastodon-tl--render-text' and fetches poll or media." (defun mastodon-tl--insert-status (toot body author-byline action-byline &optional id base-toot detailed-p) "Display the content and byline of timeline element TOOT. - BODY will form the section of the toot above the byline. AUTHOR-BYLINE is an optional function for adding the author portion of the byline that takes one variable. By default it is -`mastodon-tl--byline-author' +`mastodon-tl--byline-author'. + ACTION-BYLINE is also an optional function for adding an action, such as boosting favouriting and following to the byline. It also takes a single function. By default it is @@ -1350,7 +1331,6 @@ in which case play first video or gif from current toot." (defun mastodon-tl--toot (toot &optional detailed-p) "Formats TOOT and insertes it into the buffer. - DETAILED-P means display more detailed info. For now this just means displaying toot client." (mastodon-tl--insert-status @@ -1439,7 +1419,6 @@ PARAMS are any parameters to send with the request." (defun mastodon-tl--property (prop &optional backward) "Get property PROP for toot at point. - Move forward (down) the timeline unless BACKWARD is non-nil." (or (get-text-property (point) prop) (save-excursion @@ -1471,7 +1450,6 @@ Move forward (down) the timeline unless BACKWARD is non-nil." (defun mastodon-tl--toot-id (json) "Find approproiate toot id in JSON. - If the toot has been boosted use the id found in the reblog portion of the toot. Otherwise, use the body of the toot. This is the same behaviour as the mastodon.social @@ -2634,7 +2612,6 @@ HEADERS is the http headers returned in the response, if any." (defun mastodon-tl--find-property-range (property start-point &optional search-backwards) "Return `nil` if no such range is found. - If PROPERTY is set at START-POINT returns a range around START-POINT otherwise before/after START-POINT. @@ -2670,7 +2647,6 @@ before (non-nil) or after (nil)" (defun mastodon-tl--find-next-or-previous-property-range (property start-point search-backwards) "Find (start . end) property range after/before START-POINT. - Does so while PROPERTY is set to a consistent value (different from the value at START-POINT if that is set). @@ -2695,7 +2671,6 @@ START-POINT otherwise after START-POINT." (defun mastodon-tl--consider-timestamp-for-updates (timestamp) "Take note that TIMESTAMP is used in buffer and ajust timers as needed. - This calculates the next time the text for TIMESTAMP will change and may adjust existing or future timer runs should that time before current plans to run the update function. @@ -2725,7 +2700,6 @@ is a no-op." (defun mastodon-tl--update-timestamps-callback (buffer previous-marker) "Update the next few timestamp displays in BUFFER. - Start searching for more timestamps from PREVIOUS-MARKER or from the start if it is nil." ;; only do things if the buffer hasn't been killed in the meantime @@ -2891,7 +2865,6 @@ JSON and http headers, without it just the JSON." (defun mastodon-tl--init-sync (buffer-name endpoint update-function &optional note-type) "Initialize BUFFER-NAME with timeline targeted by ENDPOINT. - UPDATE-FUNCTION is used to receive more toots. Runs synchronously. Optional arg NOTE-TYPE means only get that type of note." diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 56ad4ed..99b5936 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -113,7 +113,6 @@ Used for completion in toot compose buffer." (defcustom mastodon-toot--use-company-for-completion nil "Whether to enable company for completion. - When non-nil, `company-mode' is enabled in the toot compose buffer, and mastodon completion backends are added to `company-capf'. @@ -160,7 +159,6 @@ You need to install company yourself to use this." (defvar-local mastodon-toot--visibility nil "A string indicating the visibility of the toot being composed. - Valid values are \"direct\", \"private\" (followers-only), \"unlisted\", and \"public\". @@ -279,7 +277,6 @@ NO-TOOT means we are not calling from a toot buffer." (defun mastodon-toot--action-success (marker byline-region remove) "Insert/remove the text MARKER with 'success face in byline. - BYLINE-REGION is a cons of start and end pos of the byline to be modified. Remove MARKER if REMOVE is non-nil, otherwise add it." @@ -299,7 +296,7 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." (insert (format "(%s) " (propertize marker 'face 'success))))) (when at-byline-p - ;; leave point after the marker: + ;; leave point after the marker: (unless remove (mastodon-tl--goto-next-toot))))) @@ -855,7 +852,6 @@ Remove empty string (self) from result and joins the sequence with whitespace." (defun mastodon-toot--process-local (acct) "Add domain to local ACCT and replace the curent user name with \"\". - Mastodon requires the full @user@domain, even in the case of local accts. eg. \"user\" -> \"@user@local.social\" (when local.social is the domain of the mastodon-instance-url). diff --git a/lisp/mastodon.el b/lisp/mastodon.el index a6ee4bc..cd7dd8e 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -61,7 +61,6 @@ (autoload 'mastodon-profile--make-author-buffer "mastodon-profile") (autoload 'mastodon-profile--show-user "mastodon-profile") (autoload 'mastodon-discover "mastodon-discover") - (autoload 'mastodon-tl--block-user "mastodon-tl") (autoload 'mastodon-tl--unblock-user "mastodon-tl") (autoload 'mastodon-tl--mute-user "mastodon-tl") @@ -107,7 +106,6 @@ (defcustom mastodon-instance-url "https://mastodon.social" "Base URL for the Mastodon instance you want to be active. - For example, if your mastodon username is \"example_user@social.instance.org\", and you want this account to be active, the value of this variable should be @@ -123,7 +121,6 @@ changes to take effect." (defcustom mastodon-active-user nil "Username of the active user. - For example, if your mastodon username is \"example_user@social.instance.org\", and you want this account to be active, the value of this variable should be @@ -139,7 +136,6 @@ changes to take effect." (defcustom mastodon-toot-timestamp-format "%F %T" "Format to use for timestamps. - For valid formatting options see `format-time-string`. The default value \"%F %T\" prints ISO8601-style YYYY-mm-dd HH:MM:SS. Use. e.g. \"%c\" for your locale's date and time format." -- cgit v1.2.3 From 480a1637007ff63792ae509f3659b2b7be2abb89 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 14 Jan 2023 14:42:32 +0100 Subject: remove insert call in toot--most-restritive-vis --- lisp/mastodon-toot.el | 1 - 1 file changed, 1 deletion(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 0d733bd..bff6677 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1362,7 +1362,6 @@ The default is given by `mastodon-toot--default-reply-visibility'." (unless (null reply-visibility) (let ((less-restrictive (member (intern mastodon-toot--default-reply-visibility) mastodon-toot-visibility-list))) - (insert (format "%s" reply-visibility)) (if (member (intern reply-visibility) less-restrictive) mastodon-toot--default-reply-visibility reply-visibility)))) -- cgit v1.2.3 From 63edb7d5a2cae579d7e076398057e7a83cfa1888 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 15 Jan 2023 07:13:55 +0100 Subject: toot--send: simplify edit-p check --- lisp/mastodon-toot.el | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index bff6677..177cfdc 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -710,12 +710,11 @@ If media items have been attached and uploaded with If `mastodon-toot--edit-toot-id' is non-nil, PUT contents to instance to edit a toot." (interactive) - (let* ((edit-p (if mastodon-toot--edit-toot-id t nil)) - (toot (mastodon-toot--remove-docs)) + (let* ((toot (mastodon-toot--remove-docs)) (scheduled mastodon-toot--scheduled-for) (scheduled-id mastodon-toot--scheduled-id) (endpoint - (if edit-p + (if mastodon-toot--edit-toot-id ;; we are sending an edit: (mastodon-http--api (format "statuses/%s" mastodon-toot--edit-toot-id)) @@ -731,8 +730,8 @@ instance to edit a toot." (symbol-name t))) ("spoiler_text" . ,spoiler) ("language" . ,mastodon-toot--language)) - ; Pleroma instances can't handle null-valued - ; scheduled_at args, so only add if non-nil + ; Pleroma instances can't handle null-valued + ; scheduled_at args, so only add if non-nil (when scheduled `(("scheduled_at" . ,scheduled))))) (args-media (when mastodon-toot--media-attachments (mastodon-http--build-array-params-alist @@ -760,7 +759,7 @@ instance to edit a toot." ((mastodon-toot--empty-p) (message "Empty toot. Cowardly refusing to post this.")) (t - (let ((response (if edit-p + (let ((response (if mastodon-toot--edit-toot-id ;; we are sending an edit: (mastodon-http--put endpoint args) (mastodon-http--post endpoint args)))) -- cgit v1.2.3 From 78eb53aacb42480a2b387b76ca90946b114985d3 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 16 Jan 2023 07:59:30 +0100 Subject: buffer-spec for toot-edits history and add check to get-buffer-type --- lisp/mastodon-tl.el | 4 +++- lisp/mastodon-toot.el | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 96aaf4b..e01d3a7 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1474,7 +1474,9 @@ Should work in all mastodon buffers." 'scheduled-statuses) ;; instance description ((string= "instance" endpoint-fun) - 'instance-description)))) + 'instance-description) + ((string= "*mastodon-toot-edits*" buffer-name-fun) + 'toot-edits)))) (defun mastodon-tl--has-toots-p () "Return non-nil if the current buffer contains toots. diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 177cfdc..2241805 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -815,7 +815,8 @@ instance to edit a toot." (defun mastodon-toot--view-toot-edits () "View editing history of the toot at point in a popup buffer." (interactive) - (let ((history (mastodon-tl--property 'edit-history))) + (let ((id (mastodon-tl--property 'base-toot-id)) + (history (mastodon-tl--property 'edit-history))) (with-current-buffer (get-buffer-create "*mastodon-toot-edits*") (let ((inhibit-read-only t)) (special-mode) @@ -836,7 +837,10 @@ instance to edit a toot." (format "Edits to toot by %s:" (alist-get 'username (alist-get 'account (car history)))) - 'face font-lock-comment-face)))))) + 'face font-lock-comment-face)) + (mastodon-tl--set-buffer-spec (buffer-name (current-buffer)) + (format "statuses/%s/history" id) + nil))))) (defun mastodon-toot--insert-toot-iter (it) "Insert iteration IT of toot." -- cgit v1.2.3 From 098f8b1e73e10801c55d4c470906bca6edd75251 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 16 Jan 2023 10:55:06 +0100 Subject: differentiate edit toot from new toot --- lisp/mastodon-tl.el | 5 ++++- lisp/mastodon-toot.el | 12 +++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index dd17988..931fa0b 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1417,7 +1417,10 @@ Should work in all mastodon buffers." (let ((endpoint-fun (mastodon-tl--get-endpoint nil :no-error)) (buffer-name-fun (mastodon-tl--buffer-name nil :no-error))) (cond (mastodon-toot-mode - 'compose-toot) + ;; composing/editing: + (if (string= "*edit toot*" (buffer-name)) + 'edit-toot + 'new-toot)) ;; main timelines: ((string= "timelines/home" endpoint-fun) 'home) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 2241805..0d4f9e2 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -793,9 +793,9 @@ instance to edit a toot." (toot-language (alist-get 'language toot)) (reply-id (alist-get 'in_reply_to_id toot))) (when (y-or-n-p "Edit this toot? ") - (mastodon-toot--compose-buffer) + (mastodon-toot--compose-buffer nil reply-id nil content :edit) (goto-char (point-max)) - (insert content) + ;; (insert content) ;; adopt reply-to-id, visibility, CW, and language: (mastodon-toot--set-toot-properties reply-id toot-visibility source-cw toot-language) @@ -1543,15 +1543,17 @@ Added to `after-change-functions'." ;; NB: now that we have toot drafts, to ensure offline composing remains ;; possible, avoid any direct requests here: (defun mastodon-toot--compose-buffer (&optional reply-to-user - reply-to-id reply-json initial-text) + reply-to-id reply-json initial-text + edit) "Create a new buffer to capture text for a new toot. If REPLY-TO-USER is provided, inject their handle into the message. If REPLY-TO-ID is provided, set the `mastodon-toot--reply-to-id' var. REPLY-JSON is the full JSON of the toot being replied to. INITIAL-TEXT is used by `mastodon-toot-insert-draft-toot' to add a draft into the buffer." - (let* ((buffer-exists (get-buffer "*new toot*")) - (buffer (or buffer-exists (get-buffer-create "*new toot*"))) + (let* ((buffer-name (if edit "*edit toot*" "*new toot*")) + (buffer-exists (get-buffer buffer-name)) + (buffer (or buffer-exists (get-buffer-create buffer-name))) (inhibit-read-only t) (reply-text (alist-get 'content reply-json)) (previous-window-config (list (current-window-configuration) -- cgit v1.2.3 From 3998bfa01b4a3998288061ab87d5c4f4c7ffdf3d Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 28 Jan 2023 09:36:11 +0100 Subject: error msg on attempt to boost private toot. FIXES #383 --- lisp/mastodon-toot.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 0d4f9e2..cc3d506 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -342,7 +342,9 @@ TYPE is a symbol, either 'favourite or 'boost." (msg (if boosted "unboosted" "boosted")) (action-string (if boost-p "boost" "favourite")) (remove (if boost-p (when boosted t) (when faved t))) - (toot-type (alist-get 'type (mastodon-tl--property 'toot-json)))) + (toot-type (alist-get 'type (mastodon-tl--property 'toot-json))) + (visibility (mastodon-tl--field 'visibility + (mastodon-tl--property 'toot-json)))) (if byline-region (cond ;; actually there's nothing wrong with faving/boosting own toots! ;;((mastodon-toot--own-toot-p (mastodon-tl--property 'toot-json)) @@ -354,7 +356,10 @@ TYPE is a symbol, either 'favourite or 'boost." (error "You can't %s boosts" action-string)) ((and (equal "favourite" toot-type) (not (string= (mastodon-tl--get-endpoint) "notifications"))) - (error "Your can't %s favourites" action-string)) + (error "You can't %s favourites" action-string)) + ((and (equal "private" visibility) + (equal type 'boost)) + (error "You can't boost private toots.")) (t (mastodon-toot--action action -- cgit v1.2.3 From ad9f5a1cfd5332447d67012411790371b31f7c0b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 28 Jan 2023 13:42:40 +0100 Subject: list toot boosters and favers --- lisp/mastodon-toot.el | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index cc3d506..e233fba 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -423,6 +423,37 @@ TYPE is a symbol, either 'favourite or 'boost." (message (format "%s #%s" message id))))) (message (format "Nothing to %s here?!?" action))))) +(defun mastodon-toot--list-toot-boosters () + "List the boosters of toot at point." + (interactive) + (mastodon-toot--list-toot-boosters-or-favers)) + +(defun mastodon-toot--list-toot-favouriters () + "List the favouriters of toot at point." + (interactive) + (mastodon-toot--list-toot-boosters-or-favers :favourite)) + +(defun mastodon-toot--list-toot-boosters-or-favers (&optional favourite) + "List the favouriters or boosters of toot at point. +With FAVOURITE, list favouriters, else list boosters." + (let* ((base-toot (mastodon-tl--property 'base-toot-id)) + (endpoint (if favourite "favourited_by" "reblogged_by")) + (url (mastodon-http--api + (format "statuses/%s/%s" base-toot endpoint))) + (params '(("limit" . "80"))) + (json (mastodon-http--get-json url params)) + (handles (mapcar (lambda (x) (alist-get 'acct x)) json)) + (type-string (if favourite "Favouriters" "Boosters"))) + (if (not handles) + (error "Looks like this toot has no %s" type-string) + (let ((choice + (completing-read + (format "%s (enter to view profile): " type-string) + handles + nil + t))) + (mastodon-profile--show-user choice))))) + (defun mastodon-toot--copy-toot-url () "Copy URL of toot at point. If the toot is a fave/boost notification, copy the URLof the -- cgit v1.2.3 From 3f98af1a063da1aa863530b266a69fc1361a7b88 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 28 Jan 2023 13:43:08 +0100 Subject: docstrings/flychecks --- lisp/mastodon-profile.el | 2 +- lisp/mastodon-tl.el | 14 +++++++++----- lisp/mastodon-toot.el | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index ac9feba..b15b4bb 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -363,7 +363,7 @@ Ask for confirmation if length > 500 characters." (mastodon-profile--user-profile-send-updated-do url note)))) (defun mastodon-profile--user-profile-send-updated-do (url note) - "Send PATCH request with the updated profile note." + "Send PATCH request with the updated profile NOTE to URL." (let ((response (mastodon-http--patch url `(("note" . ,note))))) (mastodon-http--triage response (lambda () (message "Profile note updated!"))))) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 867318b..3c6c702 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1392,12 +1392,14 @@ Optionally get it for BUFFER." (defun mastodon-tl--get-endpoint (&optional buffer no-error) "Get the ENDPOINT stored in `mastodon-tl--buffer-spec'. -Optionally set it for BUFFER." +Optionally set it for BUFFER. +NO-ERROR means to fail silently." (mastodon-tl--get-buffer-property 'endpoint buffer no-error)) (defun mastodon-tl--buffer-name (&optional buffer no-error) "Get the BUFFER-NAME stored in `mastodon-tl--buffer-spec'. -Optionally get it for BUFFER." +Optionally get it for BUFFER. +NO-ERROR means to fail silently." (mastodon-tl--get-buffer-property 'buffer-name buffer no-error)) (defun mastodon-tl--link-header (&optional buffer) @@ -1427,7 +1429,8 @@ If NO-ERROR is non-nil, do not error when property is empty." BUFFER is buffer name, ENDPOINT is buffer's enpoint, UPDATE-FUNCTION is its update function. LINK-HEADER is the http Link header if present. -UPDATE-PARAMS is any http parameters needed for the update function." +UPDATE-PARAMS is any http parameters needed for the update function. +HIDE-REPLIES is a flag indicating if replies are hidden in the current buffer." (setq mastodon-tl--buffer-spec `(account ,(cons mastodon-active-user mastodon-instance-url) @@ -1639,7 +1642,7 @@ are displayed by default. Call this if you subsequently want to view all branches of a thread." (interactive) (if (not (eq (mastodon-tl--get-buffer-type) 'thread)) - (error "You need to be viewing a thread to call this.") + (error "You need to be viewing a thread to call this") (goto-char (point-min)) (let ((id (mastodon-tl--property 'base-toot-id))) (mastodon-tl--thread id)))) @@ -3001,7 +3004,8 @@ This location is defined by a non-nil value of UPDATE-FUNCTION is used to recieve more toots. HEADERS means to also collect the response headers. Used for paginating favourites and bookmarks. -PARAMS is any parameters to send with the request." +PARAMS is any parameters to send with the request. +HIDE-REPLIES is a flag indicating if replies are hidden in the current buffer." (let ((url (mastodon-http--api endpoint)) (buffer (concat "*mastodon-" buffer-name "*"))) (if headers diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index e233fba..35fe457 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -359,7 +359,7 @@ TYPE is a symbol, either 'favourite or 'boost." (error "You can't %s favourites" action-string)) ((and (equal "private" visibility) (equal type 'boost)) - (error "You can't boost private toots.")) + (error "You can't boost private toots")) (t (mastodon-toot--action action @@ -1586,7 +1586,8 @@ If REPLY-TO-USER is provided, inject their handle into the message. If REPLY-TO-ID is provided, set the `mastodon-toot--reply-to-id' var. REPLY-JSON is the full JSON of the toot being replied to. INITIAL-TEXT is used by `mastodon-toot-insert-draft-toot' to add -a draft into the buffer." +a draft into the buffer. +EDIT means we are editing an existing toot, not composing a new one." (let* ((buffer-name (if edit "*edit toot*" "*new toot*")) (buffer-exists (get-buffer buffer-name)) (buffer (or buffer-exists (get-buffer-create buffer-name))) -- cgit v1.2.3 From 405ad09845e152990df09a3f2f1ed52e178df2c0 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 28 Jan 2023 16:27:24 +0100 Subject: list-favouriters/boosters: handle null response --- lisp/mastodon-toot.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 35fe457..3f19a0d 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -441,18 +441,21 @@ With FAVOURITE, list favouriters, else list boosters." (url (mastodon-http--api (format "statuses/%s/%s" base-toot endpoint))) (params '(("limit" . "80"))) - (json (mastodon-http--get-json url params)) - (handles (mapcar (lambda (x) (alist-get 'acct x)) json)) - (type-string (if favourite "Favouriters" "Boosters"))) - (if (not handles) - (error "Looks like this toot has no %s" type-string) - (let ((choice - (completing-read - (format "%s (enter to view profile): " type-string) - handles - nil - t))) - (mastodon-profile--show-user choice))))) + (json (mastodon-http--get-json url params))) + (if (eq (caar json) 'error) + (error "%s (Status does not exist or is private)" + (alist-get 'error json)) + (let ((handles (mapcar (lambda (x) (alist-get 'acct x)) json)) + (type-string (if favourite "Favouriters" "Boosters"))) + (if (not handles) + (error "Looks like this toot has no %s" type-string) + (let ((choice + (completing-read + (format "%s (enter to view profile): " type-string) + handles + nil + t))) + (mastodon-profile--show-user choice))))))) (defun mastodon-toot--copy-toot-url () "Copy URL of toot at point. -- cgit v1.2.3 From 5622793b26a01777b1d001a4c2be6f095a5b82e1 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 15 Feb 2023 14:11:06 +0100 Subject: fave/boost: prevent moving to next toot if point already inside byline --- lisp/mastodon-toot.el | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 3f19a0d..7b9163a 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -308,6 +308,10 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." (when at-byline-p ;; leave point after the marker: (unless remove + ;; if point is inside the byline, back up first so + ;; we don't move to the following toot: + (beginning-of-line) + (previous-line) (mastodon-tl--goto-next-toot))))) (defun mastodon-toot--action (action callback) -- cgit v1.2.3 From 990bd88c56105f6524150fb04552148539688f14 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 18 Feb 2023 18:58:24 +0100 Subject: tl--buffer-type-eq/profile-buffer-p for all buffer checks, hopefully --- lisp/mastodon-tl.el | 76 +++++++++++++++++++++++++++------------------------ lisp/mastodon-toot.el | 7 ++--- 2 files changed, 44 insertions(+), 39 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 57d827b..c3d2672 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1474,8 +1474,12 @@ Should work in all mastodon buffers." ((string-prefix-p "statuses" endpoint-fun) 'single-status) ;; profiles: - ((string-prefix-p "accounts" endpoint-fun) + ((mastodon-tl--profile-buffer-p) (cond + ;; own profile: + ((equal (mastodon-tl--buffer-name) + (concat "*mastodon-" (mastodon-auth--get-account-name) "-statuses*")) + 'own-profile) ;; profile note: ((string-suffix-p "update-profile*" buffer-name-fun) 'update-profile-note) @@ -1488,6 +1492,8 @@ Should work in all mastodon buffers." ;; profile following ((string-suffix-p "following" endpoint-fun) 'profile-following))) + ((string= "preferences" endpoint-fun) + 'preferences) ;; search ((string-suffix-p "search" endpoint-fun) 'search) @@ -1497,7 +1503,7 @@ Should work in all mastodon buffers." ((string= "filters" endpoint-fun) 'filters) ((string= "lists" endpoint-fun) - 'lists-view) + 'lists) ((string= "suggestions" endpoint-fun) 'follow-suggestions) ((string= "favourites" endpoint-fun) @@ -1514,11 +1520,20 @@ Should work in all mastodon buffers." ((string= "*mastodon-toot-edits*" buffer-name-fun) 'toot-edits)))) +(defun mastodon-tl--buffer-type-eq (type) + "Return t if current buffer type is equal to symbol TYPE." + (eq (mastodon-tl--get-buffer-type) type)) + +(defun mastodon-tl--profile-buffer-p () + "Return t if current buffer is a profile buffer of any kind. +This includes the update profile note buffer, but not the preferences one." + (string-prefix-p "accounts" (mastodon-tl--get-endpoint nil :no-error))) + (defun mastodon-tl--has-toots-p () "Return non-nil if the current buffer contains toots. Return value is that of `member'. This is used to avoid running into trouble using functions that -presume we are in a timline of toots or similar elements, such as +presume we are in a timeline of toots or similar elements, such as `mastodon-tl--property'." (let ((toot-buffers '(home federated local tag-timeline notifications @@ -1819,8 +1834,7 @@ If ID is provided, use that list." (let* ((json (mastodon-http--process-json)) (name-new (alist-get 'title json))) (message "list %s edited to %s!" name-old name-new))) - (when (equal (buffer-name (current-buffer)) - "*mastodon-lists*") + (when (mastodon-tl--buffer-type-eq 'lists) (mastodon-tl--view-lists)))))) (defun mastodon-tl--view-timeline-list-at-point () @@ -2022,8 +2036,7 @@ If ID is provided, use that list." "Call `mastodon-http--triage' on RESPONSE and display MESSAGE." (mastodon-http--triage response (lambda () - (when (equal (buffer-name (current-buffer)) - "*mastodon-lists*") + (when (mastodon-tl--buffer-type-eq 'lists) (mastodon-tl--view-lists)) message))) @@ -2169,8 +2182,7 @@ Prompt for a context, must be a list containting at least one of \"home\", (lambda () (message "Filter created for %s!" word) ;; reload if we are in filters view: - (when (string= (mastodon-tl--get-endpoint) - "filters") + (when (mastodon-tl--buffer-type-eq 'filters) (mastodon-tl--view-filters)))))) (defun mastodon-tl--view-filters () @@ -2257,7 +2269,7 @@ RESPONSE is the JSON returned by the server." (defmacro mastodon-tl--do-if-toot (&rest body) "Execute BODY if we have a toot or user at point." (declare (debug t)) - `(if (and (not (string-prefix-p "accounts" (mastodon-tl--get-endpoint))) ;profile view + `(if (and (not (mastodon-tl--profile-buffer-p)) (not (mastodon-tl--property 'toot-json))) (message "Looks like there's no toot or user at point?") ,@body)) @@ -2568,19 +2580,19 @@ LANGS is the accumulated array param alist if we re-run recursively." "Get the list of user-handles for ACTION from the current toot." (mastodon-tl--do-if-toot (let ((user-handles - (cond ((or (equal (buffer-name) "*mastodon-follow-suggestions*") + (cond ((or (mastodon-tl--buffer-type-eq 'follow-suggestions) ;; follow suggests / search / foll requests compat: - (string-prefix-p "*mastodon-search" (buffer-name)) - (equal (buffer-name) "*mastodon-follow-requests*") + (mastodon-tl--buffer-type-eq 'search) + (mastodon-tl--buffer-type-eq 'follow-requests) ;; profile view follows/followers compat: ;; but not for profile statuses: ;; fetch 'toot-json: - (and (string-prefix-p "accounts" (mastodon-tl--get-endpoint)) - (not (string-suffix-p "statuses" (mastodon-tl--get-endpoint))))) + (mastodon-tl--buffer-type-eq 'profile-followers) + (mastodon-tl--buffer-type-eq 'profile-following)) (list (alist-get 'acct (get-text-property (point) 'toot-json)))) ;; profile view, no toots, point on profile note, ie. 'profile-json: ;; needed for e.g. gup.pe groups which show no toots publically: - ((and (string-prefix-p "accounts" (mastodon-tl--get-endpoint)) + ((and (mastodon-tl--profile-buffer-p) (get-text-property (point) 'profile-json)) (list (alist-get 'acct (get-text-property (point) 'profile-json)))) ;; avoid tl--property here because it calls next-toot @@ -2626,7 +2638,7 @@ LANGS is an array parameters alist of languages to filer user's posts by." (mastodon-profile--search-account-by-handle user-handle) ;; if profile view, use 'profile-json as status: - (if (string-prefix-p "accounts" (mastodon-tl--get-endpoint)) + (if (mastodon-tl--profile-buffer-p) (mastodon-profile--lookup-account-in-status user-handle (get-text-property (point) 'profile-json)) ;; if muting/blocking, we select from handles in current status @@ -2725,16 +2737,15 @@ If TAG is provided, unfollow it." (defun mastodon-tl--reload-timeline-or-profile () "Reload the current timeline or profile page. For use after e.g. deleting a toot." - (cond ((equal (mastodon-tl--get-endpoint) "timelines/home") + (cond ((mastodon-tl--buffer-type-eq 'home) (mastodon-tl--get-home-timeline)) - ((equal (mastodon-tl--get-endpoint) "timelines/public") + ((mastodon-tl--buffer-type-eq 'federated) (mastodon-tl--get-federated-timeline)) - ((equal (mastodon-tl--buffer-name) "*mastodon-local*") + ((mastodon-tl--buffer-type-eq 'local) (mastodon-tl--get-local-timeline)) - ((equal (mastodon-tl--get-endpoint) "notifications") + ((mastodon-tl--buffer-type-eq 'notifications) (mastodon-notifications-get)) - ((equal (mastodon-tl--buffer-name) - (concat "*mastodon-" (mastodon-auth--get-account-name) "-statuses*")) + ((mastodon-tl--buffer-type-eq 'own-profile) (mastodon-profile--my-profile)) ((save-match-data (string-match @@ -2754,12 +2765,10 @@ For use after e.g. deleting a toot." "Return t if we are in a view needing Link header pagination. Currently this includes favourites, bookmarks, and profile pages when showing followers or accounts followed." - (let ((buf (buffer-name (current-buffer))) - (endpoint (mastodon-tl--get-endpoint))) - (or (member buf '("*mastodon-favourites*" "*mastodon-bookmarks*")) - (and (string-prefix-p "accounts" endpoint) - (or (string-suffix-p "followers" endpoint) - (string-suffix-p "following" endpoint)))))) + (or (mastodon-tl--buffer-type-eq 'favourites) + (mastodon-tl--buffer-type-eq 'bookmarks) + (mastodon-tl--buffer-type-eq 'profile-followers) + (mastodon-tl--buffer-type-eq 'profile-following))) (defun mastodon-tl--more () "Append older toots to timeline, asynchronously." @@ -2977,7 +2986,7 @@ This location is defined by a non-nil value of (update-function (mastodon-tl--get-update-function)) (thread-id (mastodon-tl--property 'toot-id))) ;; update a thread, without calling `mastodon-tl--updated-json': - (if (string-suffix-p "context" (mastodon-tl--get-endpoint)) + (if (mastodon-tl--buffer-type-eq 'thread) (funcall update-function thread-id) ;; update other timelines: (let* ((id (mastodon-tl--newest-id)) @@ -3063,8 +3072,7 @@ JSON and http headers, without it just the JSON." #'mastodon-tl--update-timestamps-callback (current-buffer) nil))) - (unless (string-prefix-p "accounts" endpoint) - ;; for everything save profiles + (unless (mastodon-tl--profile-buffer-p) (mastodon-tl--goto-first-item))))))) (defun mastodon-tl--init-sync (buffer-name endpoint update-function &optional note-type) @@ -3106,9 +3114,7 @@ Optional arg NOTE-TYPE means only get that type of note." #'mastodon-tl--update-timestamps-callback (current-buffer) nil))) - (when ;(and (not (equal json '[])) - ;; for everything save profiles: - (not (string-prefix-p "accounts" endpoint)) + (unless (mastodon-tl--profile-buffer-p) (mastodon-tl--goto-first-item))) buffer)) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7b9163a..250aefd 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -77,7 +77,6 @@ (autoload 'mastodon-tl--render-text "mastodon-tl") (autoload 'mastodon-profile--fetch-server-account-settings-maybe "mastodon-profile") (autoload 'mastodon-http--build-array-params-alist "mastodon-http") -(autoload 'mastodon-tl--get-endpoint "mastodon-tl") (autoload 'mastodon-http--put "mastodon-http") (autoload 'mastodon-tl--symbol "mastodon-tl") (autoload 'mastodon-tl--view-scheduled-toots "mastodon-tl") @@ -356,10 +355,10 @@ TYPE is a symbol, either 'favourite or 'boost." ;; & nothing wrong with faving/boosting own toots from notifs: ;; this boosts/faves the base toot, not the notif status ((and (equal "reblog" toot-type) - (not (string= (mastodon-tl--get-endpoint) "notifications"))) + (not (mastodon-tl--buffer-type-eq 'notifications))) (error "You can't %s boosts" action-string)) ((and (equal "favourite" toot-type) - (not (string= (mastodon-tl--get-endpoint) "notifications"))) + (not (mastodon-tl--buffer-type-eq 'notifications))) (error "You can't %s favourites" action-string)) ((and (equal "private" visibility) (equal type 'boost)) @@ -1581,7 +1580,7 @@ Added to `after-change-functions'." (defun mastodon-toot--compose-buffer-p () "Return t if compose buffer is current." - (equal (buffer-name (current-buffer)) "*new toot*")) + (mastodon-tl--buffer-type-eq 'new-toot)) ;; NB: now that we have toot drafts, to ensure offline composing remains ;; possible, avoid any direct requests here: -- cgit v1.2.3 From 4f9a7be4926dbf3f33a717fcbed12de78c22b331 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 19 Feb 2023 21:53:48 +0100 Subject: autoloads, flychecks --- lisp/mastodon-profile.el | 4 ++++ lisp/mastodon-tl.el | 1 + lisp/mastodon-toot.el | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index b0b3e0e..aa4a12e 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -78,6 +78,9 @@ (autoload 'mastodon-tl--set-buffer-spec "mastodon-tl") (autoload 'mastodon-tl--symbol "mastodon-tl") (autoload 'mastodon-auth--get-account-id "mastodon-auth") +(autoload 'mastodon-tl--profile-buffer-p "mastodon tl") +(autoload 'mastodon-tl--buffer-type-eq "mastodon tl") +(autoload 'mastodon-toot--count-toot-chars "mastodon-toot") (defvar mastodon-instance-url) (defvar mastodon-tl--buffer-spec) @@ -86,6 +89,7 @@ (defvar mastodon-toot--max-toot-chars) (defvar mastodon-toot--visibility) (defvar mastodon-toot--content-nsfw) +(defvar mastodon-tl--timeline-posts-count) (defvar-local mastodon-profile--account nil "The data for the account being described in the current profile buffer.") diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2a20e73..ba6b1df 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -87,6 +87,7 @@ (autoload 'mastodon-toot--iso-to-human "mastodon-toot") (defvar mastodon-toot--visibility) +(defvar mastodon-toot-mode) (defvar mastodon-active-user) (when (require 'mpv nil :no-error) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 250aefd..64cdca1 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -41,7 +41,6 @@ (require 'cl-lib) (require 'persist) - (require 'mastodon-iso) (defvar mastodon-instance-url) @@ -83,6 +82,9 @@ (autoload 'mastodon-tl--cancel-scheduled-toot "mastodon-toot") (autoload 'org-read-date "org") (autoload 'iso8601-parse "iso8601") +(autoload 'mastodon-tl--buffer-type-eq "mastodon-tl") +(autoload 'mastodon-profile--show-user "mastodon-profile") +(autoload 'mastodon-tl--set-buffer-spec "mastodon-tl") ;; for mastodon-toot--translate-toot-text (autoload 'mastodon-tl--content "mastodon-tl") @@ -310,7 +312,7 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." ;; if point is inside the byline, back up first so ;; we don't move to the following toot: (beginning-of-line) - (previous-line) + (forward-line -1) (mastodon-tl--goto-next-toot))))) (defun mastodon-toot--action (action callback) -- cgit v1.2.3 From b0946358c7c2b1e179ae4dc6a6620a7c8fd6c9a0 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 Feb 2023 21:28:28 +0100 Subject: fix a comment --- lisp/mastodon-toot.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 64cdca1..0f3d658 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -774,8 +774,8 @@ instance to edit a toot." (symbol-name t))) ("spoiler_text" . ,spoiler) ("language" . ,mastodon-toot--language)) - ; Pleroma instances can't handle null-valued - ; scheduled_at args, so only add if non-nil + ;; Pleroma instances can't handle null-valued + ;; scheduled_at args, so only add if non-nil (when scheduled `(("scheduled_at" . ,scheduled))))) (args-media (when mastodon-toot--media-attachments (mastodon-http--build-array-params-alist -- cgit v1.2.3 From 619ebc6cb1f65280f1be785b92ce699575732c74 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 Feb 2023 21:31:19 +0100 Subject: insert spaces before argument lists for lambda --- lisp/mastodon-toot.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 0f3d658..7f24818 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -902,8 +902,8 @@ Buffer-local variable `mastodon-toot-previous-window-config' holds the config." (defun mastodon-toot--mentions-to-string (mentions) "Apply `mastodon-toot--process-local' function to each mention in MENTIONS. Remove empty string (self) from result and joins the sequence with whitespace." - (mapconcat (lambda(mention) mention) - (remove "" (mapcar (lambda(x) (mastodon-toot--process-local x)) + (mapconcat (lambda (mention) mention) + (remove "" (mapcar (lambda (x) (mastodon-toot--process-local x)) mentions)) " ")) -- cgit v1.2.3 From b9368c00359bc6407048669539957a45cac47297 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 Feb 2023 21:31:51 +0100 Subject: remove some whitespace --- lisp/mastodon-toot.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7f24818..2625695 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -933,7 +933,7 @@ Federated user: `username@host.co`." ;; reverse does not work on vectors in 24.5 (mapcar (lambda(x) (alist-get 'acct x)) (reverse mentions)))) - + (defun mastodon-toot--get-bounds (regex) "Get bounds of tag or handle before point using REGEX." ;; needed because # and @ are not part of any existing thing at point -- cgit v1.2.3