From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: wenbinye@gmail.com Newsgroups: gmane.emacs.help Subject: Re: indirect assignement in lisp Date: 29 Aug 2006 03:51:35 -0700 Organization: http://groups.google.com Message-ID: <1156848695.348934.164620@p79g2000cwp.googlegroups.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1156851645 1378 80.91.229.2 (29 Aug 2006 11:40:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 29 Aug 2006 11:40:45 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 29 13:40:43 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GI1xK-0002vj-6h for geh-help-gnu-emacs@m.gmane.org; Tue, 29 Aug 2006 13:40:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GI1xJ-0002PV-Oy for geh-help-gnu-emacs@m.gmane.org; Tue, 29 Aug 2006 07:40:33 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!p79g2000cwp.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 40 Original-NNTP-Posting-Host: 218.17.227.208 Original-X-Trace: posting.google.com 1156848700 729 127.0.0.1 (29 Aug 2006 10:51:40 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 29 Aug 2006 10:51:40 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Opera/9.01 (X11; Linux i686; U; zh-cn),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: p79g2000cwp.googlegroups.com; posting-host=218.17.227.208; posting-account=3wOHJA0AAAAYp1ktKqTr4LI0QMFE1g-B Original-Xref: shelby.stanford.edu gnu.emacs.help:141410 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:37030 Archived-At: you can get a symbol value from symbol name like this: (symbol-value (intern-soft (format "marked-point-%d" (- cmd-key 48)))) For a detail documents, see Info elisp 8.3 Creating and Interning Symbols help-gnu-emacs@vsbe.com wrote: > 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