* Help making setq work on dynamic symbol
@ 2024-10-18 14:40 Ship Mints
2024-10-18 15:00 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Ship Mints @ 2024-10-18 14:40 UTC (permalink / raw)
To: Emacs Devel
[-- Attachment #1: Type: text/plain, Size: 658 bytes --]
Probably something silly but this seems esoteric enough to ask.
On Emacs 29.4:
(defmacro my/setq (name value)
(let ((sym (intern name)))
`(setq ,sym ,value)))
(defvar foo nil)
(my/setq "foo" t) ; this works
(intern (concat "f" "oo")) ; this works
(my/setq (concat "f" "oo") t) ; this fails with...
Debugger entered--Lisp error: (wrong-type-argument stringp (concat "f"
"oo"))
intern((concat "f" "oo"))
(let ((sym (intern name))) (list 'setq sym value))
(closure (t) (name value) (let ((sym (intern name))) (list 'setq sym
value)))((concat "f" "oo") t)
macroexpand((my/setq (concat "f" "oo") t))
elisp--eval-last-sexp(nil)
TIA,
-Stephane
[-- Attachment #2: Type: text/html, Size: 1804 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Help making setq work on dynamic symbol
2024-10-18 14:40 Help making setq work on dynamic symbol Ship Mints
@ 2024-10-18 15:00 ` Eli Zaretskii
2024-10-18 15:02 ` Ship Mints
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2024-10-18 15:00 UTC (permalink / raw)
To: Ship Mints; +Cc: emacs-devel
> From: Ship Mints <shipmints@gmail.com>
> Date: Fri, 18 Oct 2024 10:40:47 -0400
>
> (defmacro my/setq (name value)
> (let ((sym (intern name)))
> `(setq ,sym ,value)))
> (defvar foo nil)
> (my/setq "foo" t) ; this works
> (intern (concat "f" "oo")) ; this works
> (my/setq (concat "f" "oo") t) ; this fails with...
>
> Debugger entered--Lisp error: (wrong-type-argument stringp (concat "f" "oo"))
> intern((concat "f" "oo"))
> (let ((sym (intern name))) (list 'setq sym value))
> (closure (t) (name value) (let ((sym (intern name))) (list 'setq sym value)))((concat "f" "oo") t)
> macroexpand((my/setq (concat "f" "oo") t))
> elisp--eval-last-sexp(nil)
my/setq is a macro, not a function.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Help making setq work on dynamic symbol
2024-10-18 15:00 ` Eli Zaretskii
@ 2024-10-18 15:02 ` Ship Mints
2024-10-18 15:18 ` Visuwesh
2024-10-18 15:20 ` Andreas Schwab
0 siblings, 2 replies; 7+ messages in thread
From: Ship Mints @ 2024-10-18 15:02 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 956 bytes --]
Yessir. This fails, too, in the same way when I expect it to work:
(setq (intern (concat "f" "oo"))) t)
On Fri, Oct 18, 2024 at 11:00 AM Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Ship Mints <shipmints@gmail.com>
> > Date: Fri, 18 Oct 2024 10:40:47 -0400
> >
> > (defmacro my/setq (name value)
> > (let ((sym (intern name)))
> > `(setq ,sym ,value)))
> > (defvar foo nil)
> > (my/setq "foo" t) ; this works
> > (intern (concat "f" "oo")) ; this works
> > (my/setq (concat "f" "oo") t) ; this fails with...
> >
> > Debugger entered--Lisp error: (wrong-type-argument stringp (concat "f"
> "oo"))
> > intern((concat "f" "oo"))
> > (let ((sym (intern name))) (list 'setq sym value))
> > (closure (t) (name value) (let ((sym (intern name))) (list 'setq sym
> value)))((concat "f" "oo") t)
> > macroexpand((my/setq (concat "f" "oo") t))
> > elisp--eval-last-sexp(nil)
>
> my/setq is a macro, not a function.
>
[-- Attachment #2: Type: text/html, Size: 1732 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Help making setq work on dynamic symbol
2024-10-18 15:02 ` Ship Mints
@ 2024-10-18 15:18 ` Visuwesh
2024-10-18 15:20 ` Andreas Schwab
1 sibling, 0 replies; 7+ messages in thread
From: Visuwesh @ 2024-10-18 15:18 UTC (permalink / raw)
To: Ship Mints; +Cc: Eli Zaretskii, emacs-devel
[வெள்ளி அக்டோபர் 18, 2024] Ship Mints wrote:
> Yessir. This fails, too, in the same way when I expect it to work:
>
> (setq (intern (concat "f" "oo"))) t)
It should be (set (intern (concat "f" "oo")) t).
>
> On Fri, Oct 18, 2024 at 11:00 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
>> > From: Ship Mints <shipmints@gmail.com>
>> > Date: Fri, 18 Oct 2024 10:40:47 -0400
>> >
>> > (defmacro my/setq (name value)
>> > (let ((sym (intern name)))
>> > `(setq ,sym ,value)))
>> > (defvar foo nil)
>> > (my/setq "foo" t) ; this works
>> > (intern (concat "f" "oo")) ; this works
>> > (my/setq (concat "f" "oo") t) ; this fails with...
>> >
>> > Debugger entered--Lisp error: (wrong-type-argument stringp (concat "f"
>> "oo"))
>> > intern((concat "f" "oo"))
>> > (let ((sym (intern name))) (list 'setq sym value))
>> > (closure (t) (name value) (let ((sym (intern name))) (list 'setq sym
>> value)))((concat "f" "oo") t)
>> > macroexpand((my/setq (concat "f" "oo") t))
>> > elisp--eval-last-sexp(nil)
>>
>> my/setq is a macro, not a function.
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Help making setq work on dynamic symbol
2024-10-18 15:02 ` Ship Mints
2024-10-18 15:18 ` Visuwesh
@ 2024-10-18 15:20 ` Andreas Schwab
2024-10-18 15:24 ` Ship Mints
1 sibling, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2024-10-18 15:20 UTC (permalink / raw)
To: Ship Mints; +Cc: Eli Zaretskii, emacs-devel
On Okt 18 2024, Ship Mints wrote:
> (setq (intern (concat "f" "oo"))) t)
(set (intern (concat "f" "oo")) t)
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Help making setq work on dynamic symbol
2024-10-18 15:20 ` Andreas Schwab
@ 2024-10-18 15:24 ` Ship Mints
2024-10-18 15:53 ` Ship Mints
0 siblings, 1 reply; 7+ messages in thread
From: Ship Mints @ 2024-10-18 15:24 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Eli Zaretskii, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 495 bytes --]
set is a good tip. setq is a lifelong habit. I made my/set a function and
it works fine.
Thank you.
On Fri, Oct 18, 2024 at 11:20 AM Andreas Schwab <schwab@linux-m68k.org>
wrote:
> On Okt 18 2024, Ship Mints wrote:
>
> > (setq (intern (concat "f" "oo"))) t)
>
> (set (intern (concat "f" "oo")) t)
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
> "And now for something completely different."
>
[-- Attachment #2: Type: text/html, Size: 1158 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Help making setq work on dynamic symbol
2024-10-18 15:24 ` Ship Mints
@ 2024-10-18 15:53 ` Ship Mints
0 siblings, 0 replies; 7+ messages in thread
From: Ship Mints @ 2024-10-18 15:53 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Eli Zaretskii, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 735 bytes --]
Just reread the, of course, well-written documentation on set setq, el.al.
It's clear set is the choice here. Thanks, again, all.
On Fri, Oct 18, 2024 at 11:24 AM Ship Mints <shipmints@gmail.com> wrote:
> set is a good tip. setq is a lifelong habit. I made my/set a function and
> it works fine.
>
> Thank you.
>
>
> On Fri, Oct 18, 2024 at 11:20 AM Andreas Schwab <schwab@linux-m68k.org>
> wrote:
>
>> On Okt 18 2024, Ship Mints wrote:
>>
>> > (setq (intern (concat "f" "oo"))) t)
>>
>> (set (intern (concat "f" "oo")) t)
>>
>> --
>> Andreas Schwab, schwab@linux-m68k.org
>> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
>> "And now for something completely different."
>>
>
[-- Attachment #2: Type: text/html, Size: 1754 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-10-18 15:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-18 14:40 Help making setq work on dynamic symbol Ship Mints
2024-10-18 15:00 ` Eli Zaretskii
2024-10-18 15:02 ` Ship Mints
2024-10-18 15:18 ` Visuwesh
2024-10-18 15:20 ` Andreas Schwab
2024-10-18 15:24 ` Ship Mints
2024-10-18 15:53 ` Ship Mints
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).