Added other types of introspection to my-python/describe-at-point.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Mon, 25 Jan 2021 10:55:00 +0200
changeset 1706 26b2fc3886f9
parent 1705 3ed88879232f
child 1707 84c30e639991
Added other types of introspection to my-python/describe-at-point.
.emacs-my
--- a/.emacs-my	Mon Jan 18 17:07:56 2021 +0200
+++ b/.emacs-my	Mon Jan 25 10:55:00 2021 +0200
@@ -3070,11 +3070,18 @@
 
 (setq python-indent-offset 4)
 
-(defun my-python/describe-at-point (symbol process)
+(defun my-python/describe-at-point (symbol process prefix)
   "Show full docs for symbol at point."
   (interactive (list (python-info-current-symbol)
-                     (python-shell-get-process)))
-  (let ( (cmd (concat "help('" symbol "')\n")) )
+                     (python-shell-get-process)
+                     current-prefix-arg))
+  (let ( (cmd
+          (cond
+           ((eq 1 prefix) (concat "type(" symbol ")\n"))
+           ((eq 2 prefix) (concat "vars(" symbol ")\n"))
+           ((eq 3 prefix) (concat "repr(" symbol ")\n"))
+           ((not prefix) (concat "help('" symbol "')\n"))
+           (t (concat "dir(" symbol ")\n")))) )
     (switch-to-buffer (get-buffer-create (format "*pydoc: %s*" symbol)))
     (fundamental-mode)
     (read-only-mode -1)