[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: when you gotta have a variable value for a symbol name
From: |
Drew Adams |
Subject: |
RE: when you gotta have a variable value for a symbol name |
Date: |
Wed, 23 Jul 2014 15:02:38 -0700 (PDT) |
> I want to evaluate (kmacro-name-last-macro variable), where I want the
> value of "variable" passed as the symbol name. Despite years of trying,
> I don't think I ever really conceptually "got" the distinction between
> symbols and variables and that seems to be critical here. I'm working
> with the code below, but it is not suceeding in naming the macros (no
> error messages, however). Of course (kmacro-name-last-macro 'my-macro)
> works just fine.
>
> (defun name-my-macro-sequentially ()
> "Names the last recorded macro as my-macro#, where # is a number
> sequentially incremented"
> (interactive)
> (unless (boundp 'my-macro-counter) (setq my-macro-counter 0))
> (setq my-macro-counter (1+ my-macro-counter))
> (let ((macro-name (format "my-macro-%d" my-macro-counter)))
> (kmacro-name-last-macro (make-symbol macro-name))
^^^^^^^^^^^
> (message "named keyboard macro %s" macro-name)))
Change `make-symbol' to `intern' and you're good to go. `make-symbol'
returns an uninterned symbol.