emacs-elpa-diffs
[Top][All Lists]
Advanced

[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")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]