joaotavora / yasnippet

A template system for Emacs
http://joaotavora.github.io/yasnippet/
2.81k stars 311 forks source link

elpy-snippet-init-assignments - "Symbol’s value as variable is void: start-point" #1187

Open lu-pl opened 10 months ago

lu-pl commented 10 months ago

Emacs version: 29.2 yasnippet version: 20240124.258 (Melpa)

Snippets using elpy-snippet-init-assignments expand to error output "Symbol’s value as variable is void: start-point".

E.g.

# -*- mode: snippet -*-
# name: init
# key: init
# group : definitions
# --

def __init__(self${1:, args}):
    ${1:$(my/elpy-snippet-init-assignments yas/text)}

expands to

def __init__(self, args):
    Symbol’s value as variable is void: start-point

As a quick fix replacing start-point with (point) appears to work:

(defun fix/elpy-snippet-init-assignments (arg-string)
  "Return the typical __init__ assignments for arguments in ARG-STRING."
  (let ((indentation
     (make-string
      (save-excursion
        (goto-char (point))
        (current-indentation))
      ?\s)))
    (mapconcat
     (lambda (arg)
       (if (string-match "^\\*" arg)
       ""
     (format "self.%s = %s\n%s" arg arg indentation)))
     (elpy-snippet-split-args arg-string) "")))
monnier commented 9 months ago

What/where is my/elpy-snippet-init-assignments? It sounds like the error is coming from that function, which is not part of YASnippet, AFAICT.