[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
indirect assignement in lisp
From: |
help-gnu-emacs |
Subject: |
indirect assignement in lisp |
Date: |
Tue, 29 Aug 2006 02:39:01 -0400 |
Hello all,
say I want to assign a variable a value.
The name of the variable being assigned should depend on the key pressed by the
user. Say, if user hits key "M-1" the variable to assign should be
`variable-1', and if the user hits "M-2", the variable to assign should be
`variable-2'.
I just don't seem to be able to figure out how to make this indirect assignment
(other than using a switch statement, of course!). This is a sample of what
I've been trying to do:
====================================================
(defvar marked-point-1 nil )
(defvar marked-point-2 nil )
(defun set-mark-point ()
(interactive)
( let ( point-name ( cmd-key last-command-char ) )
( if ( or ( < cmd-key 49 ) ( > cmd-key 50 ) )
( message "the key is %d how did you get here?" cmd-key )
( progn
( setq point-name ( concat "marked-point-" (number-to-string (-
cmd-key 48 ))))
; ( set (eval point-name) (list (current-buffer) (point) ) )
)
)
)
)
===============================================================
as one can see, point-name gets assigned to the variable name depending on the
key pressed, but how do I get that variable (marked-point-1 or marked-point-2
in this case) assigned a value. I tried many variants of the commented out
statement, all to no avail.
Any help would be greatly appreciated,
regards,
Vb
- indirect assignement in lisp,
help-gnu-emacs <=