Function: info-pop-to-buffer

info-pop-to-buffer is a byte-compiled function defined in info.el.gz.

Signature

(info-pop-to-buffer &optional FILE-OR-NODE BUFFER-OR-NAME OTHER-WINDOW)

Documentation

Put Info node FILE-OR-NODE in specified buffer and display it.

Optional argument FILE-OR-NODE is as for info.

If the optional argument BUFFER-OR-NAME is a buffer, use that buffer. If it is a string, use that string as the name of the buffer, creating it if it does not exist. Otherwise, use a buffer with the name *info*, creating it if it does not exist.

Optional argument OTHER-WINDOW nil means to prefer the selected window. OTHER-WINDOW non-nil means to prefer another window. Select the window used, if it has been made.

Source Code

;; Defined in /usr/src/emacs/lisp/info.el.gz
(defun info-pop-to-buffer (&optional file-or-node buffer-or-name other-window)
  "Put Info node FILE-OR-NODE in specified buffer and display it.
Optional argument FILE-OR-NODE is as for `info'.

If the optional argument BUFFER-OR-NAME is a buffer, use that
buffer.  If it is a string, use that string as the name of the
buffer, creating it if it does not exist.  Otherwise, use a
buffer with the name `*info*', creating it if it does not exist.

Optional argument OTHER-WINDOW nil means to prefer the selected
window.  OTHER-WINDOW non-nil means to prefer another window.
Select the window used, if it has been made."
  (let ((buffer (cond
		 ((bufferp buffer-or-name)
		  buffer-or-name)
		 ((stringp buffer-or-name)
		  (get-buffer-create buffer-or-name))
		 (t
		  (get-buffer-create "*info*")))))
    (with-current-buffer buffer
      (unless (derived-mode-p '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))))