From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: What is the type of user input? Date: Wed, 27 Oct 2004 14:36:24 -0600 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <2uaf6cF28g520U1@uni-berlin.de> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1098909441 19683 80.91.229.6 (27 Oct 2004 20:37:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 27 Oct 2004 20:37:21 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 27 22:37:15 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CMuXi-0006r8-00 for ; Wed, 27 Oct 2004 22:37:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CMufT-0000Op-GZ for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Oct 2004 16:45:15 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 77 Original-X-Trace: news.uni-berlin.de PP9GTwybWcQTQ634/336OwZJ+5lnRS2bG+RDEgFnMfMa07aGM= User-Agent: Mozilla Thunderbird 0.8 (X11/20040916) X-Accept-Language: en-us, en In-Reply-To: Original-Xref: shelby.stanford.edu gnu.emacs.help:126143 Original-To: help-gnu-emacs@gnu.org 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: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:21523 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21523 Hattuari wrote: > The following code demonstrates the problem I'm having: > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; create a property list and use it to map long strings > ;; to short strings > (setq paste-gl-type-map ()) > > (setq paste-gl-type-map (plist-put paste-gl-type-map 'GLbyte 'b)) > (setq paste-gl-type-map (plist-put paste-gl-type-map 'GLshort 's)) > (setq paste-gl-type-map (plist-put paste-gl-type-map 'GLint 'i)) > ;;... > > (plist-get paste-gl-type-map 'GLbyte) ;; test function call > > > (defun paste-gl-array(gl-type gl-components gl-vector) > "Map OpenGL types to corresponding sufixes.(GL\'type\' )" > (interactive "sType: \nnNumber 1 to 4: \nsVector: ") > (message " gl-type=%s, gl-components=%d, gl-vector=%s , suffix=%s" > gl-type gl-components gl-vector > (plist-get paste-gl-type-map gl-type)) > > ) > ;; end of application code > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > When I use the code by first `M-x eval-buffer' and then `M-x > paste-gl-arrayGLbyte4v', the result is a message > displayed in the echo area as follows: > > gl-type=GLbyte, gl-components=4, gl-vector=v , suffix=nil > > Notice that gl-type is displayed with the value I entered in the minibuffer > when it is passed to the first %s in the message string. It seems not to > be treated as a string when passed to plist-get, hence the 'suffix=nil'. gl-type is a string. Since the paste-gl-type-map property list is keyed by symbols, plist-get returns nil. The %s message specifier can be applied to any Lisp object, and symbols and strings are formatted the same. The solution is to either (1) read gl-type with the %S code or (2) call plist-get with (intern gl-type). > OTOH, when I evaluate this expression in an emacs-lisp buffer > (paste-gl-array 'GLbyte 4 'v), I see the following in the echo area: > > gl-type=GLbyte, gl-components=4, gl-vector=v , suffix=b > > That is the desired result. Why is this not the result of calling the > function as an interactive command as described above? > > I will continue to look for an answer in the documentation, but any help > from someone who knows the answer would be appreciated. It's not that hard to find: `C-h f message' has a link to the doc string for `format', which has a link to the doc string for `princ' in its description of %s: ,----[ C-h f princ RET ] | princ is a built-in function. | (princ OBJECT &optional PRINTCHARFUN) | | Output the printed representation of OBJECT, any Lisp object. | No quoting characters are used; no delimiters are printed around | the contents of strings. | | OBJECT is any of the Lisp data types: a number, a string, a symbol, | a list, a buffer, a window, a frame, etc. | | A printed representation of an object is text which describes that object. ...`---- -- Kevin Rodgers