Skip to content

Commit

Permalink
Display of the current function can be disabled.
Browse files Browse the repository at this point in the history
The new variable elpy-eldoc-show-current-function allows users to
disable the display of the function or class and method being edited
in the echo area in case Elpy can not find a calltip.

Fixes #377
Fixes #432
  • Loading branch information
jorgenschaefer committed Jan 9, 2015
1 parent d447513 commit 77cc9df
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
16 changes: 13 additions & 3 deletions elpy.el
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,15 @@ message again within this amount of seconds."
:type 'integer
:group 'elpy)

(defcustom elpy-eldoc-show-current-function t
"If true, show the current function if no calltip is available.
When Elpy can not find the calltip of the function call at point,
it can show the name of the function or class and method being
edited instead. Setting this variable to nil disables this feature."
:type 'boolean
:group 'elpy)

(defcustom elpy-test-runner 'elpy-test-discover-runner
"The test runner to use to run tests."
:type '(choice (const :tag "Unittest Discover" elpy-test-discover-runner)
Expand Down Expand Up @@ -3055,9 +3064,10 @@ display the current class and method instead."
(eldoc-message
(cond
((not calltip)
(let ((current-defun (python-info-current-defun)))
(when current-defun
(format "In: %s()" current-defun))))
(when elpy-eldoc-show-current-function
(let ((current-defun (python-info-current-defun)))
(when current-defun
(format "In: %s()" current-defun)))))
((stringp calltip)
calltip)
(t
Expand Down
12 changes: 12 additions & 0 deletions test/elpy-eldoc-documentation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@

(should (equal calltip "In: FooClass.method()")))))

(ert-deftest elpy-eldoc-documentation-should-not-display-current-defun-if-no-calltip-and-show-defun-disabled ()
(elpy-testcase ()
(mletf* ((elpy-rpc-get-calltip (callback) (funcall callback nil))
(calltip nil)
(eldoc-message (tip) (setq calltip tip))
(python-info-current-defun () "FooClass.method")
(elpy-eldoc-show-current-function nil))

(elpy-eldoc-documentation)

(should (null calltip)))))

(ert-deftest elpy-eldoc-documentation-should-return-nil-without-defun ()
(elpy-testcase ()
(mletf* ((elpy-rpc-get-calltip (callback) (funcall callback nil))
Expand Down

0 comments on commit 77cc9df

Please sign in to comment.