From d7c388eb997056fe954faa6ff85a1fd95ef7f691 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 3 Sep 2022 14:51:22 +0200 Subject: url-lookkup: fix loading profile fun: just use the search JSON --- lisp/mastodon.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 13a410b..aca2230 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -296,8 +296,7 @@ not, just browse the URL in the normal fashion." (alist-get 'accounts response))) (let* ((accounts (assoc 'accounts response)) (account (seq-first (cdr accounts))) - (account-acct (alist-get 'acct account))) - (mastodon-profile--show-user account-acct))) + (mastodon-profile--make-author-buffer account))) (t (browse-url query)))))))) -- cgit v1.2.3 From 113e33bf8effec6d5568104474b25ef67635334b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 3 Sep 2022 14:51:22 +0200 Subject: url-lookup: fix loading profile fun: just use the search JSON --- lisp/mastodon.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 13a410b..9ff7106 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -296,8 +296,7 @@ not, just browse the URL in the normal fashion." (alist-get 'accounts response))) (let* ((accounts (assoc 'accounts response)) (account (seq-first (cdr accounts))) - (account-acct (alist-get 'acct account))) - (mastodon-profile--show-user account-acct))) + (mastodon-profile--make-author-buffer account)))) (t (browse-url query)))))))) -- cgit v1.2.3 From cc6e4026e03e3c075ae670cd11f2a53981a830a8 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 3 Sep 2022 16:02:11 +0200 Subject: docstring --- lisp/mastodon.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 4994fed..93b24b3 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -269,7 +269,8 @@ If REPLY-JSON is the json of the toot being replied to." ;;;###autoload (defun mastodon-url-lookup (&optional query-url) - "Do a WebFinger lookup for a URL. + "If QUERY-URL resembles a mastodon link, try to load in `mastodon.el'. +Does a WebFinger lookup. URL can be arg QUERY-URL, or URL at point, or provided by the user. If a status or account is found, load it in `mastodon.el', if not, just browse the URL in the normal fashion." -- cgit v1.2.3 From 23013ff6daa54c8268c6f5b791270b78e1ac7eb0 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 3 Sep 2022 18:32:37 +0200 Subject: improve masto-url-p regexes --- lisp/mastodon.el | 62 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 93b24b3..0c6104f 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -279,43 +279,43 @@ not, just browse the URL in the normal fashion." (url-get-url-at-point) (get-text-property (point) 'shr-url) (read-string "Lookup URL: ")))) - ;; TODO: test for a likely masto link and just browse-url if not - (save-match-data - (if (not (mastodon--masto-url-p query)) - (browse-url query) - (message "Performing lookup...") - (let* ((url (format "%s/api/v2/search" mastodon-instance-url)) - (param (concat "resolve=t")) ; webfinger - (response (mastodon-http--get-search-json url query param :silent))) - (cond ((not (seq-empty-p - (alist-get 'statuses response))) - (let* ((statuses (assoc 'statuses response)) - (status (seq-first (cdr statuses))) - (status-id (alist-get 'id status))) - (mastodon-tl--thread status-id))) - ((not (seq-empty-p - (alist-get 'accounts response))) - (let* ((accounts (assoc 'accounts response)) - (account (seq-first (cdr accounts)))) - (mastodon-profile--make-author-buffer account))) - (t - (browse-url query)))))))) + (if (not (mastodon--masto-url-p query)) + (browse-url query) + (message "Performing lookup...") + (let* ((url (format "%s/api/v2/search" mastodon-instance-url)) + (param (concat "resolve=t")) ; webfinger + (response (mastodon-http--get-search-json url query param :silent))) + (cond ((not (seq-empty-p + (alist-get 'statuses response))) + (let* ((statuses (assoc 'statuses response)) + (status (seq-first (cdr statuses))) + (status-id (alist-get 'id status))) + (mastodon-tl--thread status-id))) + ((not (seq-empty-p + (alist-get 'accounts response))) + (let* ((accounts (assoc 'accounts response)) + (account (seq-first (cdr accounts)))) + (mastodon-profile--make-author-buffer account))) + (t + (browse-url query))))))) (defun mastodon--masto-url-p (query) "Check if QUERY resembles a fediverse URL." - ;; regex test the url: ;; calqued off https://github.com/tuskyapp/Tusky/blob/c8fc2418b8f5458a817bba221d025b822225e130/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt ;; TODO: remove domain and add ^ to regex: ;; (let ((query-path (url-file-nondirectory query))) - (or (string-match "/@" query) - (string-match "/users/[[:alnum:]]+$" query) - (string-match "/notice/[[:alnum:]]+$" query) - (string-match "/objects/[-a-f0-9]+$" query) - (string-match "/notes/[a-z0-9]+$" query) - (string-match "/display/[-a-f0-9]+$" query) - (string-match "/profile/[[:alpha:]]+$" query) - (string-match "/p/[[:alpha:]]+/[[:digit:]]+$" query) - (string-match "/[[:alpha:]]+$" query))) + (let* ((uri-parsed (url-generic-parse-url query)) + (query (url-filename uri-parsed))) + (save-match-data + (or (string-match "^/@[[:alnum:]]+/[[:digit:]]+$" query) + (string-match "^/users/[[:alnum:]]+$" query) + (string-match "^/notice/[[:alnum:]]+$" query) + (string-match "^/objects/[-a-f0-9]+$" query) + (string-match "^/notes/[a-z0-9]+$" query) + (string-match "^/display/[-a-f0-9]+$" query) + (string-match "^/profile/[[:alpha:]]+$" query) + (string-match "^/p/[[:alpha:]]+/[[:digit:]]+$" query) + (string-match "^/[[:alpha:]]+$" query))))) ;;;###autoload (add-hook 'mastodon-mode-hook (lambda () -- cgit v1.2.3 From 479bdf4becba035a74243514ce82d37c12d02bfa Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 14:06:59 +0200 Subject: improve masto-url-p regexes for users --- lisp/mastodon.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 0c6104f..d773d24 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -302,12 +302,12 @@ not, just browse the URL in the normal fashion." (defun mastodon--masto-url-p (query) "Check if QUERY resembles a fediverse URL." ;; calqued off https://github.com/tuskyapp/Tusky/blob/c8fc2418b8f5458a817bba221d025b822225e130/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt - ;; TODO: remove domain and add ^ to regex: - ;; (let ((query-path (url-file-nondirectory query))) + ;; thx to Conny Duck! (let* ((uri-parsed (url-generic-parse-url query)) (query (url-filename uri-parsed))) (save-match-data - (or (string-match "^/@[[:alnum:]]+/[[:digit:]]+$" query) + (or (string-match "^/@[^/]+$" query) + (string-match "^/@[^/]+/[[:digit:]]+$" query) (string-match "^/users/[[:alnum:]]+$" query) (string-match "^/notice/[[:alnum:]]+$" query) (string-match "^/objects/[-a-f0-9]+$" query) -- cgit v1.2.3 From 6eef69b247a20cea4bb1fc598cfc9e69deb7fb91 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 14:56:33 +0200 Subject: url-lookup: shr-browse-url not browse-url, for keymap --- lisp/mastodon.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index d773d24..5d41858 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -280,7 +280,7 @@ not, just browse the URL in the normal fashion." (get-text-property (point) 'shr-url) (read-string "Lookup URL: ")))) (if (not (mastodon--masto-url-p query)) - (browse-url query) + (shr-browse-url query) (message "Performing lookup...") (let* ((url (format "%s/api/v2/search" mastodon-instance-url)) (param (concat "resolve=t")) ; webfinger -- cgit v1.2.3 From 5073a82d39914e1b753005520219ab949cd13f97 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 14:56:33 +0200 Subject: url-lookup: shr-browse-url in masto-mode, otherwise browse-url --- lisp/mastodon.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 5d41858..4578e13 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -280,7 +280,9 @@ not, just browse the URL in the normal fashion." (get-text-property (point) 'shr-url) (read-string "Lookup URL: ")))) (if (not (mastodon--masto-url-p query)) - (shr-browse-url query) + (if (equal major-mode 'mastodon-mode) + (shr-browse-url query) ;; keep our shr keymap + (browse-url query)) (message "Performing lookup...") (let* ((url (format "%s/api/v2/search" mastodon-instance-url)) (param (concat "resolve=t")) ; webfinger -- cgit v1.2.3 From cf504419334bf964e5211ab238783efb15325648 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 22:02:26 +0200 Subject: fix toot--kill test --- lisp/mastodon-toot.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 2f58bfb..5ec58dd 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -462,14 +462,13 @@ REPLY-ID, TOOT-VISIBILITY, and TOOT-CW of deleted toot are preseved." (defun mastodon-toot--kill (&optional cancel) "Kill `mastodon-toot-mode' buffer and window. CANCEL means the toot was not sent, so we save the toot text as a draft." - (with-current-buffer (get-buffer "*new toot*") - (unless (eq mastodon-toot-current-toot-text nil) - (when cancel - (cl-pushnew mastodon-toot-current-toot-text - mastodon-toot-draft-toots-list :test 'equal))) - ;; prevent some weird bug when cancelling a non-empty toot: - (delete #'mastodon-toot-save-toot-text after-change-functions) - (kill-buffer-and-window))) + (unless (eq mastodon-toot-current-toot-text nil) + (when cancel + (cl-pushnew mastodon-toot-current-toot-text + mastodon-toot-draft-toots-list :test 'equal))) + ;; prevent some weird bug when cancelling a non-empty toot: + (delete #'mastodon-toot-save-toot-text after-change-functions) + (kill-buffer-and-window)) (defun mastodon-toot--cancel () "Kill new-toot buffer/window. Does not POST content to Mastodon. -- cgit v1.2.3 From 2b484837ef8a0e2874284ff7be6d531e9b45d610 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 19 Sep 2022 12:04:42 +0200 Subject: add persist dep to mastodon.el file explicitly --- lisp/mastodon.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 72043cf..bc624d9 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -5,7 +5,7 @@ ;; Author: Johnson Denen ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1") (request "0.3.0")) +;; Package-Requires: ((emacs "27.1") (request "0.3.0") (persist "0.4")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. -- cgit v1.2.3 From c917a2d0e85167dc82db14975d2d3960114d4279 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 20 Sep 2022 14:44:22 +0200 Subject: FIX getting of 'parent-toot properties in mastodon-toot--reply --- lisp/mastodon-toot.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 5ec58dd..8c9cc62 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -761,7 +761,7 @@ Customize `mastodon-toot-display-orig-in-reply-buffer' to display text of the toot being replied to in the compose buffer." (interactive) (let* ((toot (mastodon-tl--property 'toot-json)) - (parent (mastodon-tl--property 'parent-toot)) ; for new notifs handling + (parent (mastodon-tl--field 'parent-toot toot)) ; for new notifs handling (id (mastodon-tl--as-string (mastodon-tl--field 'id (or parent toot)))) (account (mastodon-tl--field 'account toot)) -- cgit v1.2.3 From 6b88c28779bd64aaf56c9d1e0c5fced77a506c0a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 21 Sep 2022 16:20:14 +0200 Subject: handle empty relationships vector in make-buffer-for can be empty when doing url-lookup on a mention --- lisp/mastodon-profile.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 012e357..7f78df7 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -461,10 +461,12 @@ Returns a list of lists." (mastodon-profile--account-field account 'statuses_count))) (relationships (mastodon-profile--relationships-get id)) - (followed-by-you (alist-get 'following - (aref relationships 0))) - (follows-you (alist-get 'followed_by - (aref relationships 0))) + (followed-by-you (when (not (seq-empty-p relationships)) + (alist-get 'following + (aref relationships 0)))) + (follows-you (when (not (seq-empty-p relationships)) + (alist-get 'followed_by + (aref relationships 0)))) (followsp (or (equal follows-you 't) (equal followed-by-you 't))) (fields (mastodon-profile--fields-get account)) (pinned (mastodon-profile--get-statuses-pinned account))) -- cgit v1.2.3 From cf02b35a4170bbde1d36a24591e11d553f0be58f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 15 Oct 2022 22:04:55 +0200 Subject: autoload profile-account-settings in mastodon.el --- lisp/mastodon.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index bc624d9..e50d5c1 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -97,6 +97,7 @@ (autoload 'mastodon-toot--translate-toot-text "mastodon-toot")) (autoload 'mastodon-search--trending-tags "mastodon-search") (autoload 'mastodon-profile-fetch-server-account-settings "mastodon-profile") +(autoload 'mastodon-profile-account-settings "mastodon-profile") (defgroup mastodon nil "Interface with Mastodon." -- cgit v1.2.3 From f678fc83f777ef40e948c176b1343e4de3764856 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 3 Nov 2022 21:44:06 +0100 Subject: Revert "remove unused --append-query-string" This reverts commit e2fd67b16104ab772a4ef962613cb9f3cb3cea52. --- lisp/mastodon-http.el | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lisp') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index f32ccd4..f73fd6b 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -173,6 +173,13 @@ Pass response buffer to CALLBACK function." (with-temp-buffer (mastodon-http--url-retrieve-synchronously url)))) +(defun mastodon-http--append-query-string (url params) + "Append PARAMS to URL as query strings and return it. + +PARAMS should be an alist as required by `url-build-query-string'." + (let ((query-string (url-build-query-string params))) + (concat url "?" query-string))) + ;; search functions: (defun mastodon-http--process-json-search () "Process JSON returned by a search query to the server." -- cgit v1.2.3 From e61ba4cccfeddce5fe0f2b4a43cbd444861cf31e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 7 Nov 2022 13:58:34 +0100 Subject: add dash to handles regex --- lisp/mastodon-toot.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 60cc4da..7a40354 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1217,7 +1217,7 @@ Added to `after-change-functions'." (mastodon-toot--propertize-item "#[1-9a-zA-Z_]+" 'success (cdr header-region)) - (mastodon-toot--propertize-item "@[1-9a-zA-Z._]+" + (mastodon-toot--propertize-item "@[1-9a-zA-Z._-]+" 'mastodon-display-name-face (cdr header-region))))) -- cgit v1.2.3 From 9411f56f9f0d3a26e5948058dd919dcf71331c6a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 10 Nov 2022 19:02:36 +0100 Subject: FIX: -tl--get-poll - add a fallback format string --- lisp/mastodon-tl.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 6f53f93..92fd12b 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -996,7 +996,12 @@ this just means displaying toot client." ((> (plist-get parsed :hours) 0) (format "%s hours, %s minutes left" (plist-get parsed :hours) (plist-get parsed :minutes))) ((> (plist-get parsed :minutes) 0) - (format "%s minutes left" (plist-get parsed :minutes)))))) + (format "%s minutes left" (plist-get parsed :minutes))) + (t ;; we failed to guess: + (format "%s days, %s hours, %s minutes left" + (plist-get parsed :days) + (plist-get parsed :hours) + (plist-get parsed :minutes)))))) (defun mastodon-tl--poll-vote (option) "If there is a poll at point, prompt user for OPTION to vote on it." -- cgit v1.2.3 From 7d8dd00a97c73b0c2e04c37c38daf6b1c04de4c8 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 10 Nov 2022 20:44:41 +0100 Subject: FIX update profile note - params alist format --- lisp/mastodon-profile.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 4aa9310..c61298e 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -270,7 +270,7 @@ JSON is the data returned by the server." (let* ((note (buffer-substring-no-properties (point-min) (point-max))) (url (mastodon-http--api "accounts/update_credentials"))) (kill-buffer-and-window) - (let ((response (mastodon-http--patch url `((note ,note))))) + (let ((response (mastodon-http--patch url `(("note" . ,note))))) (mastodon-http--triage response (lambda () (message "Profile note updated!")))))) -- cgit v1.2.3 From 404d2fce2a5a975888a499aa224c81e862f60b82 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 10 Nov 2022 20:48:11 +0100 Subject: GET verify_cred not PATCH update_creds for fetch profile note --- lisp/mastodon-profile.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index c61298e..8d5bf36 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -246,8 +246,8 @@ JSON is the data returned by the server." (defun mastodon-profile--update-user-profile-note () "Fetch user's profile note and display for editing." (interactive) - (let* ((url (mastodon-http--api "accounts/update_credentials")) - (json (mastodon-http--patch-json url)) + (let* ((url (mastodon-http--api "accounts/verify_credentials")) + (json (mastodon-http--get-json url)) (source (alist-get 'source json)) (note (alist-get 'note source)) (buffer (get-buffer-create "*mastodon-update-profile*")) -- cgit v1.2.3 From ee9787e2b05878c9db8353d6321a0d04a65b0c4b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Nov 2022 10:06:53 +0100 Subject: remove call to shr-browse-url for non-masto URLs --- lisp/mastodon.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index b169f00..a61aead 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -288,9 +288,12 @@ not, just browse the URL in the normal fashion." (get-text-property (point) 'shr-url) (read-string "Lookup URL: ")))) (if (not (mastodon--masto-url-p query)) - (if (equal major-mode 'mastodon-mode) - (shr-browse-url query) ;; keep our shr keymap - (browse-url query)) + ;; this doesn't work as shr-browse-url doesn't take a url arg + ;; and with no args it can't use our read-string query, but only + ;; looks for a url at point + ;; (if (equal major-mode 'mastodon-mode) + ;; (shr-browse-url query) ;; keep our shr keymap + (browse-url query) (message "Performing lookup...") (let* ((url (format "%s/api/v2/search" mastodon-instance-url)) (param (concat "resolve=t")) ; webfinger -- cgit v1.2.3 From 01575d69be8ee629968c57cac742ae742433e367 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Nov 2022 12:00:03 +0100 Subject: remove commented autoloads from mastodon.el --- lisp/mastodon.el | 9 --------- 1 file changed, 9 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index a61aead..7ec6ee3 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -61,10 +61,6 @@ (autoload 'mastodon-profile--get-toot-author "mastodon-profile") (autoload 'mastodon-profile--make-author-buffer "mastodon-profile") (autoload 'mastodon-profile--show-user "mastodon-profile") -;; (autoload 'mastodon-toot--compose-buffer "mastodon-toot") -;; (autoload 'mastodon-toot--reply "mastodon-toot") -;; (autoload 'mastodon-toot--toggle-boost "mastodon-toot") -;; (autoload 'mastodon-toot--toggle-favourite "mastodon-toot") (autoload 'mastodon-discover "mastodon-discover") (autoload 'mastodon-tl--block-user "mastodon-tl") @@ -79,9 +75,6 @@ (autoload 'mastodon-notifications--follow-request-accept "mastodon-notifications") (autoload 'mastodon-notifications--follow-request-reject "mastodon-notifications") (autoload 'mastodon-search--search-query "mastodon-search") -;; (autoload 'mastodon-toot--delete-toot "mastodon-toot") -;; (autoload 'mastodon-toot--copy-toot-url "mastodon-toot") -;; (autoload 'mastodon-toot--pin-toot-toggle "mastodon-toot") (autoload 'mastodon-auth--get-account-name "mastodon-auth") ;; (autoload 'mastodon-async--stream-federated "mastodon-async") ;; (autoload 'mastodon-async--stream-local "mastodon-async") @@ -91,10 +84,8 @@ (autoload 'mastodon-profile--update-user-profile-note "mastodon-profile") (autoload 'mastodon-auth--user-acct "mastodon-auth") (autoload 'mastodon-tl--poll-vote "mastodon-http") -;; (autoload 'mastodon-toot--delete-and-redraft-toot "mastodon-toot") (autoload 'mastodon-profile--view-bookmarks "mastodon-profile") (autoload 'mastoton-tl--view-filters "mastodon-tl") -;; (autoload 'mastodon-toot--bookmark-toot-toggle "mastodon-toot") (autoload 'mastodon-tl--view-filters "mastodon-tl") (autoload 'mastodon-tl--get-follow-suggestions "mastodon-tl") (when (require 'lingva nil :no-error) -- cgit v1.2.3 From 302f4828703313057823dfcc39d01ae00eb21e86 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 17 Nov 2022 09:49:46 +0100 Subject: prop tags/handles - tweak regex for spacing --- lisp/mastodon-toot.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 438e887..3c4c7aa 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1262,10 +1262,10 @@ Added to `after-change-functions'." ;; stops all text after a handle or mention being propertized: (set-text-properties (cdr header-region) (point-max) nil) ;; TODO: confirm allowed hashtag/handle characters: - (mastodon-toot--propertize-item "[\n\t ]\\(?2:#[1-9a-zA-Z_]+\\)[\n\t ]" + (mastodon-toot--propertize-item "\\([\n\t ]\\|^\\)\\(?2:#[1-9a-zA-Z_]+\\)\\b" 'success (cdr header-region)) - (mastodon-toot--propertize-item "[\n\t ]\\(?2:@[1-9a-zA-Z._-]+\\)[\n\t ]" + (mastodon-toot--propertize-item "\\([\n\t ]\\|^\\)\\(?2:@[1-9a-zA-Z._-]+\\)\\b" 'mastodon-display-name-face (cdr header-region))))) -- cgit v1.2.3 From 98276c45f29d4e45955ad7649758619453423cb4 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 17 Nov 2022 14:57:23 +0100 Subject: tweak toot prop mentions regex --- lisp/mastodon-toot.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 3c4c7aa..125eeea 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1265,9 +1265,13 @@ Added to `after-change-functions'." (mastodon-toot--propertize-item "\\([\n\t ]\\|^\\)\\(?2:#[1-9a-zA-Z_]+\\)\\b" 'success (cdr header-region)) - (mastodon-toot--propertize-item "\\([\n\t ]\\|^\\)\\(?2:@[1-9a-zA-Z._-]+\\)\\b" - 'mastodon-display-name-face - (cdr header-region))))) + (mastodon-toot--propertize-item + (concat "\\([\n\t ]\\|^\\)" ; preceding space or bol + "\\(?2:@[1-9a-zA-Z._-]+" ; a handle + "\\(@[1-9a-zA-Z._-]+\\)?\\)" ; with poss domain + "\\b") ; boundary + 'mastodon-display-name-face + (cdr header-region))))) (defun mastodon-toot--propertize-item (regex face start) "Propertize item matching REGEX with FACE starting from START." -- cgit v1.2.3 From 788577427993c97302d29ee8e6fbfc841f550138 Mon Sep 17 00:00:00 2001 From: "Nicolas P. Rougier" Date: Sun, 20 Nov 2022 15:29:33 +0100 Subject: Added a user customizable symbol list --- lisp/mastodon-tl.el | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 86a7b56..0cdb421 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -106,6 +106,21 @@ width fonts when rendering HTML text")) :group 'mastodon-tl :type '(boolean :tag "Whether to display user avatars in timelines")) +;; Various symbols using throughout timeline +;; Default comes from nerd-font (www.nerdfonts.com) +(defcustom mastodon-tl-symbols '((reply . ("" . "R")) + (boost . ("" . "B")) + (favourite . ("" . "F")) + (bookmark . ("" . "K")) + (media . ("" . "M")) + (verified . ("" . "V")) + (private . ("" . "P")) + (direct . ("" . "D"))) + "Set of symbols (or strings) to be used in timeline. If a symbol does not look right (tofu), it means your font settings do not support it." + :type '(alist :key-type symbol :value-type string) + :group 'mastodon-tl) + + (defvar-local mastodon-tl--update-point nil "When updating a mastodon buffer this is where new toots will be inserted. @@ -200,6 +215,19 @@ types of mastodon links and not just shr.el-generated ones.") "The keymap to be set for the author byline. It is active where point is placed by `mastodon-tl--goto-next-toot.'") +(defun mastodon-tl--symbol (name) + "Return the unicode symbol (as a string) corresponding to NAME. + +If symbol is not displayable, an ASCII equivalent is returned. If +NAME is not part of the symbol table, '?' is returned." + + (if-let* ((symbol (alist-get name mastodon-tl-symbols))) + (if (char-displayable-p (string-to-char (car symbol))) + (car symbol) + (cdr symbol)) + "?")) + + (defun mastodon-tl--next-tab-item () "Move to the next interesting item. @@ -551,9 +579,7 @@ this just means displaying toot client." (faved (equal 't (mastodon-tl--field 'favourited toot))) (boosted (equal 't (mastodon-tl--field 'reblogged toot))) (bookmarked (equal 't (mastodon-tl--field 'bookmarked toot))) - (bookmark-str (if (fontp (char-displayable-p #10r128278)) - "🔖" - "K")) + (bookmark-str (mastodon-tl--symbol 'bookmark)) (visibility (mastodon-tl--field 'visibility toot))) (concat ;; Boosted/favourited markers are not technically part of the byline, so @@ -575,13 +601,9 @@ this just means displaying toot client." ;; in `mastodon-tl--byline-author' (funcall author-byline toot) (cond ((equal visibility "direct") - (if (fontp (char-displayable-p #10r9993)) - " ✉" - " [direct]")) + (mastodon-tl--symbol 'direct)) ((equal visibility "private") - (if (fontp (char-displayable-p #10r128274)) - " 🔒" - " [followers]"))) + (mastodon-tl--symbol 'private)) (funcall action-byline toot) " " ;; TODO: Once we have a view for toot (responses etc.) make -- cgit v1.2.3 From 25bb8619e215bdc8715aeb3f53724ad1f9af35b1 Mon Sep 17 00:00:00 2001 From: "Nicolas P. Rougier" Date: Sun, 20 Nov 2022 15:59:49 +0100 Subject: Fix a missing parenthesis & added links to default icons --- lisp/mastodon-tl.el | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 0cdb421..1a26a54 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -108,14 +108,23 @@ width fonts when rendering HTML text")) ;; Various symbols using throughout timeline ;; Default comes from nerd-font (www.nerdfonts.com) -(defcustom mastodon-tl-symbols '((reply . ("" . "R")) - (boost . ("" . "B")) - (favourite . ("" . "F")) - (bookmark . ("" . "K")) - (media . ("" . "M")) - (verified . ("" . "V")) - (private . ("" . "P")) - (direct . ("" . "D"))) +(defcustom mastodon-tl-symbols + '(;; See https://icon-sets.iconify.design/octicon/comment-24/ + (reply . ("" . "R")) + ;; See https://icon-sets.iconify.design/octicon/reply-24/ + (boost . ("" . "B")) + ;; See https://icon-sets.iconify.design/octicon/star-fill-24/ + (favourite . ("" . "F")) + ;; See https://icon-sets.iconify.design/octicon/bookmark-24/ + (bookmark . ("" . "K")) + ;; See https://icon-sets.iconify.design/octicon/file-media-24/ + (media . ("" . "M")) + ;; See https://icon-sets.iconify.design/octicon/verified-24/ + (verified . ("" . "V")) + ;; See https://icon-sets.iconify.design/octicon/person-fill-24/ + (private . ("" . "P")) + ;; See https://icon-sets.iconify.design/octicon/location-24/ + (direct . ("" . "D"))) "Set of symbols (or strings) to be used in timeline. If a symbol does not look right (tofu), it means your font settings do not support it." :type '(alist :key-type symbol :value-type string) :group 'mastodon-tl) @@ -603,7 +612,7 @@ this just means displaying toot client." (cond ((equal visibility "direct") (mastodon-tl--symbol 'direct)) ((equal visibility "private") - (mastodon-tl--symbol 'private)) + (mastodon-tl--symbol 'private))) (funcall action-byline toot) " " ;; TODO: Once we have a view for toot (responses etc.) make -- cgit v1.2.3 From 91836e01b1598923c7a6a8e17fba74ff92d2587e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 25 Nov 2022 23:48:01 +0100 Subject: toot--set-toot-lang docstring --- lisp/mastodon-toot.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 59a3813..27e7ce5 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1115,7 +1115,8 @@ LENGTH is the maximum character length allowed for a poll option." ("30 days" . ,(number-to-string (* 60 60 24 30))))) (defun mastodon-toot--set-toot-lang () - "Prompt for a language and return its two letter ISO 639 1 code." + "Prompt for a language and set `mastodon-toot--language'. +Return its two letter ISO 639 1 code." (interactive) (let* ((langs (mapcar (lambda (x) (cons (cadr x) -- cgit v1.2.3 From 0c889fd275b8338aed5f173f0a7df78e23801b92 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Nov 2022 09:34:20 +0100 Subject: paginate profile view followers/following with link header --- lisp/mastodon-profile.el | 36 ++++++++++++++++++++++++++---------- lisp/mastodon-tl.el | 23 +++++++++++++++-------- 2 files changed, 41 insertions(+), 18 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 3ba00b9..658b1d4 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -71,6 +71,9 @@ (autoload 'mastodon-tl--get-endpoint "mastodon-tl.el") (autoload 'mastodon-toot--get-max-toot-chars "mastodon-toot") (autoload 'mastodon-tl--add-account-to-list "mastodon-tl") +(autoload 'mastodon-http--get-response "mastodon-http") +(autoload 'mastodon-tl--get-link-header-from-response "mastodon-tl") +(autoload 'mastodon-tl--set-buffer-spec "mastodon-tl") (defvar mastodon-instance-url) (defvar mastodon-tl--buffer-spec) @@ -186,7 +189,9 @@ NO-REBLOGS means do not display boosts in statuses." (mastodon-profile--make-profile-buffer-for mastodon-profile--account "following" - #'mastodon-profile--add-author-bylines) + #'mastodon-profile--add-author-bylines + nil + :headers) (error "Not in a mastodon profile"))) (defun mastodon-profile--open-followers () @@ -196,7 +201,9 @@ NO-REBLOGS means do not display boosts in statuses." (mastodon-profile--make-profile-buffer-for mastodon-profile--account "followers" - #'mastodon-profile--add-author-bylines) + #'mastodon-profile--add-author-bylines + nil + :headers) (error "Not in a mastodon profile"))) (defun mastodon-profile--view-favourites () @@ -552,16 +559,25 @@ 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) + &optional no-reblogs headers) "Display profile of ACCOUNT, using ENDPOINT-TYPE and UPDATE-FUNCTION. -NO-REBLOGS means do not display boosts in statuses." +NO-REBLOGS means do not display boosts in statuses. +HEADERS means also fetch link headers for pagination." (let* ((id (mastodon-profile--account-field account 'id)) (args (when no-reblogs '(("exclude_reblogs" . "t")))) (url (mastodon-http--api (format "accounts/%s/%s" id endpoint-type))) (acct (mastodon-profile--account-field account 'acct)) (buffer (concat "*mastodon-" acct "-" endpoint-type "*")) + (response (if headers + (mastodon-http--get-response url args) + (mastodon-http--get-json url args))) + (json (if headers (car response) response)) + (endpoint (format "accounts/%s/%s" id endpoint-type)) + (link-header (when headers + (mastodon-tl--get-link-header-from-response + (cdr response)))) + (note (mastodon-profile--account-field account 'note)) - (json (mastodon-http--get-json url args)) (locked (mastodon-profile--account-field account 'locked)) (followers-count (mastodon-tl--as-string (mastodon-profile--account-field @@ -585,11 +601,11 @@ NO-REBLOGS means do not display boosts in statuses." (switch-to-buffer buffer) (mastodon-mode) (mastodon-profile-mode) - (setq mastodon-profile--account account - mastodon-tl--buffer-spec - `(buffer-name ,buffer - endpoint ,(format "accounts/%s/%s" id endpoint-type) - update-function ,update-function)) + (setq mastodon-profile--account account) + (mastodon-tl--set-buffer-spec buffer + endpoint + update-function + link-header) (let* ((inhibit-read-only t) (is-statuses (string= endpoint-type "statuses")) (is-followers (string= endpoint-type "followers")) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 1a726c4..a87cd73 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -136,10 +136,6 @@ If nil `(point-min)' is used instead.") (defvar-local mastodon-tl--timestamp-update-timer nil "The timer that, when set will scan the buffer to update the timestamps.") -(defvar mastodon-tl--link-header-buffers - '("*mastodon-favourites*" "*mastodon-bookmarks*") - "A list of buffers that use link headers for pagination.") - ;; KEYMAPS (defvar mastodon-tl--link-keymap @@ -2327,11 +2323,22 @@ For use after e.g. deleting a toot." (param (cadr split))) (concat url-base "&" param))) +(defun mastodon-tl--use-link-header-p () + "Return t if we are in a view that uses 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)))))) + (defun mastodon-tl--more () "Append older toots to timeline, asynchronously." (interactive) (message "Loading older toots...") - (if (member (buffer-name (current-buffer)) mastodon-tl--link-header-buffers) + (if (mastodon-tl--use-link-header-p) ;; link-header: can't build a URL with --more-json-async, endpoint/id: (let* ((next (car (mastodon-tl--link-header))) ;;(prev (cadr (mastodon-tl--link-header))) @@ -2532,7 +2539,7 @@ from the start if it is nil." "Initialize BUFFER-NAME with timeline targeted by ENDPOINT asynchronously. UPDATE-FUNCTION is used to recieve more toots. HEADERS means to also collect the response headers. Used for paginating -favourites." +favourites and bookmarks." (let ((url (mastodon-http--api endpoint)) (buffer (concat "*mastodon-" buffer-name "*"))) (if headers @@ -2545,8 +2552,8 @@ favourites." "Initialize BUFFER with timeline targeted by ENDPOINT. UPDATE-FUNCTION is used to recieve more toots. RESPONSE is the data returned from the server by -`mastodon-http--process-json', a cons cell of JSON and http -headers." +`mastodon-http--process-json', with arg HEADERS a cons cell of +JSON and http headers, without it just the JSON." (let* ((json (if headers (car response) response)) (headers (if headers (cdr response) nil)) (link-header (mastodon-tl--get-link-header-from-response headers))) -- cgit v1.2.3 From 14b7547c385648565eba8a4bac3dc8afa5ebf978 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Nov 2022 10:44:45 +0100 Subject: use homegrown icons in tl--symbols list --- lisp/mastodon-tl.el | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 1a26a54..7477b25 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -106,30 +106,22 @@ width fonts when rendering HTML text")) :group 'mastodon-tl :type '(boolean :tag "Whether to display user avatars in timelines")) -;; Various symbols using throughout timeline -;; Default comes from nerd-font (www.nerdfonts.com) -(defcustom mastodon-tl-symbols - '(;; See https://icon-sets.iconify.design/octicon/comment-24/ - (reply . ("" . "R")) - ;; See https://icon-sets.iconify.design/octicon/reply-24/ - (boost . ("" . "B")) - ;; See https://icon-sets.iconify.design/octicon/star-fill-24/ - (favourite . ("" . "F")) - ;; See https://icon-sets.iconify.design/octicon/bookmark-24/ - (bookmark . ("" . "K")) - ;; See https://icon-sets.iconify.design/octicon/file-media-24/ - (media . ("" . "M")) - ;; See https://icon-sets.iconify.design/octicon/verified-24/ - (verified . ("" . "V")) - ;; See https://icon-sets.iconify.design/octicon/person-fill-24/ - (private . ("" . "P")) - ;; See https://icon-sets.iconify.design/octicon/location-24/ - (direct . ("" . "D"))) - "Set of symbols (or strings) to be used in timeline. If a symbol does not look right (tofu), it means your font settings do not support it." +(defcustom mastodon-tl--symbols + '((reply . ("💬" . "R")) + (boost . ("🔁" . "B")) + (favourite . ("⭐" . "F")) + (bookmark . ("🔖" . "K")) + (media . ("" . "M")) + (verified . ("" . "V")) + (private . ("🔒" . "P")) + (direct . ("✉" . "D")) + (edited . ("✍" . "E"))) + "A set of symbols (and fallback strings) to be used in timeline. +If a symbol does not look right (tofu), it means your +font settings do not support it." :type '(alist :key-type symbol :value-type string) :group 'mastodon-tl) - (defvar-local mastodon-tl--update-point nil "When updating a mastodon buffer this is where new toots will be inserted. @@ -226,14 +218,12 @@ It is active where point is placed by `mastodon-tl--goto-next-toot.'") (defun mastodon-tl--symbol (name) "Return the unicode symbol (as a string) corresponding to NAME. - If symbol is not displayable, an ASCII equivalent is returned. If NAME is not part of the symbol table, '?' is returned." - - (if-let* ((symbol (alist-get name mastodon-tl-symbols))) - (if (char-displayable-p (string-to-char (car symbol))) - (car symbol) - (cdr symbol)) + (if-let* ((symbol (alist-get name mastodon-tl--symbols))) + (if (char-displayable-p (string-to-char (car symbol))) + (car symbol) + (cdr symbol)) "?")) -- cgit v1.2.3 From 8448f28c129662625e5c4beb98592fb9ef06032a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Nov 2022 10:58:14 +0100 Subject: cleanup --symbols, autoload --- lisp/mastodon-profile.el | 5 ++--- lisp/mastodon-tl.el | 38 +++++++------------------------------- 2 files changed, 9 insertions(+), 34 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 658b1d4..c275e5c 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -74,6 +74,7 @@ (autoload 'mastodon-http--get-response "mastodon-http") (autoload 'mastodon-tl--get-link-header-from-response "mastodon-tl") (autoload 'mastodon-tl--set-buffer-spec "mastodon-tl") +(autoload 'mastodon-tl--symbol "mastodon-tl") (defvar mastodon-instance-url) (defvar mastodon-tl--buffer-spec) @@ -628,9 +629,7 @@ HEADERS means also fetch link headers for pagination." (propertize (concat "@" acct) 'face 'default) (if (equal locked t) - (if (fontp (char-displayable-p #10r9993)) - " 🔒" - " [locked]") + (mastodon-tl--symbol 'locked) "") "\n ------------\n" ;; profile note: diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 1a5fc33..8c9e00a 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -129,9 +129,10 @@ nil." (bookmark . ("🔖" . "K")) (media . ("" . "M")) (verified . ("" . "V")) - (private . ("🔒" . "P")) - (direct . ("✉" . "D")) - (edited . ("✍" . "E"))) + (locked . ("🔒" . "[locked]")) + (private . ("🔒" . "[followers]")) + (direct . ("✉" . "[direct]")) + (edited . ("✍" . "[edited]"))) "A set of symbols (and fallback strings) to be used in timeline. If a symbol does not look right (tofu), it means your font settings do not support it." @@ -629,7 +630,6 @@ this just means displaying toot client." (faved (equal 't (mastodon-tl--field 'favourited toot))) (boosted (equal 't (mastodon-tl--field 'reblogged toot))) (bookmarked (equal 't (mastodon-tl--field 'bookmarked toot))) - (bookmark-str (mastodon-tl--symbol 'bookmark)) (visibility (mastodon-tl--field 'visibility toot)) (account (alist-get 'account toot)) (avatar-url (alist-get 'avatar account)) @@ -645,13 +645,13 @@ this just means displaying toot client." ;; the toot having just been favourited/boosted. (concat (when boosted (mastodon-tl--format-faved-or-boosted-byline - (mastodon-tl--return-boost-char))) + (mastodon-tl--symbol 'boost))) (when faved (mastodon-tl--format-faved-or-boosted-byline - (mastodon-tl--return-fave-char))) + (mastodon-tl--symbol 'favourite))) (when bookmarked (mastodon-tl--format-faved-or-boosted-byline - (mastodon-tl--return-bookmark-char)))) + (mastodon-tl--symbol 'bookmark)))) ;; we remove avatars from the byline also, so that they also do not mess ;; with `mastodon-tl--goto-next-toot': (when (and mastodon-tl--show-avatars @@ -718,30 +718,6 @@ this just means displaying toot client." (mastodon-toot--get-toot-edits (alist-get 'id toot))) 'byline t)))) -(defun mastodon-tl--return-boost-char () - "" - (cond - ((fontp (char-displayable-p #10r128257)) - "🔁") - (t - "B"))) - -(defun mastodon-tl--return-fave-char () - "" - (cond - ((fontp (char-displayable-p #10r11088)) - "⭐") - ((fontp (char-displayable-p #10r9733)) - "★") - (t - "F"))) - -(defun mastodon-tl--return-bookmark-char () - "" - (if (fontp (char-displayable-p #10r128278)) - "🔖" - "K")) - (defun mastodon-tl--format-edit-timestamp (timestamp) "Convert edit TIMESTAMP into a descriptive string." (let ((parsed (ts-human-duration -- cgit v1.2.3 From 217af69c12d4472d308e2aec6cdd78045d70d97b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Nov 2022 11:22:10 +0100 Subject: symbols: preceding space for locked accounts, private/direct toots --- lisp/mastodon-profile.el | 2 +- lisp/mastodon-tl.el | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index c275e5c..54f0e84 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -629,7 +629,7 @@ HEADERS means also fetch link headers for pagination." (propertize (concat "@" acct) 'face 'default) (if (equal locked t) - (mastodon-tl--symbol 'locked) + (concat " " (mastodon-tl--symbol 'locked)) "") "\n ------------\n" ;; profile note: diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 8c9e00a..aa34c2e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -667,9 +667,9 @@ this just means displaying toot client." (funcall author-byline toot) ;; visibility: (cond ((equal visibility "direct") - (mastodon-tl--symbol 'direct)) + (concat " " (mastodon-tl--symbol 'direct))) ((equal visibility "private") - (mastodon-tl--symbol 'private))) + (concat " " (mastodon-tl--symbol 'private)))) (funcall action-byline toot) " " ;; TODO: Once we have a view for toot (responses etc.) make -- cgit v1.2.3 From 0bee7050dd608c33b599434e17ce9229ce8ea3a0 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Nov 2022 11:31:20 +0100 Subject: always use mastodon-tl--symbol --- lisp/mastodon-tl.el | 6 +++--- lisp/mastodon-toot.el | 38 ++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 23 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index aa34c2e..fc3dc2e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -697,9 +697,9 @@ this just means displaying toot client." 'keymap mastodon-tl--shr-map-replacement))))) (if edited-time (concat - (if (fontp (char-displayable-p #10r128274)) - " ✍ " - " [edited] ") + " " + (mastodon-tl--symbol 'edited) + " " (propertize (format-time-string mastodon-toot-timestamp-format edited-parsed) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 27e7ce5..c99f088 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -78,7 +78,7 @@ (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--return-fave-char "mastodon-tl") +(autoload 'mastodon-tl--symbol "mastodon-tl") ;; for mastodon-toot--translate-toot-text (autoload 'mastodon-tl--content "mastodon-tl") @@ -345,8 +345,8 @@ TYPE is a symbol, either 'favourite or 'boost." (list 'favourited-p (not faved)))) (mastodon-toot--action-success (if boost-p - (mastodon-tl--return-boost-char) - (mastodon-tl--return-fave-char)) + (mastodon-tl--symbol 'boost) + (mastodon-tl--symbol 'favourite)) byline-region remove)) (message (format "%s #%s" (if boost-p msg action) id)))))) (message (format "Nothing to %s here?!?" action-string))))) @@ -366,23 +366,21 @@ TYPE is a symbol, either 'favourite or 'boost." "Bookmark or unbookmark toot at point." (interactive) (let* ( ;(toot (mastodon-tl--property 'toot-json)) - (id (mastodon-tl--property 'base-toot-id)) - ;; (mastodon-tl--as-string (mastodon-tl--toot-id toot))) - (bookmarked-p (mastodon-tl--property 'bookmarked-p)) - (prompt (if bookmarked-p - (format "Toot already bookmarked. Remove? ") - (format "Bookmark this toot? "))) - (byline-region - (when id - (mastodon-tl--find-property-range 'byline (point)))) - (action (if bookmarked-p "unbookmark" "bookmark")) - (bookmark-str (if (fontp (char-displayable-p #10r128278)) - "🔖" - "K")) - (message (if bookmarked-p - "Bookmark removed!" - "Toot bookmarked!")) - (remove (when bookmarked-p t))) + (id (mastodon-tl--property 'base-toot-id)) + ;; (mastodon-tl--as-string (mastodon-tl--toot-id toot))) + (bookmarked-p (mastodon-tl--property 'bookmarked-p)) + (prompt (if bookmarked-p + (format "Toot already bookmarked. Remove? ") + (format "Bookmark this toot? "))) + (byline-region + (when id + (mastodon-tl--find-property-range 'byline (point)))) + (action (if bookmarked-p "unbookmark" "bookmark")) + (bookmark-str (mastodon-tl--symbol 'bookmark)) + (message (if bookmarked-p + "Bookmark removed!" + "Toot bookmarked!")) + (remove (when bookmarked-p t))) (if byline-region (when (y-or-n-p prompt) (mastodon-toot--action -- cgit v1.2.3 From 8ee5b29c10a128b8268ddac82c96154d9b0208c1 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Nov 2022 11:52:25 +0100 Subject: tl--symbol -- add media icon --- lisp/mastodon-tl.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index fc3dc2e..ce2062d 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -127,7 +127,7 @@ nil." (boost . ("🔁" . "B")) (favourite . ("⭐" . "F")) (bookmark . ("🔖" . "K")) - (media . ("" . "M")) + (media . ("📹" . "[media]")) (verified . ("" . "V")) (locked . ("🔒" . "[locked]")) (private . ("🔒" . "[followers]")) -- cgit v1.2.3 From ae8f6c6d7dfdd8048c8bab21b3afd81f981fbc96 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Nov 2022 14:51:45 +0100 Subject: always use --set-buffer-spec, not setq --buffer-spec --- lisp/mastodon-async.el | 13 +++++-------- lisp/mastodon-search.el | 19 ++++++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-async.el b/lisp/mastodon-async.el index 8a08416..58e7b93 100644 --- a/lisp/mastodon-async.el +++ b/lisp/mastodon-async.el @@ -229,14 +229,11 @@ ENDPOINT is the endpoint for the stream and timeline." (mastodon-tl--timeline (mastodon-http--get-json (mastodon-http--api endpoint)))) (mastodon-mode) - (setq mastodon-tl--buffer-spec - `(buffer-name - ,buffer-name - endpoint ,endpoint - update-function - ,(if (equal name "notifications") - 'mastodon-notifications--timeline - 'mastodon-tl--timeline))) + (mastodon-tl--set-buffer-spec buffer-name + endpoint + ,(if (equal name "notifications") + 'mastodon-notifications--timeline + 'mastodon-tl--timeline)) (setq-local mastodon-tl--enable-relative-timestamps nil) (setq-local mastodon-tl--display-media-p t) (current-buffer)))) diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 65c5aba..4aa5721 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -40,12 +40,13 @@ (autoload 'mastodon-auth--access-token "mastodon-auth") (autoload 'mastodon-http--get-search-json "mastodon-http") (autoload 'mastodon-http--api "mastodon-http") +(autoload 'mastodon-tl--set-buffer-spec "mastodon-tl") + (defvar mastodon-toot--completion-style-for-mentions) (defvar mastodon-instance-url) (defvar mastodon-tl--link-keymap) (defvar mastodon-http--timeout) (defvar mastodon-toot--enable-completion-for-mentions) -(defvar mastodon-tl--buffer-spec) ;; functions for completion of mentions in mastodon-toot @@ -101,11 +102,9 @@ QUERY is the string to search." (mastodon-mode) (let ((inhibit-read-only t)) (erase-buffer) - (setq mastodon-tl--buffer-spec - `(buffer-name ,buffer - endpoint ,(format "api/v1/trends") - update-function - (lambda (toot) (message "Trends.")))) + (mastodon-tl--set-buffer-spec buffer + "api/v1/trends" + nil) ;; hashtag results: (insert (mastodon-tl--set-face (concat "\n ------------\n" @@ -141,11 +140,9 @@ QUERY is the string to search." (mastodon-mode) (let ((inhibit-read-only t)) (erase-buffer) - (setq mastodon-tl--buffer-spec - `(buffer-name ,buffer - endpoint ,(format "api/v2/search") - update-function - (lambda (toot) (message "Searched.")))) + (mastodon-tl--set-buffer-spec buffer + "api/v2/search" + nil) ;; user results: (insert (mastodon-tl--set-face (concat "\n ------------\n" -- cgit v1.2.3 From c6281d6579cdcae5d2e1200a35b4f09a4406496e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Nov 2022 15:08:32 +0100 Subject: remove --view-author-profile, replace with --get-toot-author --- lisp/mastodon-profile.el | 8 -------- lisp/mastodon-tl.el | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 54f0e84..91103f1 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -737,14 +737,6 @@ IMG_TYPE is the JSON key from the account data." (message "Loading your profile...") (mastodon-profile--show-user (mastodon-auth--get-account-name))) -(defun mastodon-profile--view-author-profile () - "View the profile of author of present toot." - (interactive) - (let* ((toot-json (mastodon-tl--property 'toot-json)) - (acct (alist-get 'account toot-json)) - (handle (alist-get 'acct acct))) - (mastodon-profile--show-user handle))) - (defun mastodon-profile--account-field (account field) "Return FIELD from the ACCOUNT. FIELD is used to identify regions under 'account" diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index ce2062d..dccf36a 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -254,7 +254,7 @@ types of mastodon links and not just shr.el-generated ones.") (when (require 'mpv nil :no-error) (let ((map (make-sparse-keymap))) (define-key map (kbd "") 'mastodon-tl--mpv-play-video-from-byline) - (define-key map (kbd "") 'mastodon-profile--view-author-profile) + (define-key map (kbd "") 'mastodon-profile--get-toot-author) (keymap-canonicalize map))) "The keymap to be set for the author byline. It is active where point is placed by `mastodon-tl--goto-next-toot.'") -- cgit v1.2.3 From 8c3f5435b977c04edbe86015ecdf7f9ba181e80e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Nov 2022 15:20:02 +0100 Subject: --set-buffer-spec everywhere(?) and include handle/instance url set buffer spec in view instances description --- lisp/mastodon-profile.el | 9 ++++++++- lisp/mastodon-tl.el | 13 +++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 91103f1..6dbe572 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -287,7 +287,8 @@ JSON is the data returned by the server." (defun mastodon-profile--update-user-profile-note () "Fetch user's profile note and display for editing." (interactive) - (let* ((url (mastodon-http--api "accounts/verify_credentials")) + (let* ((endpoint "accounts/verify_credentials") + (url (mastodon-http--api endpoint)) (json (mastodon-http--get-json url)) (source (alist-get 'source json)) (note (alist-get 'note source)) @@ -295,6 +296,9 @@ JSON is the data returned by the server." (inhibit-read-only t)) (switch-to-buffer-other-window buffer) (text-mode) + (mastodon-tl--set-buffer-spec (buffer-name buffer) + endpoint + nil) (setq-local header-line-format (propertize "Edit your profile note. C-c C-c to send, C-c C-k to cancel." @@ -497,6 +501,9 @@ This endpoint only holds a few preferences. For others, see (switch-to-buffer-other-window buf) (erase-buffer) (special-mode) + (mastodon-tl--set-buffer-spec (buffer-name buf) + "preferences" + nil) (let ((inhibit-read-only t)) (while response (let ((el (pop response))) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index dccf36a..b019272 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1368,10 +1368,12 @@ BUFFER is buffer name, ENDPOINT is buffer's enpoint, UPDATE-FUNCTION is its update function. LINK-HEADER is the http Link header if present." (setq mastodon-tl--buffer-spec - `(buffer-name ,buffer - endpoint ,endpoint - update-function ,update-function - link-header ,link-header))) + `(account ,(cons mastodon-active-user + mastodon-instance-url) + buffer-name ,buffer + endpoint ,endpoint + update-function ,update-function + link-header ,link-header))) (defun mastodon-tl--more-json (endpoint id) "Return JSON for timeline ENDPOINT before ID." @@ -1951,6 +1953,9 @@ INSTANCE is an instance domain name." (let ((buf (get-buffer-create "*mastodon-instance*"))) (with-current-buffer buf (switch-to-buffer-other-window buf) + (mastodon-tl--set-buffer-spec (buffer-name buf) + "instance" + nil) (let ((inhibit-read-only t)) (erase-buffer) (special-mode) -- cgit v1.2.3 From 75896755e97a75523eb9e4a8aef3d30350c30299 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Nov 2022 15:31:38 +0100 Subject: no lambdas allowed in buffer-spec update-function! --- lisp/mastodon-profile.el | 1 - lisp/mastodon-tl.el | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 6dbe572..1200972 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -584,7 +584,6 @@ HEADERS means also fetch link headers for pagination." (link-header (when headers (mastodon-tl--get-link-header-from-response (cdr response)))) - (note (mastodon-profile--account-field account 'note)) (locked (mastodon-profile--account-field account 'locked)) (followers-count (mastodon-tl--as-string diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index b019272..f02593c 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1453,7 +1453,7 @@ ID is that of the toot to view." (mastodon-mode) (mastodon-tl--set-buffer-spec buffer (format "statuses/%s" id) - (lambda (_toot) (message "END of thread."))) + nil) (let ((inhibit-read-only t)) (mastodon-tl--toot toot :detailed-p)))))) @@ -1493,7 +1493,7 @@ ID is that of the toot to view." (mastodon-tl--set-buffer-spec buffer (format "statuses/%s/context" id) - (lambda (_toot) (message "END of thread."))) + 'mastodon-tl--thread) (let ((inhibit-read-only t)) (mastodon-tl--timeline (alist-get 'ancestors context)) (goto-char (point-max)) -- cgit v1.2.3