From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: reading a variable from the user Date: Wed, 10 Oct 2012 07:13:36 -0700 Message-ID: References: <1349853875855-266778.post@n5.nabble.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1349878449 315 80.91.229.3 (10 Oct 2012 14:14:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Oct 2012 14:14:09 +0000 (UTC) To: "'drain'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 10 16:14:16 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TLx38-00008f-Ct for geh-help-gnu-emacs@m.gmane.org; Wed, 10 Oct 2012 16:14:14 +0200 Original-Received: from localhost ([::1]:49621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLx32-0001K0-10 for geh-help-gnu-emacs@m.gmane.org; Wed, 10 Oct 2012 10:14:08 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLx2r-0001IO-DJ for Help-gnu-emacs@gnu.org; Wed, 10 Oct 2012 10:14:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLx2h-0005xY-Qg for Help-gnu-emacs@gnu.org; Wed, 10 Oct 2012 10:13:57 -0400 Original-Received: from rcsinet15.oracle.com ([148.87.113.117]:32004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLx2h-0005xQ-Je for Help-gnu-emacs@gnu.org; Wed, 10 Oct 2012 10:13:47 -0400 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q9AEDjge015273 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 10 Oct 2012 14:13:46 GMT Original-Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q9AEDim3000586 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 10 Oct 2012 14:13:45 GMT Original-Received: from abhmt116.oracle.com (abhmt116.oracle.com [141.146.116.68]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q9AEDijb019730; Wed, 10 Oct 2012 09:13:44 -0500 Original-Received: from dradamslap1 (/10.159.222.233) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2012 07:13:44 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <1349853875855-266778.post@n5.nabble.com> Thread-Index: Ac2muFHKTfDsEcTJQ5q+H5TIuLG+LAAN8VVw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 148.87.113.117 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87153 Archived-At: > Is there a function that prompts the user in the mini-buffer, > matches the string input with a local variable name, and then > returns the variable? Not sure what you need. There is function `read-variable'. That works only for user options, in spite of the misleading name. See also function `read-any-variable' in library `strings.el': (defun read-any-variable (prompt &optional default-value) "Read name of a variable and return it as a symbol. Unlike `read-variable', which reads only user options, this reads the name of any variable. Prompts with arg string PROMPT. By default, return DEFAULT-VALUE if non-nil. If DEFAULT-VALUE is nil and the nearest symbol to the cursor is a variable, then return that by default." (let ((symb (cond ((fboundp 'symbol-nearest-point) (symbol-nearest-point)) ((fboundp 'symbol-at-point) (symbol-at-point)) (t nil))) (enable-recursive-minibuffers t)) (when (and default-value (symbolp default-value)) (setq default-value (symbol-name default-value))) (intern (completing-read prompt obarray 'boundp t nil 'minibuffer-history (or default-value (and (boundp symb) (symbol-name symb))) t)))) http://www.emacswiki.org/emacs-en/download/strings.el If you want functions like `symbol-nearest-point' then get http://www.emacswiki.org/emacs-en/download/thingatpt%2b.el There is also function `read-var-and-value' in library `simple+.el'. It does this: "Read a variable name and value. READ-VAR-FN is a function to read the variable name. SET-VAR-HIST-VAR is a variable holding a history of variable values. MAKE-LOCAL-P non-nil means the variable is to be local. Optional arg BUFFER is the buffer used to determine the current value of the variable, which is used as the default value when reading the new value." http://www.emacswiki.org/emacs-en/download/simple%2b.el