From a46d541c7895320efeeb1ecb23dc73c3d78e7c01 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 Feb 2023 22:38:56 +0100 Subject: update readme bindings --- README.org | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 608d279..71eb52c 100644 --- a/README.org +++ b/README.org @@ -167,12 +167,13 @@ not contain =:client_id= and =:client_secret=. |----------------+---------------------------------------------------------------------------| | | *Notifications view* | | =a=, =j= | accept/reject follow request | -| =c= | clear notification at point | +| =C-k= | clear notification at point | | | see =mastodon-notifications--get-*= functions for filtered views | |----------------+---------------------------------------------------------------------------| | | *Quitting* | | =q= | Quit mastodon buffer, leave window open | | =Q= | Quit mastodon buffer and kill window | +| =C-M-q= | Quit and kill all mastodon buffers | |----------------+---------------------------------------------------------------------------| **** Toot byline legend -- cgit v1.2.3 From 6eb7c27bef937ec76f3dba0ae19b57de4561bf8f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 1 Mar 2023 22:33:38 +0100 Subject: FIX #398 -- bad if from bad brackets in --more --- lisp/mastodon-tl.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index ba6b1df..8197315 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2789,12 +2789,12 @@ when showing followers or accounts followed." ;;(prev (cadr (mastodon-tl--link-header))) (url (mastodon-tl--build-link-header-url next))) (mastodon-http--get-response-async url nil 'mastodon-tl--more* (current-buffer) - (point) :headers)) - (mastodon-tl--more-json-async - (mastodon-tl--get-endpoint) - (mastodon-tl--oldest-id) - (mastodon-tl--update-params) - 'mastodon-tl--more* (current-buffer) (point)))))) + (point) :headers)))) + (mastodon-tl--more-json-async + (mastodon-tl--get-endpoint) + (mastodon-tl--oldest-id) + (mastodon-tl--update-params) + 'mastodon-tl--more* (current-buffer) (point)))) (defun mastodon-tl--more* (response buffer point-before &optional headers) "Append older toots to timeline, asynchronously. -- cgit v1.2.3 From 1e2fd43dbc1f6a4dbea74900ed67e9f328798603 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 5 Mar 2023 13:45:16 +0100 Subject: view-instance: include domain in buffer name --- lisp/mastodon-tl.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 8197315..b18ddc0 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2341,11 +2341,13 @@ INSTANCE is an instance domain name." :vector))) (mastodon-tl--instance-response-fun response brief))))) -(defun mastodon-tl--instance-response-fun (response brief) +(defun mastodon-tl--instance-response-fun (response brief instance) "Display instance description RESPONSE in a new buffer. BRIEF means to show fewer details." (when response - (let ((buf (get-buffer-create "*mastodon-instance*"))) + (let ((domain (url-file-nondirectory instance)) + (buf (get-buffer-create + (format "*mastodon-instance-%s*" domain)))) (with-current-buffer buf (switch-to-buffer-other-window buf) (let ((inhibit-read-only t)) -- cgit v1.2.3 From 170864113ea5ce459e86446464087ad8e0b7fa12 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 7 Mar 2023 14:24:38 +0100 Subject: bind list-followed tags to ':' --- lisp/mastodon.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index a49d0cc..271e772 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -211,6 +211,7 @@ Use. e.g. \"%c\" for your locale's date and time format." (define-key map (kbd "s") #'mastodon-tl--view-scheduled-toots) (define-key map (kbd "M-C-q") #'mastodon-kill-all-buffers) (define-key map (kbd ";") #'mastodon-tl--view-instance-description) + (define-key map (kbd ":") #'mastodon-tl--list-followed-tags) (define-key map (kbd ",") #'mastodon-toot--list-toot-favouriters) (define-key map (kbd ".") #'mastodon-toot--list-toot-boosters) map) -- cgit v1.2.3 From 742414c5c08e4b11e34ec5b231f622fb6cfffd8a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 8 Mar 2023 23:25:58 +0100 Subject: replace with-output-to-temp-buffer with with-current-buffer calls --- lisp/mastodon-profile.el | 165 ++++++++++++++++++++++++----------------------- lisp/mastodon-tl.el | 158 ++++++++++++++++++++++----------------------- 2 files changed, 162 insertions(+), 161 deletions(-) diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 8d8d0c7..2607b82 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -658,89 +658,90 @@ HEADERS means also fetch link headers for pagination." (fields (mastodon-profile--fields-get account)) (pinned (mastodon-profile--get-statuses-pinned account)) (joined (mastodon-profile--account-field account 'created_at))) - (with-output-to-temp-buffer buffer - (switch-to-buffer buffer) - (mastodon-mode) - (mastodon-profile-mode) - (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")) - (is-following (string= endpoint-type "following")) - (endpoint-name (cond - (is-statuses " TOOTS ") - (is-followers " FOLLOWERS ") - (is-following " FOLLOWING ")))) - (insert - (propertize - (concat - "\n" - (mastodon-profile--image-from-account account 'avatar_static) - (mastodon-profile--image-from-account account 'header_static) - "\n" - (propertize (mastodon-profile--account-field - account 'display_name) - 'face 'mastodon-display-name-face) - "\n" - (propertize (concat "@" acct) - 'face 'default) - (if (equal locked t) - (concat " " (mastodon-tl--symbol 'locked)) - "") - "\n ------------\n" - ;; profile note: - ;; account here to enable tab-stops in profile note - (mastodon-tl--render-text note account) - ;; meta fields: - (if fields - (concat "\n" - (mastodon-tl--set-face - (mastodon-profile--fields-insert fields) - 'success)) - "") - "\n" - ;; Joined date: + (with-current-buffer (get-buffer-create buffer) + (let ((inhibit-read-only t)) + (switch-to-buffer buffer) + (mastodon-mode) + (mastodon-profile-mode) + (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")) + (is-following (string= endpoint-type "following")) + (endpoint-name (cond + (is-statuses " TOOTS ") + (is-followers " FOLLOWERS ") + (is-following " FOLLOWING ")))) + (insert (propertize - (mastodon-profile--format-joined-date-string joined) - 'face 'success) - "\n\n") - 'profile-json account) - ;; insert counts - (mastodon-tl--set-face - (concat " ------------\n" - " TOOTS: " toots-count " | " - "FOLLOWERS: " followers-count " | " - "FOLLOWING: " following-count "\n" - " ------------\n\n") - 'success) - ;; insert relationship (follows) - (if followsp - (mastodon-tl--set-face - (concat (if (equal follows-you 't) - " | FOLLOWS YOU") - (if (equal followed-by-you 't) - " | FOLLOWED BY YOU") - "\n\n") - 'success) - "") ; if no followsp we still need str-or-char-p for insert - ;; insert endpoint - (mastodon-tl--set-face - (concat " ------------\n" - endpoint-name "\n" - " ------------\n") - 'success)) - (setq mastodon-tl--update-point (point)) - (mastodon-media--inline-images (point-min) (point)) - ;; insert pinned toots first - (when (and pinned (equal endpoint-type "statuses")) - (mastodon-profile--insert-statuses-pinned pinned) - (setq mastodon-tl--update-point (point))) ;updates to follow pinned toots - (funcall update-function json))) - (goto-char (point-min)))) + (concat + "\n" + (mastodon-profile--image-from-account account 'avatar_static) + (mastodon-profile--image-from-account account 'header_static) + "\n" + (propertize (mastodon-profile--account-field + account 'display_name) + 'face 'mastodon-display-name-face) + "\n" + (propertize (concat "@" acct) + 'face 'default) + (if (equal locked t) + (concat " " (mastodon-tl--symbol 'locked)) + "") + "\n ------------\n" + ;; profile note: + ;; account here to enable tab-stops in profile note + (mastodon-tl--render-text note account) + ;; meta fields: + (if fields + (concat "\n" + (mastodon-tl--set-face + (mastodon-profile--fields-insert fields) + 'success)) + "") + "\n" + ;; Joined date: + (propertize + (mastodon-profile--format-joined-date-string joined) + 'face 'success) + "\n\n") + 'profile-json account) + ;; insert counts + (mastodon-tl--set-face + (concat " ------------\n" + " TOOTS: " toots-count " | " + "FOLLOWERS: " followers-count " | " + "FOLLOWING: " following-count "\n" + " ------------\n\n") + 'success) + ;; insert relationship (follows) + (if followsp + (mastodon-tl--set-face + (concat (if (equal follows-you 't) + " | FOLLOWS YOU") + (if (equal followed-by-you 't) + " | FOLLOWED BY YOU") + "\n\n") + 'success) + "") ; if no followsp we still need str-or-char-p for insert + ;; insert endpoint + (mastodon-tl--set-face + (concat " ------------\n" + endpoint-name "\n" + " ------------\n") + 'success)) + (setq mastodon-tl--update-point (point)) + (mastodon-media--inline-images (point-min) (point)) + ;; insert pinned toots first + (when (and pinned (equal endpoint-type "statuses")) + (mastodon-profile--insert-statuses-pinned pinned) + (setq mastodon-tl--update-point (point))) ;updates to follow pinned toots + (funcall update-function json))) + (goto-char (point-min))))) (defun mastodon-profile--format-joined-date-string (joined) "Format a human-readable Joined string from timestamp JOINED." diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index b18ddc0..0309d20 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1646,14 +1646,15 @@ ID is that of the toot to view." (mastodon-http--api (concat "statuses/" id))))) (if (equal (caar toot) 'error) (message "Error: %s" (cdar toot)) - (with-output-to-temp-buffer buffer - (switch-to-buffer buffer) - (mastodon-mode) - (mastodon-tl--set-buffer-spec buffer - (format "statuses/%s" id) - nil) + (with-current-buffer (get-buffer-create buffer) (let ((inhibit-read-only t)) - (mastodon-tl--toot toot :detailed-p)))))) + (switch-to-buffer buffer) + (mastodon-mode) + (mastodon-tl--set-buffer-spec buffer + (format "statuses/%s" id) + nil) + (let ((inhibit-read-only t)) + (mastodon-tl--toot toot :detailed-p))))))) (defun mastodon-tl--view-whole-thread () "From a thread view, view entire thread. @@ -1698,13 +1699,13 @@ view all branches of a thread." 0) ;; if we have a thread: (progn - (with-output-to-temp-buffer buffer - (switch-to-buffer buffer) - (mastodon-mode) - (mastodon-tl--set-buffer-spec buffer - endpoint - #'mastodon-tl--thread) + (with-current-buffer (get-buffer-create buffer) (let ((inhibit-read-only t)) + (switch-to-buffer buffer) + (mastodon-mode) + (mastodon-tl--set-buffer-spec buffer + endpoint + #'mastodon-tl--thread) (mastodon-tl--timeline (alist-get 'ancestors context)) (goto-char (point-max)) (move-marker marker (point)) @@ -1717,7 +1718,6 @@ view all branches of a thread." ;; else just print the lone toot: (mastodon-tl--single-toot id))))))) - (defun mastodon-tl--mute-thread () "Mute the thread displayed in the current buffer. Note that you can only (un)mute threads you have posted in." @@ -3048,43 +3048,43 @@ JSON and http headers, without it just the JSON." (message "Looks like nothing returned from endpoint: %s" endpoint) (let* ((headers (if headers (cdr response) nil)) (link-header (mastodon-tl--get-link-header-from-response headers))) - (with-output-to-temp-buffer buffer - (switch-to-buffer buffer) - ;; mastodon-mode wipes buffer-spec, so order must unforch be: - ;; 1 run update-function, 2 enable masto-mode, 3 set buffer spec. - ;; which means we cannot use buffer-spec for update-function - ;; unless we set it both before and after the others - (mastodon-tl--set-buffer-spec buffer - endpoint - update-function - link-header - update-params - hide-replies) - (setq - ;; Initialize with a minimal interval; we re-scan at least once - ;; every 5 minutes to catch any timestamps we may have missed - mastodon-tl--timestamp-next-update (time-add (current-time) - (seconds-to-time 300))) - (funcall update-function json)) - (mastodon-mode) - (with-current-buffer buffer - (mastodon-tl--set-buffer-spec buffer - endpoint - update-function - link-header - update-params - hide-replies) - (setq mastodon-tl--timestamp-update-timer - (when mastodon-tl--enable-relative-timestamps - (run-at-time (time-to-seconds - (time-subtract mastodon-tl--timestamp-next-update - (current-time))) - nil ;; don't repeat - #'mastodon-tl--update-timestamps-callback - (current-buffer) - nil))) - (unless (mastodon-tl--profile-buffer-p) - (mastodon-tl--goto-first-item))))))) + (with-current-buffer (get-buffer-create buffer) + (let ((inhibit-read-only t)) + (switch-to-buffer buffer) + ;; mastodon-mode wipes buffer-spec, so order must unforch be: + ;; 1 run update-function, 2 enable masto-mode, 3 set buffer spec. + ;; which means we cannot use buffer-spec for update-function + ;; unless we set it both before and after the others + (mastodon-tl--set-buffer-spec buffer + endpoint + update-function + link-header + update-params + hide-replies) + (setq + ;; Initialize with a minimal interval; we re-scan at least once + ;; every 5 minutes to catch any timestamps we may have missed + mastodon-tl--timestamp-next-update (time-add (current-time) + (seconds-to-time 300))) + (funcall update-function json) + (mastodon-mode) + (mastodon-tl--set-buffer-spec buffer + endpoint + update-function + link-header + update-params + hide-replies) + (setq mastodon-tl--timestamp-update-timer + (when mastodon-tl--enable-relative-timestamps + (run-at-time (time-to-seconds + (time-subtract mastodon-tl--timestamp-next-update + (current-time))) + nil ;; don't repeat + #'mastodon-tl--update-timestamps-callback + (current-buffer) + nil))) + (unless (mastodon-tl--profile-buffer-p) + (mastodon-tl--goto-first-item)))))))) (defun mastodon-tl--init-sync (buffer-name endpoint update-function &optional note-type) "Initialize BUFFER-NAME with timeline targeted by ENDPOINT. @@ -3100,34 +3100,34 @@ Optional arg NOTE-TYPE means only get that type of note." (url (mastodon-http--api endpoint)) (buffer (concat "*mastodon-" buffer-name "*")) (json (mastodon-http--get-json url args))) - (with-output-to-temp-buffer buffer - (switch-to-buffer buffer) - ;; mastodon-mode wipes buffer-spec, so order must unforch be: - ;; 1 run update-function, 2 enable masto-mode, 3 set buffer spec. - ;; which means we cannot use buffer-spec for update-function - ;; unless we set it both before and after the others - (mastodon-tl--set-buffer-spec buffer endpoint update-function) - (setq - ;; Initialize with a minimal interval; we re-scan at least once - ;; every 5 minutes to catch any timestamps we may have missed - mastodon-tl--timestamp-next-update (time-add (current-time) - (seconds-to-time 300))) - (funcall update-function json)) - (mastodon-mode) - (with-current-buffer buffer - (mastodon-tl--set-buffer-spec buffer endpoint update-function nil args) - (setq mastodon-tl--timestamp-update-timer - (when mastodon-tl--enable-relative-timestamps - (run-at-time (time-to-seconds - (time-subtract mastodon-tl--timestamp-next-update - (current-time))) - nil ;; don't repeat - #'mastodon-tl--update-timestamps-callback - (current-buffer) - nil))) - (unless (mastodon-tl--profile-buffer-p) - (mastodon-tl--goto-first-item))) - buffer)) + (with-current-buffer (get-buffer-create buffer) + (let ((inhibit-read-only t)) + (switch-to-buffer buffer) + ;; mastodon-mode wipes buffer-spec, so order must unforch be: + ;; 1 run update-function, 2 enable masto-mode, 3 set buffer spec. + ;; which means we cannot use buffer-spec for update-function + ;; unless we set it both before and after the others + (mastodon-tl--set-buffer-spec buffer endpoint update-function) + (setq + ;; Initialize with a minimal interval; we re-scan at least once + ;; every 5 minutes to catch any timestamps we may have missed + mastodon-tl--timestamp-next-update (time-add (current-time) + (seconds-to-time 300))) + (funcall update-function json) + (mastodon-mode) + (mastodon-tl--set-buffer-spec buffer endpoint update-function nil args) + (setq mastodon-tl--timestamp-update-timer + (when mastodon-tl--enable-relative-timestamps + (run-at-time (time-to-seconds + (time-subtract mastodon-tl--timestamp-next-update + (current-time))) + nil ;; don't repeat + #'mastodon-tl--update-timestamps-callback + (current-buffer) + nil))) + (unless (mastodon-tl--profile-buffer-p) + (mastodon-tl--goto-first-item))) + buffer))) (provide 'mastodon-tl) ;;; mastodon-tl.el ends here -- cgit v1.2.3 From 8b3a5dd807b363700b995b42aa43c93a4089c19e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 10 Mar 2023 15:12:21 +0100 Subject: notifs-get: force set kmap in buffer --- lisp/mastodon.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 271e772..04773c7 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -294,7 +294,8 @@ BUFFER-NAME is added to \"*mastodon-\" to create the buffer name." "notifications" 'mastodon-notifications--timeline type) - (use-local-map mastodon-notifications--map)))) + (with-current-buffer buffer + (use-local-map mastodon-notifications--map))))) ;; URL lookup: should be available even if `mastodon.el' not loaded: -- cgit v1.2.3 From bf4eef8b2d85b7b4cde69a87b0f265b9d40f1cad Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 10 Mar 2023 15:12:43 +0100 Subject: notifs-get: fix buffer name setting --- lisp/mastodon.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 04773c7..e70beb5 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -283,8 +283,9 @@ If REPLY-JSON is the json of the toot being replied to." Optionally only print notifications of type TYPE, a string. BUFFER-NAME is added to \"*mastodon-\" to create the buffer name." (interactive) - (let ((buffer (or (concat "*mastodon-" buffer-name "*") - "*mastodon-notifications*"))) + (let ((buffer (if buffer-name + (concat "*mastodon-" buffer-name "*") + "*mastodon-notifications*"))) (if (get-buffer buffer) (progn (switch-to-buffer buffer) (mastodon-tl--update)) -- cgit v1.2.3 From 15ad9d08dcd11795986fac0cade255306dfb9e96 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 10 Mar 2023 19:43:40 +0100 Subject: mastodon-toot-mode-hook: disable auto-fill. also readme --- README.org | 13 ++++++++++++- lisp/mastodon-toot.el | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 71eb52c..0e99564 100644 --- a/README.org +++ b/README.org @@ -190,7 +190,7 @@ not contain =:client_id= and =:client_secret=. =M-x mastodon-toot= (or =t= from a mastodon.el buffer). -Pops a new buffer/window in =mastodon-toot= minor mode. Enter the +Pops a new buffer/window in =text-mode= and =mastodon-toot= minor mode. Enter the contents of your toot here. =C-c C-c= sends the toot. =C-c C-k= cancels. Both actions kill the buffer and window. @@ -203,6 +203,17 @@ Server's max toot length, and attachment previews, are shown. You can download and use your instance's custom emoji (=mastodon-toot--download-custom-emoji=, =mastodon-toot--enable-custom-emoji=). +The compose buffer uses =text-mode= so any configuration you have for that mode +will be enabled. If any of your existing config conflicts with =mastodon-toot=, +you can disable it in the =mastodon-toot-mode-hook=. For example, the default +value of that hook is as follows: + +#+begin_src emacs-lisp +(add-hook 'mastodon-toot-mode-hook + (lambda () + (auto-fill-mode -1))) +#+end_src + **** Keybindings |---------+----------------------------------| diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 2625695..b8930b0 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1654,6 +1654,11 @@ EDIT means we are editing an existing toot, not composing a new one." ;;;###autoload (add-hook 'mastodon-toot-mode-hook #'mastodon-profile--fetch-server-account-settings-maybe) +;; disable auto-fill-mode: +(add-hook 'mastodon-toot-mode-hook + (lambda () + (auto-fill-mode -1))) + (define-minor-mode mastodon-toot-mode "Minor mode to capture Mastodon toots." :group 'mastodon-toot -- cgit v1.2.3