From 3debb298e1e23f2b930800834192b39d438a9286 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Wed, 19 Dec 2018 20:56:47 -0600 Subject: [PATCH] jupyter-completion--arg-extract: Handle `;` in Julia kernels This also saves the separator after an argument so that `jupyter-completion--make-arg-snippet` uses the right separator (either `,` or `;`) --- jupyter-client.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/jupyter-client.el b/jupyter-client.el index 3bbab4b..4b7f868 100644 --- a/jupyter-client.el +++ b/jupyter-client.el @@ -1343,7 +1343,7 @@ Works for Julia and Python." (string-trim (buffer-substring-no-properties start (1- (point))))))) - (while (re-search-forward ",\\|::" nil t) + (while (re-search-forward ",\\|::\\|;" nil t) (setq ppss (syntax-ppss) depth (nth 0 ppss) inner (nth 1 ppss)) @@ -1352,15 +1352,16 @@ Works for Julia and Python." (if (eq (char-after) ?{) (push (jupyter-completion--arg-extract-1 (point)) inner-args) (push (list (list (funcall get-sexp))) inner-args))) - (?, + ((or ?, ?\;) (if (/= depth 1) (push (jupyter-completion--arg-extract-1 inner) inner-args) - (push (cons (funcall get-string start) (pop inner-args)) + ;; ((string . sep) . inner-args) + (push (cons (cons (funcall get-string start) (char-before)) (pop inner-args)) arg-info) (skip-syntax-forward "-") (setq start (point)))))) (goto-char (point-max)) - (push (cons (funcall get-string start) (pop inner-args)) arg-info) + (push (cons (cons (funcall get-string start) nil) (pop inner-args)) arg-info) (nreverse arg-info))) (defun jupyter-completion--make-arg-snippet (args) @@ -1369,11 +1370,12 @@ Works for Julia and Python." with i = 1 for top-args in args ;; TODO: Handle nested arguments - for (arg . inner-args) = top-args - collect (format "${%d:%s}" i arg) into constructs + for ((arg . sep) . inner-args) = top-args + collect (format (concat "${%d:%s}" (when sep "%c")) i arg sep) + into constructs and do (setq i (1+ i)) finally return - (concat "(" (mapconcat #'identity constructs ", ") ")"))) + (concat "(" (mapconcat #'identity constructs " ") ")"))) ;;;;; Completion prefix