mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
Add ein:notebook-request-tool-tip-command
This commit is contained in:
parent
9c807157f5
commit
3f0fcd2acf
3 changed files with 37 additions and 2 deletions
16
ein-cell.el
16
ein-cell.el
|
@ -362,7 +362,21 @@ A specific node can be specified using optional ARGS."
|
|||
|
||||
(defun ein:cell-finish-tooltip (cell content)
|
||||
;; FIXME: implement!
|
||||
(ein:log 'info "`ein:cell-finish-tooltip' is not implemented!"))
|
||||
(let* ((defstring (or (plist-get content :call_def)
|
||||
(plist-get content :init_definition)
|
||||
(plist-get content :definition)))
|
||||
(docstring (or (plist-get content :call_docstring)
|
||||
(plist-get content :init_docstring)
|
||||
(plist-get content :docstring)
|
||||
"<empty docstring>"))
|
||||
(name (plist-get content :name))
|
||||
(tooltip (format "%s\n%s\n%s" name defstring docstring)))
|
||||
(ein:log 'debug "EIN:CELL-FINISH-TOOLTIP")
|
||||
(ein:log 'debug "tooltip: %s" tooltip)
|
||||
(cond
|
||||
((fboundp 'popup-tip)
|
||||
(funcall 'popup-tip tooltip))
|
||||
(t (message "%s" defstring)))))
|
||||
|
||||
(defun ein:cell-goto (cell)
|
||||
(ewoc-goto-node (oref cell :ewoc) (ein:cell-element-get cell :input))
|
||||
|
|
|
@ -218,9 +218,11 @@ The kernel will no longer be responsive.")))
|
|||
|
||||
|
||||
(defun ein:kernel-object-info-request (kernel objname)
|
||||
"Send object info request of OBJNAME to KERNEL and return
|
||||
`msg-id' or `nil' when OBJNAME is `nil'."
|
||||
(assert (ein:kernel-ready-p kernel))
|
||||
(when objname
|
||||
(let* ((content (list :oname (format "%S" objname)))
|
||||
(let* ((content (list :oname (format "%s" objname)))
|
||||
(msg (ein:kernel-get-msg kernel "object_info_request" content)))
|
||||
(ein:websocket-send
|
||||
(ein:$kernel-shell-channel kernel)
|
||||
|
|
|
@ -506,6 +506,24 @@ when the prefix argument is given."
|
|||
(puthash msg-id (oref cell :cell-id) (ein:@notebook msg-cell-map)))
|
||||
(setf (ein:@notebook dirty) t))))
|
||||
|
||||
(defun ein:notebook-request-tool-tip (notebook cell func)
|
||||
(let ((msg-id (ein:kernel-object-info-request
|
||||
(ein:$notebook-kernel notebook) func)))
|
||||
(when msg-id
|
||||
(puthash msg-id (oref cell :cell-id)
|
||||
(ein:$notebook-msg-cell-map notebook)))))
|
||||
|
||||
(defun ein:notebook-request-tool-tip-command ()
|
||||
(interactive)
|
||||
(ein:notebook-with-cell #'ein:codecell-p
|
||||
(ein:kernel-if-ready (ein:@notebook kernel)
|
||||
(let ((func (save-excursion
|
||||
(unless (looking-at "(")
|
||||
(search-backward "(" (point-at-bol) t))
|
||||
(with-syntax-table ein:dotty-syntax-table
|
||||
(thing-at-point 'word)))))
|
||||
(ein:notebook-request-tool-tip ein:notebook cell func)))))
|
||||
|
||||
(defun ein:notebook-complete-cell (notebook cell line-string rel-pos)
|
||||
(let ((msg-id (ein:kernel-complete (ein:$notebook-kernel notebook)
|
||||
line-string rel-pos)))
|
||||
|
@ -668,6 +686,7 @@ NAME is any non-empty string that does not contain '/' or '\\'."
|
|||
(define-key map "\C-c\C-t" 'ein:notebook-toggle-cell-type)
|
||||
(define-key map "\C-c\C-n" 'ein:notebook-goto-next-cell)
|
||||
(define-key map "\C-c\C-p" 'ein:notebook-goto-prev-cell)
|
||||
(define-key map "\C-c\C-f" 'ein:notebook-request-tool-tip-command)
|
||||
(define-key map "\C-c\C-i" 'ein:notebook-complete-cell-command)
|
||||
(define-key map "\C-c\C-z" 'ein:notebook-kernel-interrupt-command)
|
||||
(define-key map "\C-c\C-q" 'ein:notebook-kernel-kill-command)
|
||||
|
|
Loading…
Add table
Reference in a new issue