all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Carlos Pita <carlosjosepita@gmail.com>
To: 19637@debbugs.gnu.org
Subject: bug#19637: 25.0.50; ipython eldoc keep visible while typing parameters
Date: Thu, 5 Feb 2015 16:21:03 -0300	[thread overview]
Message-ID: <CAELgYhcV66fFt_gHSiWK0-bNp-RKu3z2RC1sh66PwAS+MRMDmA@mail.gmail.com> (raw)
In-Reply-To: <CAELgYheYypj48uV6oKwzSjS0TJ66isOUg_oCXFi25y1Seja3+Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]

Here is a tentative patch.

What it does is the following:

1) If point is in a paren context it escapes to the opening parenthesis

2) Now, if point is left (or was there from the very beginning) over
an opening (, then the relevant symbol is the one to the left of the
(, so whitespaces, newlines and backslashes are skipped backwards.
Presumably the point is now over a symbol.

3) We call (python-info-current-symbol). If a symbol is indeed parsed,
it's returned, if not, then the point position is restored and
(python-info-current-symbol) is called as usual.

Notice that the above allows for nested calls. But the exact behavior
is as follows (say * marks the position of the point):

a) m*ap(xx           will return map
b) map(xx*           will return map
c) map(open*       will also return map
d) map(open(xx*  will return open

I think this is almost always what you want. But a more complex
sequence could be implemented for c that first checks if there is any
documentation for 'open' and only in case there was no documentation
for the symbol, it showed the documentation for 'map'. I don't think
it's worth the extra complexity.

Cheers
--
Carlos

[-- Attachment #2: tooltip.patch --]
[-- Type: text/x-patch, Size: 1373 bytes --]

diff --git a/.emacs.d/lisp/python.el b/.emacs.d/lisp/python.el
index 4c8f4c6..3fe62e0 100644
--- a/.emacs.d/lisp/python.el
+++ b/.emacs.d/lisp/python.el
@@ -3940,15 +3940,25 @@ See `python-check-command' for the default."
   :type 'string
   :group 'python)
 
+(defun python-eldoc--get-symbol-at-point ()
+  (or (save-excursion
+        (when (let ((start (python-syntax-context 'paren)))
+                (when start
+                  (goto-char start))
+                (= (char-after) ?\())
+          (skip-chars-backward " \t\n\\\\")
+          (python-info-current-symbol)))
+      (python-info-current-symbol)))
+
 (defun python-eldoc--get-doc-at-point (&optional force-input force-process)
   "Internal implementation to get documentation at point.
-If not FORCE-INPUT is passed then what `python-info-current-symbol'
+If not FORCE-INPUT is passed then what `python-eldoc--get-symbol-at-point'
 returns will be used.  If not FORCE-PROCESS is passed what
 `python-shell-get-process' returns is used."
   (let ((process (or force-process (python-shell-get-process))))
     (when process
       (let ((input (or force-input
-                       (python-info-current-symbol t))))
+                       (python-eldoc--get-symbol-at-point))))
         (and input
              ;; Prevent resizing the echo area when iPython is
              ;; enabled.  Bug#18794.

  reply	other threads:[~2015-02-05 19:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-20 20:09 bug#19637: 25.0.50; ipython eldoc keep visible while typing parameters Carlos Pita
2015-02-05 19:21 ` Carlos Pita [this message]
2015-02-07 21:45 ` Fabián Ezequiel Gallina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAELgYhcV66fFt_gHSiWK0-bNp-RKu3z2RC1sh66PwAS+MRMDmA@mail.gmail.com \
    --to=carlosjosepita@gmail.com \
    --cc=19637@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.