help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using variable names as args to interactive functions


From: Kevin Rodgers
Subject: Re: using variable names as args to interactive functions
Date: Tue, 15 Jan 2008 20:01:05 -0700
User-agent: Thunderbird 1.5.0.14 (Macintosh/20071210)

Stuart wrote:
Here's what I ended up doing:

First I changed all the my script to generate the variables as
defvar's instead of setq's:
  (defvar my-special-dir-a "/path/to/my/special/dir" "*Special
directory `a'.")

This allows the "*" to make it a user variable so it can be read by
the interactive prompt.

Now my definition looks like this:

(defun find-my-special-dir (dir)
        (interactive "vSpecial Directory: ")
        (find-file (symbol-value (symbol-value 'dir))))

symbol-value 'dir returns the name of the variable the user types at
the prompt (i.e., my-special-dir-a)
Then the symbol-value on top of that returns the string "/path/to/my/
special/dir" and now it works!

(find-file (symbol-value dir)) ; dir should be renamed dir-sym

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

[Prev in Thread] Current Thread [Next in Thread]