@@ -1484,38 +1484,33 @@ MATCHES are the completion matches returned by the kernel,
1484
1484
METADATA is any extra data associated with MATCHES that was
1485
1485
supplied by the kernel."
1486
1486
(let (buf)
1487
- (save-current-buffer
1488
- (unwind-protect
1489
- (cl-loop
1490
- for i from 0 below (length matches)
1491
- for match = (aref matches i)
1492
- do
1493
- (put-text-property 0 1 'docsig match match )
1494
- (cond
1495
- ((string-match jupyter-completion-argument-regexp match )
1496
- (let* ((str match )
1497
- (args-str (match-string 1 str))
1498
- (end (match-end 1 ))
1499
- (path (match-string 2 str))
1500
- (line (string-to-number (match-string 3 str)))
1501
- (snippet (progn
1502
- (unless buf
1503
- (setq buf (generate-new-buffer " *temp*" ))
1504
- (set-buffer buf))
1505
- (insert args-str)
1506
- (goto-char (point-min ))
1507
- (prog1 (jupyter-completion--make-arg-snippet
1508
- (jupyter-completion--arg-extract))
1509
- (erase-buffer )))))
1510
- (setq match (aset matches i (substring match 0 end)))
1511
- (put-text-property 0 1 'snippet snippet match )
1512
- (put-text-property 0 1 'location (cons path line) match )))
1513
- ; ; TODO: This is specific to the results that
1514
- ; ; the python kernel returns, make a support
1515
- ; ; function?
1516
- ((string-match-p " \\ ." match )
1517
- (aset matches i (car (last (split-string match " \\ ." )))))))
1518
- (when buf (kill-buffer buf))))
1487
+ (with-temp-buffer
1488
+ (cl-loop
1489
+ for i from 0 below (length matches)
1490
+ for match = (aref matches i)
1491
+ do
1492
+ (put-text-property 0 1 'docsig match match )
1493
+ (cond
1494
+ ((string-match jupyter-completion-argument-regexp match )
1495
+ (let* ((str match )
1496
+ (args-str (match-string 1 str))
1497
+ (end (match-end 1 ))
1498
+ (path (match-string 2 str))
1499
+ (line (string-to-number (match-string 3 str)))
1500
+ (snippet (progn
1501
+ (erase-buffer )
1502
+ (insert args-str)
1503
+ (goto-char (point-min ))
1504
+ (jupyter-completion--make-arg-snippet
1505
+ (jupyter-completion--arg-extract)))))
1506
+ (setq match (aset matches i (substring match 0 end)))
1507
+ (put-text-property 0 1 'snippet snippet match )
1508
+ (put-text-property 0 1 'location (cons path line) match )))
1509
+ ; ; TODO: This is specific to the results that
1510
+ ; ; the python kernel returns, make a support
1511
+ ; ; function?
1512
+ ((string-match-p " \\ ." match )
1513
+ (aset matches i (car (last (split-string match " \\ ." ))))))))
1519
1514
; ; When a type is supplied add it as an annotation
1520
1515
(when-let* ((types (plist-get metadata :_jupyter_types_experimental ))
1521
1516
(lengths (mapcar #'length matches)))
0 commit comments