Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default description is too long #4

Closed
syohex opened this issue Oct 30, 2012 · 3 comments
Closed

Default description is too long #4

syohex opened this issue Oct 30, 2012 · 3 comments

Comments

@syohex
Copy link
Collaborator

syohex commented Oct 30, 2012

jediの問題かもしれませんが、description(popup-make-itemの summaryパラメータ)が
以下のようにとても長くなってしまい、見づらく感じます。

emacs

以下のVim版のスクリーンショットのような感じになればよいと
考えています。(ただコードを見る限り、Emacs版と同じようなことをやって
いるようにしか見えないので、jediの APIが今のような descriptionを
返す前に撮影されたものかもしれません)
vim

必要な情報だけ欲しいのですが、すべて有用な情報であるかもしれないので

  • そのまま表示
  • 最内の情報だけ表示(一番重要に思える)
  • 表示しない、
    から選択できるような形にするのが良いと思います。

以下は試作したパッチです。

diff --git a/jedi.el b/jedi.el
index 0e66af4..8fe65e0 100644
--- a/jedi.el
+++ b/jedi.el
@@ -182,6 +182,21 @@ To make this option work, you need to use `jedi:setup' instead of
 
 ;;; AC source

+(defcustom jedi:ac-description-style 'long
+  "How to display description"
+  :type '(choice (const :tag "Long description" 'long)
+                 (const :tag "Short Desctiption" 'short)
+                 (const :tag "No description" nil))
+  :group 'jedi)
+
+(defun jedi:ac-format-description (desc)
+  (case jedi:ac-description-style
+    (long desc)
+    (short (if (string-match "\\(<[^<:]+:[^>]+>\\)" desc)
+               (match-string 1 desc)
+             desc))
+    (otherwise nil)))
+
 (defun jedi:ac-direct-matches ()
   (mapcar
    (lambda (x)
@@ -190,7 +205,7 @@ To make this option work, you need to use `jedi:setup' instead of
        (popup-make-item word
                         :symbol symbol
                         :document (unless (equal doc "") doc)
-                        :summary description)))
+                        :summary (jedi:ac-format-description description))))
    jedi:complete-reply))

 (defun jedi:ac-direct-prefix ()

現状の jediは jedi側で文字列化してしまい、エディタプラグイン側で
得られた情報を加工しづらいように思えるので、理想的には jedi側を修正し、
それを使う側で加工しやすい情報を得られるようにできればよいと思います。
(特に括弧の入れ子構造は正規表現で解析するのが困難なので)

私の環境設定(本来は Vimのスクリーンショットのようになる ??)に問題があるかも
しれませんので、ご意見をいただけたらと思います。

よろしくお願いします。

@tkf
Copy link
Owner

tkf commented Oct 30, 2012

ありがとうございます。本家のトラッカーに issue 登録しました。 davidhalter/jedi#49
出来れば hello.py のソースを本家のほうに貼っておいてもらえませんか?

Jedi のソースを見ると "TODO return value is just repr of some objects, improve!" って書いてあるので、いつかは改善されると思います。時間がかかりそうであれば、私のほうでパッチを作って本家にPRしようと思います。

@syohex
Copy link
Collaborator Author

syohex commented Nov 8, 2012

jedi側で改善されたようなので closeとしておきます。
ありがとうございます。

@syohex syohex closed this as completed Nov 8, 2012
@tkf
Copy link
Owner

tkf commented Nov 8, 2012

こっちを閉めるの忘れてました。ありがとうございます!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants