Open quazgar opened 4 weeks ago
Simple test (after loading the definitions python-args-to-docstring
and python-split-args
in .yas-setup.el
):
(let ((yas-text "foo"))
(python-args-to-docstring))
Output:
Debugger entered--Lisp error: (wrong-type-argument listp "foo")
nth(0 "foo")
(length (nth 0 x))
(closure (t) (x) (length (nth 0 x)))("foo")
mapcar((closure (t) (x) (length (nth 0 x))) ("foo" "bar"))
(apply 'max (mapcar #'(lambda (x) (length (nth 0 x))) args))
(if args (apply 'max (mapcar #'(lambda (x) (length (nth 0 x))) args)) 0)
(let* ((indent (concat "\n" (make-string (current-column) 32))) (args (python-split-args yas-text)) (max-len (if args (apply 'max (mapcar #'(lambda ... ...) args)) 0)) (formatted-args (mapconcat #'(lambda (x) (concat (nth 0 x) (make-string ... 32) " -- " (if ... ...))) args indent))) (if (string= formatted-args "") nil (mapconcat 'identity (list "Keyword Arguments:" formatted-args) indent)))
python-args-to-docstring()
(let* ((yas-text "foo: str, bar: int = 3")) (python-args-to-docstring))
elisp--eval-last-sexp(nil)
eval-last-sexp(nil)
funcall-interactively(eval-last-sexp nil)
command-execute(eval-last-sexp)
As a quick bugfix, this snippet works:
(defun python-split-args (arg-string)
"Split a python argument string ARG-STRING into a list ((name), ...) of argument names."
(mapcar 'list
(mapcar (lambda (x)
(when (string-match python-split-arg-arg-regex x)
(match-string-no-properties 1 x)))
(split-string arg-string python-split-arg-separator t))))
It does not keep the default values or types, though.
Maybe issue #1200 from yasnippet rather belongs here? Possibly introduced by #465,
I can reproduce this with plain Emacs: