From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Keywords as function arguments for control flow Date: Sat, 30 Nov 2024 14:47:36 +0300 Message-ID: <555DCC6F-72A4-428F-8AF3-1839FC1EB734@gnu.support> References: 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="24247"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: K-9 Mail for Android To: Heime , Heime via Users list for the GNU Emacs text editor Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 30 12:49:16 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 1tHLyN-0006Di-Oa for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 30 Nov 2024 12:49:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHLxv-00034Z-Rf; Sat, 30 Nov 2024 06:48:47 -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 1tHLxu-00034J-5w for help-gnu-emacs@gnu.org; Sat, 30 Nov 2024 06:48:46 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tHLxs-0001sA-M3 for help-gnu-emacs@gnu.org; Sat, 30 Nov 2024 06:48:45 -0500 Original-Received: from [127.0.0.1] ([::ffff:197.239.10.196]) (AUTH: PLAIN admin, TLS: TLS1.3,128bits,ECDHE_RSA_AES_128_GCM_SHA256) by stw1.rcdrun.com with ESMTPSA id 0000000000081FDF.00000000674AFB66.002F0FA7; Sat, 30 Nov 2024 04:47:47 -0700 In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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:148462 Archived-At: (defun cuprat (seqr) (pcase seqr ('global (global-whitespace-mode 1)) ;; if seqr is 'global (_ (whitespace-mode 1)))) ;; default case for other values (cuprat 'global) (cuprat 'other) Explanation pcase matches the argument seqr to specific patterns (like 'global)=2E If seqr is 'global, it applies (global-whitespace-mode 1)=2E The underscore (_) is a catch-all pattern that matches anything else, so i= n that case, (whitespace-mode 1) is called=2E (defun cuprat (seqr) (cond ((eq seqr 'global) (global-whitespace-mode 1)) ;; if seqr is 'global (t (whitespace-mode 1)))) ;; default case for ot= her values (cuprat 'global) (cuprat 'other) Explanation The cond form evaluates each condition in order=2E The first condition checks if seqr is 'global, and if so, it runs (global-= whitespace-mode 1)=2E The (t =2E=2E=2E) clause is a fallback that handles all other cases, apply= ing (whitespace-mode 1)=2E Personally I have not ever used pcase Jean