Emacs: Open Python Doc 🚀
here's a convenient command to open the python doc.
(defvar xah-python-doc-path nil "A list of paths to python doc file. Each element is tried to check if it exist. (this is useful if you have multiple machines with different operating systems.) In python 3.12, it's a html file. In windows python 3.9, it's a .chm file, eg c:/Python39/Doc/python391.chm") (setq xah-python-doc-path (list "~/AppData/Local/Programs/Python/Python312/Doc/html/index.html" )) (defun xah-open-python-doc () "Open python doc file `xah-python-doc-path'. URL `http://xahlee.info/emacs/emacs/emacs_open_python_doc.html' Created: 2023-03-18 Version: 2024-10-05" (interactive) (let ((xpath (seq-some (lambda (x) (if (file-exists-p x) x nil)) xah-python-doc-path))) (cond ((not xpath) (message "no file exists in paths `xah-python-doc-path' %s" xah-python-doc-path) nil) ((string-equal (file-name-extension xpath) "html") (browse-url xpath)) ((string-equal (file-name-extension xpath) "chm") (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)))) (t (message "file exist at %s but is not html nor chm." xpath) nil))))