Emacs: Open Python Doc 🚀

By Xah Lee. Date: .

here's a convenient command to open the python doc.

(defvar xah-python-doc-path "c:/Python39/Doc/python391.chm" "Path to python documentation.")

(defun xah-open-python-doc ()
  "Open python doc file `xah-python-doc-path'.
URL `http://xahlee.info/emacs/emacs/emacs_open_python_doc.html'
Version 2023-03-18"
  (interactive)
  (cond
   ((string-equal system-type "windows-nt")
    (let ((xoutBuf (get-buffer-create "*xah open python doc*"))
          (xcmdlist (list "PowerShell" "-Command" "Invoke-Item" "-LiteralPath"))
          (xdocpath (list (format "'%s'" xah-python-doc-path))))
      (apply 'start-process (append (list "xah open python doc" xoutBuf) xcmdlist xdocpath nil))
      (switch-to-buffer-other-window xoutBuf)))
   ((string-equal system-type "darwin")
    (shell-command (concat "open " xdocpath)))
   ((string-equal system-type "gnu/linux")
    (call-process shell-file-name nil nil nil
                    shell-command-switch
                    (format "%s %s"
                            "xdg-open"
                            (shell-quote-argument xdocpath))))))

Line Wrap