help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ‘(vterm local)’ is a malformed function


From: hw
Subject: Re: ‘(vterm local)’ is a malformed function
Date: Thu, 03 Aug 2023 21:25:22 +0200
User-agent: Evolution 3.48.4 (3.48.4-1.fc38)

On Thu, 2023-08-03 at 23:45 +0700, Yuri Khan wrote:
> On Thu, 3 Aug 2023 at 22:22, hw <hw@adminart.net> wrote:
> 
> > (defun my-connections (fqdns)
> >   "Set up a bunch of vterms, some with ssh connections."
> >   (if (not (get-buffer "local")) ((vterm "local")
>                                     ^
> You forgot a ‘progn’ here. In Lisp, you can’t just put a bunch of
> forms in parentheses and expect them all to execute sequentially like
> they do in C. The first expression in parentheses is expected to be a
> function, and the rest will be passed as its arguments.

Ohh --- thank you!  I think I never understood it that way, and it's
been such a long time that I wrote anything in elisp that it's all
difficult again because I forgot so many details.

> >                                   (vterm-send-string "cd")
> >                                   (vterm-send-return))
> >     (message "local terminal seems already open"))
> 
> Alternatively, since you have just one form in the ELSE branch, you
> could invert the test:
> 
>     (if (get-buffer "local")
>         (message "local terminal seems already open")
>       (vterm "local")
>       (vterm-send-string "cd")
>       (vterm-send-return))
> 
> The THEN branch allows a single form (which could be a ‘(progn …)’ if
> you need many); the ELSE branch allows multiple forms.

strange ...

> > It works fine, though I'm getting a warning:
> > 
> > 
> > ⛔ Warning (comp): connections.el:13:36: Warning: ‘(vterm local)’ is a 
> > malformed function
> > 
> > 
> > What's malformed about it?  It doesn't consider (vterm pretty-name) as
> > malformed ... "local" somehow gets unstringyfied?
> 
> (vterm pretty-name) is within a function body, which allows multiple forms.

Hm, this warning message seems quite misleading.  I'm not sure what it
could better say instead though.

When I look at the desription of if, it says that it'll "do THEN, else
do ELSE".  To me, that means that it'll will *do* (like evaluate) what
I say, like (vterm "local") --- not that it would treat THEN and ELSE
sometimes as a parameter of if and sometimes not (i. e. not when
"else").  What else is "do" supposed to mean here?  What does it "do"
with 5 in '(if (eq 1 1) 5 6)' other than returning 5 --- or 6 if 1
wasn't equal to 1?

And if (vterm "local") can not be treated as a parameter of if, maybe
the warning message could say exactly that.  And perhaps the
description of if could point out that "do THEN" means something else
than "do ELSE".  Both are called "expression", and they're not the
same because one gets evaluted and the other doesn't (What actually
happens to it?).

5 is a malformed function, or is it?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]