Skip to content

Commit c799c25

Browse files
committed
Rename function
* jupyter-org-client.el (jupyter-org-result [jupyter-org-request]): Rename the specialized method to `jupyter-org-get-result`, don't specialize on first argument.
1 parent 22e6b0e commit c799c25

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

jupyter-org-client.el

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ If a match is not found, return nil."
12251225
(memq type org-element-all-objects)
12261226
(memq type org-element-all-elements)))))
12271227

1228-
(cl-defmethod jupyter-org-result ((req jupyter-org-request) plist &optional metadata)
1228+
(defun jupyter-org-get-result (req plist &optional metadata)
12291229
"For REQ, return a rendered form of a message PLIST.
12301230
PLIST and METADATA have the same meaning as in
12311231
`jupyter-normalize-data'.
@@ -1249,26 +1249,25 @@ If the source block parameters have a value for the :display
12491249
header argument, like \"image/png html plain\", then loop over
12501250
those mime types instead."
12511251
(if (jupyter-org-element-p plist) plist
1252-
(let* ((mime-types (jupyter-org-display-mime-types req))
1253-
(params (jupyter-org-request-block-params req)))
1254-
(cl-assert plist json-plist)
1255-
;; Push :file back into PARAMS if it was present in
1256-
;; `org-babel-execute:jupyter'. That function removes it because
1257-
;; we don't want `org-babel-insert-result' to handle it.
1258-
(when (jupyter-org-request-file req)
1259-
(push (cons :file (jupyter-org-request-file req)) params))
1260-
(or (jupyter-org-with-point-at req
1261-
(jupyter-map-mime-bundle mime-types
1262-
(jupyter-normalize-data plist metadata)
1263-
(lambda (mime content)
1264-
(jupyter-org-result mime content params))))
1265-
(let ((warning
1266-
(format
1267-
"%s did not return requested mimetype(s): %s"
1268-
(jupyter-message-type (jupyter-request-last-message req))
1269-
mime-types)))
1270-
(display-warning 'jupyter warning)
1271-
nil)))))
1252+
(pcase-let (((cl-struct jupyter-org-request block-params file) req))
1253+
(let* ((mime-types (jupyter-org-display-mime-types req)))
1254+
;; Push :file back into PARAMS if it was present in
1255+
;; `org-babel-execute:jupyter'. That function removes it because
1256+
;; we don't want `org-babel-insert-result' to handle it.
1257+
(when file
1258+
(push (cons :file file) block-params))
1259+
(or (jupyter-org-with-point-at req
1260+
(jupyter-map-mime-bundle mime-types
1261+
(jupyter-normalize-data plist metadata)
1262+
(lambda (mime content)
1263+
(jupyter-org-result mime content block-params))))
1264+
(let ((warning
1265+
(format
1266+
"%s did not return requested mimetype(s): %s"
1267+
(jupyter-message-type (jupyter-request-last-message req))
1268+
mime-types)))
1269+
(display-warning 'jupyter warning)
1270+
nil))))))
12721271

12731272
(cl-defmethod jupyter-org-result ((_mime (eql :application/vnd.jupyter.widget-view+json)) _content _params)
12741273
;; TODO: Clickable text to open up a browser
@@ -1775,7 +1774,7 @@ If INDENTATION is nil, it defaults to `current-indentation'."
17751774
(pcase-let (((cl-struct jupyter-org-request
17761775
inline-block-p block-params client)
17771776
req))
1778-
(let ((result (jupyter-org-result req data metadata)))
1777+
(let ((result (jupyter-org-get-result req data metadata)))
17791778
(jupyter-org-with-point-at req
17801779
(if inline-block-p
17811780
(org-babel-insert-result
@@ -1859,7 +1858,7 @@ EL is an Org element with the properties
18591858
(cond
18601859
(async-p
18611860
(jupyter-org--clear-async-indicator req)
1862-
(if silent-p (jupyter-return (jupyter-org-result req data metadata))
1861+
(if silent-p (jupyter-return (jupyter-org-get-result req data metadata))
18631862
(jupyter-org-inserted-result data metadata)))
18641863
(t
18651864
(jupyter-return
@@ -1959,7 +1958,7 @@ Meant to be used as the return value of
19591958
(jupyter-org-strip-last-newline r))
19601959
r))
19611960
(jupyter-org--process-pandoc-results
1962-
(mapcar (apply-partially #'jupyter-org-result req)
1961+
(mapcar (apply-partially #'jupyter-org-get-result req)
19631962
results))))
19641963
(result-params (alist-get :result-params block-params)))
19651964
(org-element-interpret-data

0 commit comments

Comments
 (0)