all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: help-gnu-emacs@vsbe.com
Cc: vb@vsbe.com
Subject: indirect assignement in lisp
Date: Tue, 29 Aug 2006 02:39:01 -0400	[thread overview]
Message-ID: <0MKoyl-1GHxFV3NlY-0001Iu@mrelay.perfora.net> (raw)


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

             reply	other threads:[~2006-08-29  6:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-29  6:39 help-gnu-emacs [this message]
     [not found] <mailman.5877.1156833550.9609.help-gnu-emacs@gnu.org>
2006-08-29 10:51 ` indirect assignement in lisp wenbinye
2006-08-29 15:46 ` Pascal Bourguignon
  -- strict thread matches above, loose matches on Subject: below --
2006-08-31  4:22 help-gnu-emacs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0MKoyl-1GHxFV3NlY-0001Iu@mrelay.perfora.net \
    --to=help-gnu-emacs@vsbe.com \
    --cc=vb@vsbe.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.