From 6e7d3dd158b0a46b878d65e8e92cd5c4b4e7395d Mon Sep 17 00:00:00 2001 From: John Miller Date: Thu, 1 Nov 2018 16:18:56 -0500 Subject: [PATCH] ein-pytools: Don't request tooltips for magic functions. Someone wants ein to get tooltip information for magic functions - we don't currently support this so will skip these situations. --- lisp/ein-pytools.el | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lisp/ein-pytools.el b/lisp/ein-pytools.el index f36ad38..4865e3d 100644 --- a/lisp/ein-pytools.el +++ b/lisp/ein-pytools.el @@ -87,23 +87,29 @@ If OTHER-WINDOW is non-`nil', open the file in the other window." ;;; Tooltip and help +;; We can probably be more sophisticated than this, but +;; as a hack it will do. +(defun ein:pytools-magic-func-p (fstr) + (string-prefix-p "%" fstr)) + (defun ein:pytools-request-tooltip (kernel func) (interactive (list (ein:get-kernel-or-error) (ein:object-at-point-or-error))) - (if (>= (ein:$kernel-api-version kernel) 3) - (ein:kernel-execute - kernel - (format "__import__('ein').print_object_info_for(%s)" func) - (list - :output (cons - (lambda (name msg-type content -metadata-not-used-) - (ein:case-equal msg-type - (("stream" "display_data") - (ein:pytools-finish-tooltip name (ein:json-read-from-string (plist-get content :text)) nil)))) - func))) - (ein:kernel-object-info-request - kernel func (list :object_info_reply - (cons #'ein:pytools-finish-tooltip nil))))) + (unless (ein:pytools-magic-func-p func) + (if (>= (ein:$kernel-api-version kernel) 3) + (ein:kernel-execute + kernel + (format "__import__('ein').print_object_info_for(%s)" func) + (list + :output (cons + (lambda (name msg-type content -metadata-not-used-) + (ein:case-equal msg-type + (("stream" "display_data") + (ein:pytools-finish-tooltip name (ein:json-read-from-string (plist-get content :text)) nil)))) + func))) + (ein:kernel-object-info-request + kernel func (list :object_info_reply + (cons #'ein:pytools-finish-tooltip nil)))))) (declare-function pos-tip-show "pos-tip") (declare-function popup-tip "popup")