.emacs-my
changeset 1345 6fe0ba3b4dc4
parent 1344 131e20ea7dad
child 1346 b9df4ce57aed
equal deleted inserted replaced
1344:131e20ea7dad 1345:6fe0ba3b4dc4
  2780   "Python code to setup documentation retrieval.")
  2780   "Python code to setup documentation retrieval.")
  2781 
  2781 
  2782 (defvar my/python-eldoc-string-code "__PYDOC_get_full_help('''%s''')"
  2782 (defvar my/python-eldoc-string-code "__PYDOC_get_full_help('''%s''')"
  2783   "Python code used to get a string with the documentation of an object.")
  2783   "Python code used to get a string with the documentation of an object.")
  2784 
  2784 
  2785 (defvar my/python-eldoc-string-code2 "help('''%s''')"
  2785 (defvar my/python-eldoc-string-code2 "help(%s); pass"
  2786   "Python code used to get a string with the documentation of an object.")
  2786   "Python code used to get a string with the documentation of an object.")
  2787 
  2787 
  2788 ;; For built-in python.el
  2788 ;; For built-in python.el
  2789 (my--eval-after-load python
  2789 (my--eval-after-load python
  2790   (add-to-list 'python-shell-setup-codes 'my/python-eldoc-setup-code) ; Used inside (python-shell-send-setup-code)
  2790   (add-to-list 'python-shell-setup-codes 'my/python-eldoc-setup-code) ; Used inside (python-shell-send-setup-code)
  2825            (enable-recursive-minibuffers t))
  2825            (enable-recursive-minibuffers t))
  2826        (list (read-string (if symbol
  2826        (list (read-string (if symbol
  2827                               (format "Describe symbol (default %s): " symbol)
  2827                               (format "Describe symbol (default %s): " symbol)
  2828                             "Describe symbol: ")
  2828                             "Describe symbol: ")
  2829                           nil nil symbol))))
  2829                           nil nil symbol))))
  2830     (let ( (python-eldoc-string-code my/python-eldoc-string-code2) )
  2830     (let ( )
  2831       (switch-to-buffer (get-buffer-create "*Python-doc*"))
  2831       (switch-to-buffer (get-buffer-create "*Python-doc*"))
  2832       (read-only-mode -1)
  2832       (read-only-mode -1)
  2833       (buffer-disable-undo)
  2833       (buffer-disable-undo)
  2834       (erase-buffer)
  2834       (erase-buffer)
  2835       (insert (python-eldoc--get-doc-at-point symbol))
  2835       (insert (python-shell-send-string-no-output (format my/python-eldoc-string-code2 symbol) (python-shell-get-process)))
  2836       (goto-char (point-min))
  2836       (goto-char (point-min))
  2837       (when (re-search-forward "^u?'" (line-end-position) t)
  2837       (when (re-search-forward "^u?'" (line-end-position) t)
  2838         (replace-match ""))
  2838         (replace-match ""))
  2839       (while (re-search-forward "\\\\n" nil t)
  2839       (while (re-search-forward "\\\\n" nil t)
  2840         (replace-match "\n"))
  2840         (replace-match "\n"))