From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stuart Newsgroups: gmane.emacs.help Subject: Re: using variable names as args to interactive functions Date: Tue, 15 Jan 2008 17:42:24 -0800 (PST) Organization: http://groups.google.com Message-ID: <7623c908-28e8-4116-acc3-1a7196bb0c3e@e32g2000prn.googlegroups.com> References: <96f5c9ae-3f50-4f54-9537-92a27cd618e8@f47g2000hsd.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1200451239 30815 80.91.229.12 (16 Jan 2008 02:40:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Jan 2008 02:40:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 16 03:40:59 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JEyD0-0008Sl-IO for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Jan 2008 03:40:54 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JEyCc-0007Yo-40 for geh-help-gnu-emacs@m.gmane.org; Tue, 15 Jan 2008 21:40:30 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!e32g2000prn.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 48 Original-NNTP-Posting-Host: 208.71.56.11 Original-X-Trace: posting.google.com 1200447744 11508 127.0.0.1 (16 Jan 2008 01:42:24 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 16 Jan 2008 01:42:24 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e32g2000prn.googlegroups.com; posting-host=208.71.56.11; posting-account=kVXI5QoAAABVyFocW0ORjUYeX2nxhaP0 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.0.10) Gecko/20070221 Red Hat/1.5.0.10-0.1.el4 Firefox/1.5.0.10, gzip(gfe), gzip(gfe) X-HTTP-Via: 1.1 mold.dreamworks.com:3128 (squid/2.5.STABLE5) Original-Xref: shelby.stanford.edu gnu.emacs.help:155333 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:50741 Archived-At: 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! Thanks! 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