.emacs-my
changeset 1342 ca70c69cabe5
parent 1341 227f15d381aa
child 1343 059cd8b7e3b3
equal deleted inserted replaced
1341:227f15d381aa 1342:ca70c69cabe5
  2778   "Python code to setup documentation retrieval.")
  2778   "Python code to setup documentation retrieval.")
  2779 
  2779 
  2780 (defvar my/python-eldoc-string-code "__PYDOC_get_full_help('''%s''')"
  2780 (defvar my/python-eldoc-string-code "__PYDOC_get_full_help('''%s''')"
  2781   "Python code used to get a string with the documentation of an object.")
  2781   "Python code used to get a string with the documentation of an object.")
  2782 
  2782 
       
  2783 (defvar my/python-eldoc-string-code2 "help('''%s''')"
       
  2784   "Python code used to get a string with the documentation of an object.")
       
  2785 
  2783 ;; For built-in python.el
  2786 ;; For built-in python.el
  2784 (my--eval-after-load python
  2787 (my--eval-after-load python
  2785   (add-to-list 'python-shell-setup-codes 'my/python-eldoc-setup-code) ; Used inside (python-shell-send-setup-code)
  2788   (add-to-list 'python-shell-setup-codes 'my/python-eldoc-setup-code) ; Used inside (python-shell-send-setup-code)
  2786   (defun my/python-eldoc-at-point (&optional symbol)
  2789   (defun my/python-eldoc-at-point (&optional symbol)
  2787     "Show full docs for symbol at point."
  2790     "Show full docs for symbol at point."
  2798       (read-only-mode -1)
  2801       (read-only-mode -1)
  2799       (buffer-disable-undo)
  2802       (buffer-disable-undo)
  2800       (erase-buffer)
  2803       (erase-buffer)
  2801       (insert (python-eldoc--get-doc-at-point symbol))
  2804       (insert (python-eldoc--get-doc-at-point symbol))
  2802       (goto-char (point-min))
  2805       (goto-char (point-min))
       
  2806       (when (re-search-forward "^u?['\"]" (line-end-position) t)
       
  2807         (replace-match ""))
       
  2808       (while (re-search-forward "\\\\n" nil t)
       
  2809         (replace-match "\n"))
       
  2810       (goto-char (point-min))
       
  2811       (while (re-search-forward "\\\\'" nil t)
       
  2812         (replace-match "['\"]"))
       
  2813       (goto-char (point-max))
       
  2814       (when (eq ?' (char-before))
       
  2815         (delete-char -1))
       
  2816       (read-only-mode 1)
       
  2817       (goto-char (point-min))))
       
  2818   (define-key python-mode-map "\C-c\C-d" 'my/python-eldoc-at-point)
       
  2819   (defun my/python-eldoc-at-point2 (&optional symbol)
       
  2820     "Show full docs for symbol at point."
       
  2821     (interactive
       
  2822      (let ((symbol (python-info-current-symbol t))
       
  2823            (enable-recursive-minibuffers t))
       
  2824        (list (read-string (if symbol
       
  2825                               (format "Describe symbol (default %s): " symbol)
       
  2826                             "Describe symbol: ")
       
  2827                           nil nil symbol))))
       
  2828     (let ( (python-eldoc-string-code my/python-eldoc-string-code2) )
       
  2829       (switch-to-buffer (get-buffer-create "*Python-doc*"))
       
  2830       (read-only-mode -1)
       
  2831       (buffer-disable-undo)
       
  2832       (erase-buffer)
       
  2833       (insert (python-eldoc--get-doc-at-point symbol))
       
  2834       (goto-char (point-min))
  2803       (when (re-search-forward "^u?'" (line-end-position) t)
  2835       (when (re-search-forward "^u?'" (line-end-position) t)
  2804         (replace-match ""))
  2836         (replace-match ""))
  2805       (while (re-search-forward "\\\\n" nil t)
  2837       (while (re-search-forward "\\\\n" nil t)
  2806         (replace-match "\n"))
  2838         (replace-match "\n"))
  2807       (goto-char (point-min))
  2839       (goto-char (point-min))
  2810       (goto-char (point-max))
  2842       (goto-char (point-max))
  2811       (when (eq ?' (char-before))
  2843       (when (eq ?' (char-before))
  2812         (delete-char -1))
  2844         (delete-char -1))
  2813       (read-only-mode 1)
  2845       (read-only-mode 1)
  2814       (goto-char (point-min))))
  2846       (goto-char (point-min))))
  2815   (define-key python-mode-map "\C-c\C-d" 'my/python-eldoc-at-point)
  2847   (define-key python-mode-map "\C-c\C-g" 'my/python-eldoc-at-point2)
  2816 
  2848 
  2817   (defun my-python/send-paragraph ()
  2849   (defun my-python/send-paragraph ()
  2818     (interactive)
  2850     (interactive)
  2819     (save-excursion
  2851     (save-excursion
  2820       (mark-paragraph)
  2852       (mark-paragraph)