[Top][All Lists]

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

Re: using variable names as args to interactive functions

From: Stuart
Subject: Re: using variable names as args to interactive functions
Date: Tue, 15 Jan 2008 17:42:24 -0800 (PST)
User-agent: G2/1.0

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!


On Jan 11, 4:53 pm, Stuart <> wrote:
> I have some variables which I set at startup with setq. There are a
> bunch of variables that get set. Each is a string representing a
> directory path. I want a function which I can just type the variable
> name and it opens dired with that directory.
> However, this doesn't work because the interactive option "v" doesn't
> include the variables set with setq because this requires that: "A
> variable declared to be a user option (i.e., satisfying the predicate
> user-variable-p)."
> Any ideas? Thanks.
> (defun find-my-special-dir (dir)
>         (interactive "vSpecial dir: ")
>         (find-file dir))
> Example
> --------------
> startup:
>      (setq my-special-dir-a "/path/to/my/special/dir")
> minibuffer:
>      Special dir: my-special-dir-a

reply via email to

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