Macro to Make Identifiers from String Diagram

Hi, @joeld. I understood it in terms of the following, although I am obviously unclear about the matter at large:

The context being passed to prefix-id in my original attempt is "removed" from where I want it to be, because I am not referencing the original scope, i.e. the context inside of (name-pt ...) is "fresh", but in the answers from @soegaard and @sorawee, the context is the same as the original call to the macro, i.e., the stx in the code below.

(define-syntax (parse-diagram stx)
  (syntax-parse stx
    [(parse-diagram WHOLE)     
     (with-syntax ([((id x y) ...) (find-ids-and-positions (syntax->datum #'WHOLE))])       
       (with-syntax ([(id ...) (change-contexts stx #'(id ...))])
         #'(begin
             (define id (pt x y))
             ...)))]))

For what it's worth, I have gotten a similar thing to work before, to name desired directory paths so that I can reference the paths more easily when creating files and folders, by way of this code:

#lang br

(define (normalize elements)
  (map (lambda (x)
         (if (path? x) x (symbol->string x)))
       (reverse elements)))

(define-macro-cases make-named-paths
  [(make-named-paths in ROOT using SIGIL [DIR ...] ...)
   #'(begin
       (walk-paths SIGIL `[,ROOT] [DIR ...])
       ...)]
  
  [(make-named-paths in ROOT [DIR ...] ...)
   #'(begin
       (make-named-paths in ROOT using @ [DIR ...])
       ...)])

(define-macro-cases walk-paths
  [(walk-paths SIGIL PATH [.. CONTENT ...])
   #'(begin
       (walk-paths SIGIL PATH CONTENT)
       ...)]
  
  [(walk-paths SIGIL PATH [NAME CONTENT0 CONTENT ...])
   (with-pattern ([$NAME (prefix-id #'SIGIL #'NAME)])
     #'(begin
         (define $NAME
           (path->directory-path
            (apply build-path (normalize (cons 'NAME PATH)))))
         
         (walk-paths SIGIL (cons 'NAME PATH) CONTENT0)
         (walk-paths SIGIL (cons 'NAME PATH) CONTENT)
         ...))]
  
  [(walk-paths SIGIL PATH [NAME])
   (with-pattern ([$NAME (prefix-id #'SIGIL #'NAME)])
     #'(define $NAME
         (path->directory-path
          (apply build-path (normalize (cons 'NAME PATH))))))]
  
  [(walk-paths SIGIL PATH NAME)
   (with-pattern ([$NAME (prefix-id #'SIGIL #'NAME)])
     #'(define $NAME
         (apply build-path (normalize (cons 'NAME PATH)))))])

;; here I use these definitions
(make-named-paths
 in    (find-system-path 'temp-dir)
 using $
 [.. archive.zip hide-wallpaper.jpg]
 [HOME self.exe spaghetti.exe data.txt data.zip live.ps1 yeet.ps1 wallpaper.jpg])

(make-named-paths
 in    (find-system-path 'doc-dir)
 using $
 [.. logs.txt hide-self.exe])

$self.exe

#path:C:\Users\CHRIST~1\AppData\Local\Temp\HOME\self.exe

Perhaps it is as you say, because of the derived syntax object when using the with-syntax* in my original attempt. I can see the outline but not necessarily all the details.