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: Mon, 14 Jan 2008 20:17:36 -0700
User-agent: Thunderbird 1.5.0.14 (Macintosh/20071210)

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

,----[ C-h f user-variable-p RET ]
| user-variable-p is a built-in function in `C source code'.
| (user-variable-p variable)
|
| Return t if variable is intended to be set and modified by users.
| (The alternative is a variable used internally in a Lisp program.)
| A variable is a user variable if
| (1) the first character of its documentation is `*', or
| (2) it is customizable (its property list contains a non-nil value
|     of `standard-value' or `custom-autoload'), or
| (3) it is an alias for another user variable.
| Return nil if variable is an alias and there is a loop in the
| chain of symbols.
|
| [back]
`----

So:

(defvar my-special-dir-a "/path/to/my/special/dir"
  "*Special directory `a'.")

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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