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: a little help with basic elisp Date: Thu, 19 Feb 2015 23:52:06 -0800 (PST) Message-ID: <6c630eda-acec-4d89-88cf-0985b49742d6@default> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1424418761 1120 80.91.229.3 (20 Feb 2015 07:52:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 20 Feb 2015 07:52:41 +0000 (UTC) To: Glen Stark , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 20 08:52:28 2015 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 1YOiNw-0006Py-BZ for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Feb 2015 08:52:28 +0100 Original-Received: from localhost ([::1]:59382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOiNv-0003t9-LS for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Feb 2015 02:52:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOiNj-0003sr-MB for help-gnu-emacs@gnu.org; Fri, 20 Feb 2015 02:52:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOiNf-0006b8-BK for help-gnu-emacs@gnu.org; Fri, 20 Feb 2015 02:52:15 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:49864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOiNf-0006a2-4a for help-gnu-emacs@gnu.org; Fri, 20 Feb 2015 02:52:11 -0500 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t1K7q8Bp030737 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 20 Feb 2015 07:52:09 GMT Original-Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t1K7q7bp015879 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 20 Feb 2015 07:52:08 GMT Original-Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t1K7q7Rc026360; Fri, 20 Feb 2015 07:52:07 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 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:102817 Archived-At: > (defun gas-push-sr-pair () > "I want to add a apair consisting of a the string I prompted for at the > mini-buffer, and the string yo" > (interactive) > (let (to-string) > =09(setq to-string (read-from-minibuffer (concat (thing-at-point > 'symbol) > " to: "))) > =09(add-to-list 'gas-sr-stack '(to-string . "yo")))) >=20 > When I run this, and do (insert (pop gas-sr-stack)), I get the > following: > gas-pop-word: Wrong type argument: char-or-string-p, (to-string . "yo") >=20 > What's tripping me up is it seems that the values stored in the char-or- > string-p are to-string and "yo". > I wanted to store the value which is currently in to-string, and "yo". >=20 > Can someone please explain to me what I am doing wrong? I'd like to > understand the language better, and of course solve my concrete problem. (defvar gas-sr-stack () "...") (defun gas-push-sr-pair () (interactive) (let ((to-string (read-from-minibuffer (concat (thing-at-point 'symbol) "= to: ")))) (add-to-list 'gas-sr-stack `(,to-string . "yo")))) And you want this instead of just (pop (car gas-sr-stack)): (let ((gas-sr (pop gas-sr-stack))) (insert (car gas-sr) (cdr gas-sr))) 1. Just bind `to-string' directly to the value you want it to have. (Not an error; it's just simpler.) 2. You need to evaluate `to-string' for the cons you want to add to the lis= t. Instead, you were inserting the constant cons (to-string . "yo") each ti= me. So use a comma inside a backtick - or use (cons to-string "yo"). 3. The main problem was that you were trying to insert the cons, not its ca= r and cdr (which are strings). Use `C-h f insert' to see info about `inse= rt'.