[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/mastodon 445d176b2a 02/27: Replace 'switch-to-buffer' with
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/mastodon 445d176b2a 02/27: Replace 'switch-to-buffer' with 'display-buffer' or 'pop-to-buffer' |
Date: |
Fri, 23 Feb 2024 13:00:52 -0500 (EST) |
branch: elpa/mastodon
commit 445d176b2a593a87afd3f6bca717feba639dfbdc
Author: Rahguzar <rahguzar@zohomail.eu>
Commit: Rahguzar <rahguzar@zohomail.eu>
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-auth.el | 31 +++++++++++++------------------
lisp/mastodon-http.el | 1 -
lisp/mastodon-tl.el | 4 ++--
lisp/mastodon.el | 4 ++--
4 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el
index 279377ba2d..9f9d128188 100644
--- a/lisp/mastodon-auth.el
+++ b/lisp/mastodon-auth.el
@@ -105,30 +105,25 @@ code. Copy this code and paste it in the minibuffer
prompt."
(defun mastodon-auth--show-notice (notice buffer-name &optional ask)
"Display NOTICE to user.
-NOTICE is displayed in vertical split occupying 50% of total
+By default NOTICE is displayed in vertical split occupying 50% of total
width. The buffer name of the buffer being displayed in the
window is BUFFER-NAME.
When optional argument ASK is given which should be a string, use
ASK as the minibuffer prompt. Return whatever user types in
response to the prompt.
When ASK is absent return nil."
- (let ((buffer (get-buffer-create buffer-name))
- (inhibit-read-only t)
- ask-value window)
- (set-buffer buffer)
- (erase-buffer)
- (insert notice)
- (fill-region (point-min) (point-max))
- (read-only-mode)
- (setq window (select-window
- (split-window (frame-root-window) nil 'left)
- t))
- (switch-to-buffer buffer t)
- (when ask
- (setq ask-value (read-string ask))
- (kill-buffer buffer)
- (delete-window window))
- ask-value))
+ (if ask
+ (read-string ask)
+ (let ((buffer (get-buffer-create buffer-name))
+ (inhibit-read-only t))
+ (set-buffer buffer)
+ (erase-buffer)
+ (insert notice)
+ (fill-region (point-min) (point-max))
+ (read-only-mode)
+ (prog1 nil
+ (pop-to-buffer buffer '(display-buffer-in-side-window
+ (side . left) (window-width . 0.5)))))))
(defun mastodon-auth--request-authorization-code ()
"Ask authorization code and return it."
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index a357672a12..541c92e66f 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -240,7 +240,6 @@ Callback to `mastodon-http--get-response-async', usually
(defun mastodon-http--process-headers ()
"Return an alist of http response headers."
- (switch-to-buffer (current-buffer))
(goto-char (point-min))
(let* ((head-str (buffer-substring-no-properties
(point-min)
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 561087e0e0..d4f3d04c99 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -287,7 +287,7 @@ It is active where point is placed by
`mastodon-tl--goto-next-item.'")
"Evaluate BODY in a new or existing buffer called BUFFER.
MODE-FUN is called to set the major mode.
OTHER-WINDOW means call `switch-to-buffer-other-window' rather
-than `switch-to-buffer'."
+than `pop-to-buffer'."
(declare (debug t)
(indent 3))
`(with-current-buffer (get-buffer-create ,buffer)
@@ -296,7 +296,7 @@ than `switch-to-buffer'."
(funcall ,mode-fun)
(if ,other-window
(switch-to-buffer-other-window ,buffer)
- (switch-to-buffer ,buffer))
+ (pop-to-buffer ,buffer '(display-buffer-same-window)))
,@body)))
(defmacro mastodon-tl--do-if-item (&rest body)
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index bac4d6759d..c9c3b6433c 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")
- [nongnu] elpa/mastodon 3d558edff6 04/27: Tweak display actions to better preserve defaults, (continued)
- [nongnu] elpa/mastodon 3d558edff6 04/27: Tweak display actions to better preserve defaults, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 5977495b8a 20/27: move condition case from http get-response to credential-account, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 379e1edc27 12/27: read me, var index, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 11be568c1e 09/27: my-profile: load by id, rather than server search, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 8e48dc0d5f 26/27: readme typo, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 63120440fa 18/27: string-trim-left on remove-docs, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon af029656fa 14/27: comment re return-creds-acc, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 1fa432d27c 11/27: toot.el: use all emoji for : capf, and get text annotation, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 5e31b1b484 15/27: http: some hack error handling in get-response, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 9caa0b58ea 10/27: docstrings, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 445d176b2a 02/27: Replace 'switch-to-buffer' with 'display-buffer' or 'pop-to-buffer',
ELPA Syncer <=
- [nongnu] elpa/mastodon 58ec54b666 17/27: update: skip scheduled-statuses view, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon d66e27be92 23/27: Merge branch 'develop', ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 2e6bcd41a9 05/27: Use pop-to-buffer so that new window is selected, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 6a5152b6cb 03/27: Use 'read-buffer' to choose a buffer, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 51132d0868 08/27: Merge pull request 'Use display-buffer to allow customization' (#522) from rahguzar/mastodon.el:display-buffer into develop, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 25bae1042f 25/27: Merge branch 'develop', ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon c84630f0f1 27/27: readme: add nb re .info docs, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 87b0b347b5 13/27: readme completion, ELPA Syncer, 2024/02/23
- [nongnu] elpa/mastodon 52b7775cb7 19/27: views: ensure things have item-type prop, and string-trim scheduleds, ELPA Syncer, 2024/02/23