From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: Keywords as function arguments for control flow Date: Sat, 30 Nov 2024 11:55:47 +0000 Message-ID: <8CHE2YXGxUmNQ6T0h8fwer42k9A2kWZtekFLSjo1iUh6YQWFRFlAgF75LJ5U4stImz_1yEfNwmDrVJPEpR6QJ_1mnMS0VWKKpxFyr3oGiMo=@protonmail.com> References: <555DCC6F-72A4-428F-8AF3-1839FC1EB734@gnu.support> Reply-To: Heime 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="9649"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 30 12:56:27 2024 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 1tHM5L-0002Nf-Ex for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 30 Nov 2024 12:56:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHM4t-00041z-JW; Sat, 30 Nov 2024 06:55:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tHM4q-00041a-8s for help-gnu-emacs@gnu.org; Sat, 30 Nov 2024 06:55:56 -0500 Original-Received: from mail-43166.protonmail.ch ([185.70.43.166]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tHM4o-0004VS-Jv for help-gnu-emacs@gnu.org; Sat, 30 Nov 2024 06:55:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1732967751; x=1733226951; bh=ZDOv01hiQQuqTS4XmKQ+xU3SihCVjsP0FP9iz8P3GUc=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=XSJMiiovfKtUbfx96HLmoRBz6faxch9ylYcSzcmG7kxpJm3iP+29j2gcVqxxTXp2K oUGC/mlvBGFKB9hz7W3mP46QEQHtBRrQGVr8CxcS0OY8ml6grwHvC1Vo2fEpLDJcnv rIBR9cI5N1sk339NRZbC80L+NIKmkmiBkWPfUTBH4sENAf460M4rHvIZg/PdNGMFeP vQpyOjmSzp2DqsGid/BjcPeqwqsn3ErennGON2ZmeMzMPxeHszjrVQ1tF1OCMv+FEY yzKF7mv0Lx8e28tqwwKjsHK4lhvq5iS2Emlwsou8glOnTudYviMyMjfLletSPt9ekM CTaKo0arD5mYw== In-Reply-To: <555DCC6F-72A4-428F-8AF3-1839FC1EB734@gnu.support> Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 91cdfa237ac8c0d05985f15d0a4d5a38ec1d8544 Received-SPF: pass client-ip=185.70.43.166; envelope-from=heimeborgia@protonmail.com; helo=mail-43166.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148463 Archived-At: Sent with Proton Mail secure email. On Saturday, November 30th, 2024 at 11:47 PM, Jean Louis = wrote: > (defun cuprat (seqr) > (pcase seqr > ('global (global-whitespace-mode 1)) ;; if seqr is 'global > (_ (whitespace-mode 1)))) ;; default case for other values >=20 > (cuprat 'global) > (cuprat 'other) >=20 >=20 > Explanation >=20 > pcase matches the argument seqr to specific patterns (like 'global). >=20 > If seqr is 'global, it applies (global-whitespace-mode 1). >=20 > The underscore (_) is a catch-all pattern that matches anything else, so = in that case, (whitespace-mode 1) is called. >=20 >=20 > (defun cuprat (seqr) > (cond > ((eq seqr 'global) (global-whitespace-mode 1)) ;; if seqr is 'global > (t (whitespace-mode 1)))) ;; default case for other values >=20 > (cuprat 'global) > (cuprat 'other) >=20 >=20 > Explanation >=20 > The cond form evaluates each condition in order. >=20 > The first condition checks if seqr is 'global, and if so, it runs (global= -whitespace-mode 1). >=20 > The (t ...) clause is a fallback that handles all other cases, applying (= whitespace-mode 1). >=20 >=20 > Personally I have not ever used pcase - Jean I have used both. The question is about how to pass keywords=20 (i.e. with :something) as function arguments.=20