From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.help Subject: Re: Setting variables, argumunts in defun Date: Sat, 13 Feb 2021 18:08:06 +0100 Message-ID: <875z2vq4jt.fsf@posteo.net> References: <87blcnq5qz.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33034"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: Help Gnu Emacs To: wael-zwaiter@gmx.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 13 18:09:01 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 1lAyPl-0008UH-8d for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 13 Feb 2021 18:09:01 +0100 Original-Received: from localhost ([::1]:36714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAyPk-0008IL-Bk for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 13 Feb 2021 12:09:00 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAyP1-0008IC-I1 for help-gnu-emacs@gnu.org; Sat, 13 Feb 2021 12:08:15 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:58407) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAyOy-000086-TW for help-gnu-emacs@gnu.org; Sat, 13 Feb 2021 12:08:15 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 207EC160060 for ; Sat, 13 Feb 2021 18:08:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1613236090; bh=aFJHL9vS3mykIhzQNSqXs1FbhMrgmXJ+ZTuHBcqhejo=; h=From:To:Cc:Subject:Date:From; b=QNRXpXpLdkj72g95Sk19VvE6QrJPQmJ/9bdEGhutjN4Lsf21sQ2RgY1BsqIXABfEO tiGgphJUeQT1LjzxK3tHtb76+a68AZEOB2uNannzthSaXzR0HggsqlkDaguKO1U0MD izds4Mb5A+vtOtDtT/+r3lQcORe76Vuw2Y+ZBRXrKC/Z8Syyod2JnmnF6QEJLjqosL BjdHw+mnHnIL+RB8FLB9ohyk+pkpFm395RqWkKY4xjKIgTwUs2CAMeG7xib//GCMjY uTJ8ajnPDFGNYxycVz2Ab4HDrrbm2WoeYlP0ovrywHjjRs2j4limI/5+t4ziC+sDb4 4vs10BuUpvgsA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DdGyx29q1z9rxX; Sat, 13 Feb 2021 18:08:09 +0100 (CET) In-Reply-To: (wael-zwaiter@gmx.com's message of "Sat, 13 Feb 2021 17:52:58 +0100") Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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:127963 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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" >> 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. >> =2D-=20 Philip K. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCAAxFiEEbW+YL3e0aNnYosjIGB9bla4wszYFAmAoB3YTHHBoaWxpcGtA cG9zdGVvLm5ldAAKCRAYH1uVrjCzNp7FC/4tsUkrjnMTwxZHEq+Dmawt5mFPKMop exLeSzguESZRYVHUEyCL9HdzPVctHK9SzdN9a0wvQXWmSztXTTqkjDSSvHW9U2sC XuEq+Z1QHXVQnFkEsxII3LwazSAGjSJMXNvZz92P1KCwCu5c8hLIxZXNVia1/t2g xPzihjfQOy2G/CwzenYNDMaoHNOK2B2Sal0WetKsVt6q7v4bHKObUKeczpKFi/Xv pVJmlYjvPUw58RIkFW0wHqivEY9/iNueZXpQeVTmJHuZt/uNEjNZrk7UwNXHmh9q bw1yqMBa+x0dZr42n7m4HPhiGWF1OnxYDowpvOg0c8q0bpspdEWMzpX5qiAHrX2g Wn4pH7G6FqtSWTjMfJgE734H6oFUs9lqh4eB0junn/BgU01VIxK/VbM+qitEm9GH 8XC4fiUVzeYvc5LspbuBukIdemhIqYuI/yGa+3DTvG9COAzWbYa2RDQe9if1zizz yfWqaw2PC+RYDTysHzFNqaDKB9Uo9XkaGNE= =WIII -----END PGP SIGNATURE----- --=-=-=--