aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2024-01-03 11:35:25 +0100
committerEli Zaretskii2024-01-06 11:49:36 +0200
commitd3a4fe5694f7bd1a09546d67d2cddc0f444d41ca (patch)
treee9a35327751d2b64ca6de0c4b56cdd67ab5b7f3b
parent657275529e31226bbc6c92eb7f7af887474a0bb8 (diff)
downloademacs-d3a4fe5694f7bd1a09546d67d2cddc0f444d41ca.tar.gz
emacs-d3a4fe5694f7bd1a09546d67d2cddc0f444d41ca.zip
Fix use of 'display-buffer-alist' for Info buffers
* lisp/info.el (info-pop-to-buffer): New function. (info-other-window, info, Info-find-node, Info-revert-find-node) (Info-next, Info-prev, Info-up, info-display-manual): Call 'info-pop-to-buffer'. (Bug#68081)
-rw-r--r--lisp/info.el67
1 files changed, 57 insertions, 10 deletions
diff --git a/lisp/info.el b/lisp/info.el
index 39ca88c358c..f4384934155 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -732,8 +732,53 @@ in `Info-file-supports-index-cookies-list'."
732 (read-file-name "Info file name: " nil nil t)) 732 (read-file-name "Info file name: " nil nil t))
733 (if (numberp current-prefix-arg) 733 (if (numberp current-prefix-arg)
734 (format "*info*<%s>" current-prefix-arg)))) 734 (format "*info*<%s>" current-prefix-arg))))
735 (info-setup file-or-node 735 (info-pop-to-buffer file-or-node buffer t))
736 (switch-to-buffer-other-window (or buffer "*info*")))) 736
737(defun info-pop-to-buffer (&optional file-or-node buffer-or-name other-window)
738 "Put Info node FILE-OR-NODE in specified buffer and display it.
739Optional argument FILE-OR-NODE is as for `info'.
740
741If the optional argument BUFFER-OR-NAME is a buffer, use that
742buffer. If it is a string, use that string as the name of the
743buffer, creating it if it does not exist. Otherwise, use a
744buffer with the name `*info*', creating it if it does not exist.
745
746Optional argument OTHER-WINDOW nil means to prefer the selected
747window. OTHER-WINDOW non-nil means to prefer another window.
748Select the window used, if it has been made."
749 (let ((buffer (cond
750 ((bufferp buffer-or-name)
751 buffer-or-name)
752 ((stringp buffer-or-name)
753 (get-buffer-create buffer-or-name))
754 (t
755 (get-buffer-create "*info*")))))
756 (with-current-buffer buffer
757 (unless (derived-mode-p 'Info-mode)
758 (Info-mode)))
759
760 (let* ((window
761 (display-buffer buffer
762 (if other-window
763 '(nil (inhibit-same-window . t))
764 '(display-buffer-same-window)))))
765 (with-current-buffer buffer
766 (if file-or-node
767 ;; If argument already contains parentheses, don't add another set
768 ;; since the argument will then be parsed improperly. This also
769 ;; has the added benefit of allowing node names to be included
770 ;; following the parenthesized filename.
771 (Info-goto-node
772 (if (and (stringp file-or-node) (string-match "(.*)" file-or-node))
773 file-or-node
774 (concat "(" file-or-node ")")))
775 (if (and (zerop (buffer-size))
776 (null Info-history))
777 ;; If we just created the Info buffer, go to the directory.
778 (Info-directory))))
779
780 (when window
781 (select-window window)))))
737 782
738;;;###autoload (put 'info 'info-file (purecopy "emacs")) 783;;;###autoload (put 'info 'info-file (purecopy "emacs"))
739;;;###autoload 784;;;###autoload
@@ -768,8 +813,8 @@ See a list of available Info commands in `Info-mode'."
768 ;; of names that might have been wrapped (in emails, etc.). 813 ;; of names that might have been wrapped (in emails, etc.).
769 (setq file-or-node 814 (setq file-or-node
770 (string-replace "\n" " " file-or-node))) 815 (string-replace "\n" " " file-or-node)))
771 (info-setup file-or-node 816
772 (pop-to-buffer-same-window (or buffer "*info*")))) 817 (info-pop-to-buffer file-or-node buffer))
773 818
774(defun info-setup (file-or-node buffer) 819(defun info-setup (file-or-node buffer)
775 "Display Info node FILE-OR-NODE in BUFFER." 820 "Display Info node FILE-OR-NODE in BUFFER."
@@ -789,6 +834,8 @@ See a list of available Info commands in `Info-mode'."
789 ;; If we just created the Info buffer, go to the directory. 834 ;; If we just created the Info buffer, go to the directory.
790 (Info-directory)))) 835 (Info-directory))))
791 836
837(make-obsolete 'info-setup "use `info-pop-to-buffer' instead" "30.1")
838
792;;;###autoload 839;;;###autoload
793(defun info-emacs-manual () 840(defun info-emacs-manual ()
794 "Display the Emacs manual in Info mode." 841 "Display the Emacs manual in Info mode."
@@ -927,7 +974,7 @@ If NOERROR, inhibit error messages when we can't find the node."
927 (setq nodename (info--node-canonicalize-whitespace nodename)) 974 (setq nodename (info--node-canonicalize-whitespace nodename))
928 (setq filename (Info-find-file filename noerror)) 975 (setq filename (Info-find-file filename noerror))
929 ;; Go into Info buffer. 976 ;; Go into Info buffer.
930 (or (derived-mode-p 'Info-mode) (switch-to-buffer "*info*")) 977 (or (derived-mode-p 'Info-mode) (info-pop-to-buffer filename))
931 ;; Record the node we are leaving, if we were in one. 978 ;; Record the node we are leaving, if we were in one.
932 (and (not no-going-back) 979 (and (not no-going-back)
933 Info-current-file 980 Info-current-file
@@ -957,7 +1004,7 @@ otherwise, that defaults to `Top'."
957 "Go to an Info node FILENAME and NODENAME, re-reading disk contents. 1004 "Go to an Info node FILENAME and NODENAME, re-reading disk contents.
958When *info* is already displaying FILENAME and NODENAME, the window position 1005When *info* is already displaying FILENAME and NODENAME, the window position
959is preserved, if possible." 1006is preserved, if possible."
960 (or (derived-mode-p 'Info-mode) (switch-to-buffer "*info*")) 1007 (or (derived-mode-p 'Info-mode) (info-pop-to-buffer filename))
961 (let ((old-filename Info-current-file) 1008 (let ((old-filename Info-current-file)
962 (old-nodename Info-current-node) 1009 (old-nodename Info-current-node)
963 (window-selected (eq (selected-window) (get-buffer-window))) 1010 (window-selected (eq (selected-window) (get-buffer-window)))
@@ -2290,7 +2337,7 @@ This command doesn't descend into sub-nodes, like \\<Info-mode-map>\\[Info-forwa
2290 (interactive nil Info-mode) 2337 (interactive nil Info-mode)
2291 ;; In case another window is currently selected 2338 ;; In case another window is currently selected
2292 (save-window-excursion 2339 (save-window-excursion
2293 (or (derived-mode-p 'Info-mode) (switch-to-buffer "*info*")) 2340 (or (derived-mode-p 'Info-mode) (info-pop-to-buffer))
2294 (Info-goto-node (Info-extract-pointer "next")))) 2341 (Info-goto-node (Info-extract-pointer "next"))))
2295 2342
2296(defun Info-prev () 2343(defun Info-prev ()
@@ -2299,7 +2346,7 @@ This command doesn't go up to the parent node, like \\<Info-mode-map>\\[Info-bac
2299 (interactive nil Info-mode) 2346 (interactive nil Info-mode)
2300 ;; In case another window is currently selected 2347 ;; In case another window is currently selected
2301 (save-window-excursion 2348 (save-window-excursion
2302 (or (derived-mode-p 'Info-mode) (switch-to-buffer "*info*")) 2349 (or (derived-mode-p 'Info-mode) (info-pop-to-buffer))
2303 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))) 2350 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))))
2304 2351
2305(defun Info-up (&optional same-file) 2352(defun Info-up (&optional same-file)
@@ -2308,7 +2355,7 @@ If SAME-FILE is non-nil, do not move to a different Info file."
2308 (interactive nil Info-mode) 2355 (interactive nil Info-mode)
2309 ;; In case another window is currently selected 2356 ;; In case another window is currently selected
2310 (save-window-excursion 2357 (save-window-excursion
2311 (or (derived-mode-p 'Info-mode) (switch-to-buffer "*info*")) 2358 (or (derived-mode-p 'Info-mode) (info-pop-to-buffer))
2312 (let ((old-node Info-current-node) 2359 (let ((old-node Info-current-node)
2313 (old-file Info-current-file) 2360 (old-file Info-current-file)
2314 (node (Info-extract-pointer "up")) p) 2361 (node (Info-extract-pointer "up")) p)
@@ -5485,7 +5532,7 @@ completion alternatives to currently visited manuals."
5485 (raise-frame (window-frame window)) 5532 (raise-frame (window-frame window))
5486 (select-frame-set-input-focus (window-frame window)) 5533 (select-frame-set-input-focus (window-frame window))
5487 (select-window window)) 5534 (select-window window))
5488 (switch-to-buffer found))) 5535 (info-pop-to-buffer nil found)))
5489 ;; The buffer doesn't exist; create it. 5536 ;; The buffer doesn't exist; create it.
5490 (info-initialize) 5537 (info-initialize)
5491 (info (Info-find-file manual) 5538 (info (Info-find-file manual)