Permalink
Browse files

lispy-inline.el (lispy-describe-inline): Now works for Python

* lispy-inline.el (lispy-describe-inline): Use jedi to get the
  docstring. Take care not to move the cursor away from the current
  function.

* elpa.el: Silence iedit loading.

* lispy.el (lispy--current-function): Add Python variant.
  • Loading branch information...
1 parent 4ba432e commit 8df9db2fce04f6691d856cef653baa117cf5dbf9 @abo-abo committed Aug 18, 2016
Showing with 23 additions and 7 deletions.
  1. +2 −0 elpa.el
  2. +13 −3 lispy-inline.el
  3. +8 −4 lispy.el
View
@@ -2,4 +2,6 @@
(expand-file-name (format ".cask/%s/elpa" emacs-version)))
(package-initialize)
(add-to-list 'load-path default-directory)
+;; Silence the loading message
+(setq iedit-toggle-key-default nil)
View
@@ -181,9 +181,11 @@ Return t if at least one was deleted."
(setq lispy-overlay nil)
(setq deleted t))
(save-excursion
- (if (region-active-p)
- (goto-char (region-beginning))
- (lispy--back-to-paren))
+ (cond ((region-active-p)
+ (goto-char (region-beginning)))
+ ((eq major-mode 'python-mode))
+ (t
+ (lispy--back-to-paren)))
(when (or (not deleted) (not (= lispy-hint-pos (point))))
(when (= 0 (count-lines (window-start) (point)))
(recenter 1))
@@ -241,11 +243,19 @@ Return t if at least one was deleted."
((eq major-mode 'lisp-mode)
(require 'le-lisp)
(lispy--lisp-describe sym))
+ ((eq major-mode 'python-mode)
+ (require 'jedi)
+ (plist-get (car (deferred:sync!
+ (jedi:call-deferred 'get_definition)))
+ :doc))
(t
(format "%s isn't supported currently" major-mode)))))
(when doc
(lispy--show (propertize doc 'face 'lispy-face-hint)))))))))
+(declare-function deferred:sync! "ext:deferred")
+(declare-function jedi:call-deferred "ext:jedi-core")
+
;; ——— Utilities ———————————————————————————————————————————————————————————————
(defun lispy--arglist (symbol)
"Get arglist for SYMBOL."
View
@@ -5721,6 +5721,8 @@ each major mode."
(lispy-looking-back (concat space "+" special-syntax "*"))))))
;;* Pure
+(declare-function lispy-bounds-python-block "le-python")
+
(defun lispy--bounds-dwim ()
"Return a cons of region bounds if it's active.
Otherwise return cons of current string, symbol or list bounds."
@@ -5906,10 +5908,12 @@ First, try to return `lispy--bounds-string'."
(if (string-match "\\`[#'`]*\\(.*?\\)'?\\'" str)
(match-string 1 str)
nil))
- (save-excursion
- (lispy--back-to-paren)
- (when (looking-at "(\\([^ \n)]+\\)[ )\n]")
- (match-string-no-properties 1)))))
+ (if (eq major-mode 'python-mode)
+ (lispy--string-dwim (bounds-of-thing-at-point 'symbol))
+ (save-excursion
+ (lispy--back-to-paren)
+ (when (looking-at "(\\([^ \n)]+\\)[ )\n]")
+ (match-string-no-properties 1))))))
(defun lispy--prin1-fancy (x)
"Return a propertized `prin1-to-string'-ed X."

0 comments on commit 8df9db2

Please sign in to comment.