From 445d176b2a593a87afd3f6bca717feba639dfbdc Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Sat, 6 Jan 2024 12:32:57 +0100 Subject: Replace 'switch-to-buffer' with 'display-buffer' or 'pop-to-buffer' This allows user to customize how buffers get shown using 'display-buffer-alist'. Also refactors mastodon-auth--show-notice. --- lisp/mastodon.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index bac4d67..c9c3b64 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -289,7 +289,7 @@ See `mastodon-toot-display-orig-in-reply-buffer'.") (buffer-list))))) ; catch any other masto buffer (mastodon-return-credential-account :force) (if buffer - (switch-to-buffer buffer) + (display-buffer buffer) (mastodon-tl--get-home-timeline) (message "Loading Mastodon account %s on %s..." (mastodon-auth--user-acct) @@ -335,7 +335,7 @@ from the server and load anew." "*mastodon-notifications*"))) (if (and (not force) (get-buffer buffer)) - (progn (switch-to-buffer buffer) + (progn (display-buffer buffer) (mastodon-tl--update)) (message "Loading your notifications...") (mastodon-tl--init-sync (or buffer-name "notifications") -- cgit v1.2.3 From 6a5152b6cbbf69c46720732a847ca47504bf213f Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Sat, 6 Jan 2024 12:54:27 +0100 Subject: Use 'read-buffer' to choose a buffer --- lisp/mastodon.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index c9c3b64..2ab3bc3 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -433,10 +433,12 @@ Calls `mastodon-tl--get-buffer-type', which see." (defun mastodon-switch-to-buffer () "Switch to a live mastodon buffer." (interactive) - (let* ((bufs (mastodon-live-buffers)) - (buf-names (mapcar #'buffer-name bufs)) - (choice (completing-read "Switch to mastodon buffer: " - buf-names))) + (let ((choice (read-buffer + "Switch to mastodon buffer: " nil t + (lambda (cand) + (with-current-buffer + (if (stringp cand) cand (car cand)) + (mastodon-tl--get-buffer-type)))))) (switch-to-buffer choice))) (defun mastodon-mode-hook-fun () -- cgit v1.2.3 From 3d558edff6ae59e487b2bfe189ff4445841c5604 Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Sun, 7 Jan 2024 09:17:55 +0100 Subject: Tweak display actions to better preserve defaults --- lisp/mastodon.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 2ab3bc3..20b252f 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -289,7 +289,7 @@ See `mastodon-toot-display-orig-in-reply-buffer'.") (buffer-list))))) ; catch any other masto buffer (mastodon-return-credential-account :force) (if buffer - (display-buffer buffer) + (display-buffer buffer '(display-buffer-same-window)) (mastodon-tl--get-home-timeline) (message "Loading Mastodon account %s on %s..." (mastodon-auth--user-acct) @@ -335,7 +335,7 @@ from the server and load anew." "*mastodon-notifications*"))) (if (and (not force) (get-buffer buffer)) - (progn (display-buffer buffer) + (progn (display-buffer buffer '(display-buffer-same-window)) (mastodon-tl--update)) (message "Loading your notifications...") (mastodon-tl--init-sync (or buffer-name "notifications") -- cgit v1.2.3 From 2e6bcd41a9bb5953b20758ada8cec2b4ff8e9b4f Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Mon, 8 Jan 2024 20:34:59 +0100 Subject: Use pop-to-buffer so that new window is selected --- lisp/mastodon.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 20b252f..93e802e 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -289,7 +289,7 @@ See `mastodon-toot-display-orig-in-reply-buffer'.") (buffer-list))))) ; catch any other masto buffer (mastodon-return-credential-account :force) (if buffer - (display-buffer buffer '(display-buffer-same-window)) + (pop-to-buffer buffer '(display-buffer-same-window)) (mastodon-tl--get-home-timeline) (message "Loading Mastodon account %s on %s..." (mastodon-auth--user-acct) @@ -335,7 +335,7 @@ from the server and load anew." "*mastodon-notifications*"))) (if (and (not force) (get-buffer buffer)) - (progn (display-buffer buffer '(display-buffer-same-window)) + (progn (pop-to-buffer buffer '(display-buffer-same-window)) (mastodon-tl--update)) (message "Loading your notifications...") (mastodon-tl--init-sync (or buffer-name "notifications") -- cgit v1.2.3 From af029656fae2b54ea26467423dab7090d170d0a5 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 20 Feb 2024 09:51:05 +0100 Subject: comment re return-creds-acc --- lisp/mastodon.el | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 142eced..ffeee82 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -299,6 +299,11 @@ See `mastodon-toot-display-orig-in-reply-buffer'.") (defvar mastodon-profile-credential-account nil) +;; TODO: the get request in mastodon-http--get-response often returns nil +;; after waking pc from sleep, not sure how to fix, or if just my pc +;; interestingly it only happens with this function tho. +;;we have to use :force to update the credential-account object in case things +;; have been changed via another client. (defun mastodon-return-credential-account (&optional force) "Return the CredentialAccount entity. Either from `mastodon-profile-credential-account' or from the -- cgit v1.2.3 From 5977495b8a7d2782b36723289e805f018375275b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 21 Feb 2024 10:26:53 +0100 Subject: move condition case from http get-response to credential-account --- lisp/mastodon-http.el | 9 ++------- lisp/mastodon.el | 7 ++++++- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index a345324..aef8975 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -180,13 +180,8 @@ SILENT means don't message. NO-HEADERS means don't collect http response headers. VECTOR means return json arrays as vectors." (let ((buf (mastodon-http--get url params silent))) - ;; (if (not buf) - ;; (error "Request returned nada") - (condition-case x - (with-current-buffer buf - (mastodon-http--process-response no-headers vector)) - (wrong-type-argument - (error "Request returned nada"))))) + (with-current-buffer buf + (mastodon-http--process-response no-headers vector)))) (defun mastodon-http--get-json (url &optional params silent vector) "Return only JSON data from URL request. diff --git a/lisp/mastodon.el b/lisp/mastodon.el index ffeee82..abc7787 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -315,7 +315,12 @@ FORCE means to fetch from the server and update nil :silent))) (if force (setq mastodon-profile-credential-account - (eval req)) + ;; TODO: we should also signal a quit condition after like 5 + ;; secs here + (condition-case x + (eval req) + (t ; req fails, return old value + mastodon-profile-credential-account))) (or mastodon-profile-credential-account (setq mastodon-profile-credential-account (eval req)))))) -- cgit v1.2.3 From 45e59eab514c11c69e5d0e619de967442ce1fddc Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 22 Feb 2024 10:31:25 +0100 Subject: make byte-compiler happier --- lisp/mastodon-toot.el | 3 ++- lisp/mastodon.el | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7ff3c34..e414552 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -155,7 +155,8 @@ If the original toot visibility is different we use the more restricted one." :type 'boolean) (defcustom mastodon-toot--emojify-in-compose-buffer nil - "Whether to enable `emojify' in the compose buffer.") + "Whether to enable `emojify' in the compose buffer." + :type 'boolean) (defcustom mastodon-toot--proportional-fonts-compose nil "Nonnil to enable using proportional fonts in the compose buffer. diff --git a/lisp/mastodon.el b/lisp/mastodon.el index abc7787..7a04c87 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -97,6 +97,8 @@ (autoload 'mastodon-views--view-instance-description "mastodon-views") (autoload 'mastodon-views--view-lists "mastodon-views") (autoload 'mastodon-views--view-scheduled-toots "mastodon-views") +(autoload 'mastodon-tl--dm-user "mastodon-tl") +(autoload 'mastodon-tl--scroll-up-command "mastodon-tl") (autoload 'special-mode "simple") (defvar mastodon-tl--highlight-current-toot) @@ -317,7 +319,7 @@ FORCE means to fetch from the server and update (setq mastodon-profile-credential-account ;; TODO: we should also signal a quit condition after like 5 ;; secs here - (condition-case x + (condition-case nil (eval req) (t ; req fails, return old value mastodon-profile-credential-account))) -- cgit v1.2.3