]> git.eshelyaron.com Git - emacs.git/commitdiff
Display Info buffer after ensuring it contains text
authorJoseph Turner <joseph@breatheoutbreathe.in>
Sat, 6 Apr 2024 01:32:36 +0000 (18:32 -0700)
committerEshel Yaron <me@eshelyaron.com>
Sun, 14 Apr 2024 17:07:42 +0000 (19:07 +0200)
* lisp/info.el (info-pop-to-buffer): Move display of Info buffer
to a later stage after its text contents is ready to display.
This helps to use fit-window-to-buffer in display-buffer-alist (bug#70213).

(cherry picked from commit 21775a936bd3838adaae38bd5c5ec776434736c1)

lisp/info.el

index 901f0384c628791a73b4fe98b979996a1114ff34..b459406959e39575fb17b33999cf08ba4d5ba434 100644 (file)
@@ -807,30 +807,28 @@ Select the window used, if it has been made."
                  (get-buffer-create "*info*")))))
     (with-current-buffer buffer
       (unless (derived-mode-p 'Info-mode)
-       (Info-mode)))
+       (Info-mode))
+
+      (if file-or-node
+         ;; If argument already contains parentheses, don't add another set
+         ;; since the argument will then be parsed improperly.  This also
+         ;; has the added benefit of allowing node names to be included
+         ;; following the parenthesized filename.
+         (Info-goto-node
+          (if (and (stringp file-or-node) (string-match "(.*)" file-or-node))
+              file-or-node
+             (concat "(" file-or-node ")")))
+       (if (and (zerop (buffer-size))
+                (null Info-history))
+           ;; If we just created the Info buffer, go to the directory.
+           (Info-directory))))
+
+    (when-let ((window (display-buffer buffer
+                                      (if other-window
+                                          '(nil (inhibit-same-window . t))
+                                        '(display-buffer-same-window)))))
+      (select-window window))))
 
-    (let* ((window
-           (display-buffer buffer
-                           (if other-window
-                               '(nil (inhibit-same-window . t))
-                             '(display-buffer-same-window)))))
-      (with-current-buffer buffer
-       (if file-or-node
-           ;; If argument already contains parentheses, don't add another set
-           ;; since the argument will then be parsed improperly.  This also
-           ;; has the added benefit of allowing node names to be included
-           ;; following the parenthesized filename.
-           (Info-goto-node
-            (if (and (stringp file-or-node) (string-match "(.*)" file-or-node))
-                file-or-node
-               (concat "(" file-or-node ")")))
-         (if (and (zerop (buffer-size))
-                  (null Info-history))
-             ;; If we just created the Info buffer, go to the directory.
-             (Info-directory))))
-
-      (when window
-       (select-window window)))))
 
 ;;;###autoload (put 'info 'info-file (purecopy "emacs"))
 ;;;###autoload