From: Drew Adams <drew.adams@oracle.com>
To: Glen Stark <mail@glenstark.net>, help-gnu-emacs@gnu.org
Subject: RE: a little help with basic elisp
Date: Thu, 19 Feb 2015 23:52:06 -0800 (PST) [thread overview]
Message-ID: <6c630eda-acec-4d89-88cf-0985b49742d6@default> (raw)
In-Reply-To: <ILAFw.813229$394.409278@fx25.am4>
> (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)
> (setq to-string (read-from-minibuffer (concat (thing-at-point
> 'symbol)
> " to: ")))
> (add-to-list 'gas-sr-stack '(to-string . "yo"))))
>
> 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")
>
> 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".
>
> 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 list.
Instead, you were inserting the constant cons (to-string . "yo") each time.
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 car
and cdr (which are strings). Use `C-h f insert' to see info about `insert'.
prev parent reply other threads:[~2015-02-20 7:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 6:47 a little help with basic elisp Glen Stark
2015-02-20 7:39 ` Barry Margolin
2015-02-20 7:52 ` Drew Adams [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6c630eda-acec-4d89-88cf-0985b49742d6@default \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=mail@glenstark.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).