From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: wael-zwaiter@gmx.com Newsgroups: gmane.emacs.help Subject: Re: Setting variables, argumunts in defun Date: Sat, 13 Feb 2021 17:52:58 +0100 Message-ID: References: <87blcnq5qz.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6483"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: Philip Kaludercic Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 13 17:53:27 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAyAg-0001ao-Bx for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 13 Feb 2021 17:53:26 +0100 Original-Received: from localhost ([::1]:50738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAyAf-0000rW-Eh for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 13 Feb 2021 11:53:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAyAJ-0000rP-3Q for help-gnu-emacs@gnu.org; Sat, 13 Feb 2021 11:53:03 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:42647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAyAH-0004KM-7v for help-gnu-emacs@gnu.org; Sat, 13 Feb 2021 11:53:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1613235178; bh=57lAtD35JiuC/jkqEAO1T0APXMfmK7kSXREM9dcFFVk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Rab3mw3OwRsNKhPc2T3aadyhkffjm6RQiDq9t2x4iGvcyKrvE1KuworBlcPeMlwrq yKtSlGuOVlrVHrHZM/QnODb59YPoXCJHPl3t0CDBoTcrt/JTFTlUgH7ANdsCj5LWp3 z7GXzygCeTyvH0hJAuB0OFkAibEUzlTtKJUW7G7s= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs12.server.lan [172.19.170.180]) (via HTTP); Sat, 13 Feb 2021 17:52:58 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <87blcnq5qz.fsf@posteo.net> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:iswgW5P2ZqkZUuH7DUHn50579cQ5h/1j8Wa7nCSRaxaxOKV8wn6ipEGsO1iQH/3Iaky9z 9y8LHI/mHuCWGY60LOAUyRpsrclzBQ/8YGw45HD4wnfR9ktlz4OeR2QfmnBfZBm/4ezNcxcGUP6v mWZScuKhLNS43CeJzj6hDuKlERRVd2f8xCqXHagHnRwzL8fd3l2nwVR1P/ykJz3ReFaE/Xj4QmHn KCFj+hOcHYDPK3aMUg5h7RBekCwXAKITDUZylBXuU/KWRK3b4anted2P4i3vCfM8gdw6pIsalOY5 jQ= X-UI-Out-Filterresults: notjunk:1;V03:K0:JUz/VH11HzY=:F4/jv5iLKFdH70aLaRKQe6 H7sllJSJe9qvw/y3p8NQchrOL+znHAzmGNFQ2jjlZjRdqt7wevPL4iu6NjYcpuVE+HEvfMT9t PzJKZstMMuE/1kor5Mu63lPk4nRHvmwHM5aQyeTvrMOBKZZiT5P/DehJB3VqgroEDDMg4R8EX b1WjheNruvknSBtQ80FYM5az2AzE5AJm0pVamKWKArVw8JqoPqKGMk1z29djyj58zQIUWFQRp jlfsF9gT7uwD4KMSaHATqxock0bJhwWB46D9finUl1e0gyv7ktZlSQ7DTLI9FLM28zwKEzthD cazH5BkgMIAPTCECHB5NpBzL5eXLuk/Ey88oON1+jEbGk1ip0m8PnO2z+yuLtZkJMVcW2om64 iBUPVeD6Bs7F7gA2rkqR8WHXweApc2b66esGPsNURxb1DOLqGsisBiEE4KJSCOdH+A+xIEMlr 7xtFHsLyMDm+RcCqHhynuoLy/8Wglg3tUcTyzkpSc9kJi+vIfTfqexPU+JgDZkxsK45slmFr3 6vWS28B/37aMbvhxQ/kJWrksuKRYke+42S1rKMQNgHyMOZ99WBcZ98FBenhPG+TTd9wXBboT2 n0MROo8s663aI= Received-SPF: pass client-ip=212.227.15.19; envelope-from=wael-zwaiter@gmx.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127961 Archived-At: Is the following valid? (setq-local devi 0.18 scal 1.0) > Sent: Sunday, February 14, 2021 at 4:42 AM > From: "Philip Kaludercic" > To: "Christopher Dimech" > Cc: wael-zwaiter@gmx.com, "Help Gnu Emacs" > Subject: Re: Setting variables, argumunts in defun > > Christopher Dimech 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" > >> 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. >