From: Philip Kaludercic <philipk@posteo.net>
To: wael-zwaiter@gmx.com
Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Re: Setting variables, argumunts in defun
Date: Sat, 13 Feb 2021 18:08:06 +0100 [thread overview]
Message-ID: <875z2vq4jt.fsf@posteo.net> (raw)
In-Reply-To: <trinity-c4ba5187-ef05-46d0-93ca-93653ca89e64-1613235178556@3c-app-mailcom-bs12> (wael-zwaiter@gmx.com's message of "Sat, 13 Feb 2021 17:52:58 +0100")
[-- Attachment #1: Type: text/plain, Size: 2765 bytes --]
wael-zwaiter@gmx.com writes:
> Is the following valid?
>
> (setq-local devi 0.18
> scal 1.0)
No, because setq-local only accepts one two arguments (variable and
value). Try C-h o setq-local, and you'll see it's documentation.
>> Sent: Sunday, February 14, 2021 at 4:42 AM
>> From: "Philip Kaludercic" <philipk@posteo.net>
>> To: "Christopher Dimech" <dimech@gmx.com>
>> Cc: wael-zwaiter@gmx.com, "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
>> Subject: Re: Setting variables, argumunts in defun
>>
>> Christopher Dimech <dimech@gmx.com> writes:
>>
>> > I am trying to use pcase on a string, but do need some direction
>> > on how to use it.
>>
>> Pcase is usually used like this
>>
>> (pcase objv
>> ("enable"
>> (setq devi 0.18)
>> (setq scal 0.2))
>> ("disable"
>> (setq devi 0.18)
>> (setq scal 1.0)))
>>
>> the first element it the expression that the execution depends on, and
>> every possible branch starts with a case. What you are doing looks more
>> like a cond-expression:
>>
>> (cond ((string-equal objv "enable")
>> (setq devi 0.18)
>> (setq scal 0.2))
>> ((string-equal objv "disable")
>> (setq devi 0.18)
>> (setq scal 1.0)))
>>
>> That being said, it's probably better to use a symbol ('enable and
>> 'disable) or a boolean value write this. Exploiting the fact that setq
>> can assign multiple variables at one, you could also write
>>
>> (if (eq objv 'enable)
>> (setq devi 0.18
>> scal 0.2)
>> (setq devi 0.18
>> scal 1.0))
>>
>> though depending on what you are doing, it might be better to avoid
>> setting global variables in the first place.
>>
>> > (pcase (string-match "enable" objv)
>> > (
>> > (setq devi 0.18)
>> > (setq scal 0.2) )
>> >
>> > ( (string-match "disable" objv)
>> > (setq devi 0.0)
>> > (setq scal 1.0) )
>> >
>> > )
>> >
>> >
>> >> Sent: Sunday, February 14, 2021 at 4:14 AM
>> >> From: wael-zwaiter@gmx.com
>> >> To: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
>> >> Subject: Setting variables, argumunts in defun
>> >>
>> >> I would like to set up devi and scal by selecting either one or
>> >> the other. Wow can I do this in elisp. Should I pass parameters
>> >> to the function. Can one pass a string, then check its contents?
>> >>
>> >> (defun deviscal ()
>> >>
>> >> (setq devi 0.18)
>> >> (setq scal 0.2)
>> >>
>> >> (setq devi 0.0)
>> >> (setq scal 1.0) )
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>>
>> --
>> Philip K.
>>
--
Philip K.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 686 bytes --]
next prev parent reply other threads:[~2021-02-13 17:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-13 16:14 Setting variables, argumunts in defun wael-zwaiter
2021-02-13 16:33 ` Christopher Dimech
2021-02-13 16:36 ` wael-zwaiter
2021-02-13 16:42 ` Philip Kaludercic
2021-02-13 16:52 ` wael-zwaiter
2021-02-13 16:57 ` tomas
2021-02-13 17:23 ` wael-zwaiter
2021-02-13 22:59 ` Michael Heerdegen
2021-02-13 17:08 ` Philip Kaludercic [this message]
2021-02-13 17:09 ` Philip Kaludercic
2021-02-13 19:15 ` Jean Louis
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875z2vq4jt.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=help-gnu-emacs@gnu.org \
--cc=wael-zwaiter@gmx.com \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.