From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: goncholden Newsgroups: gmane.emacs.help Subject: Re: Function passing flag Date: Tue, 08 Mar 2022 20:28:22 +0000 Message-ID: References: <87pmmwpbni.fsf@zoho.eu> <877d94p87y.fsf@zoho.eu> Reply-To: goncholden 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="24126"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs mailing list , Emanuel Berg To: Corwin Brust Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 08 21:28:51 2022 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 1nRgRv-00064F-MI for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Mar 2022 21:28:51 +0100 Original-Received: from localhost ([::1]:38812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRgRu-0006KZ-4V for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Mar 2022 15:28:50 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRgRY-0006KP-L5 for help-gnu-emacs@gnu.org; Tue, 08 Mar 2022 15:28:28 -0500 Original-Received: from mail-40135.protonmail.ch ([185.70.40.135]:26880) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRgRV-0006si-O5 for help-gnu-emacs@gnu.org; Tue, 08 Mar 2022 15:28:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1646771303; bh=pKwQNsuvUxx/R3ynbfjP6FAX/0U8SDVVnSC5SICmjjk=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=Etg/hGSiZyDonx5H0ES1fhXH2k9hagqJj/OBbySLYjXU3WWVBLKnRG9IEBApcu54+ ly0P+BB8or4bNtU+J+MkhsRQ1fEIRrrJW+yP3xBRABL1y/BMirUE0wpE//ZsuGF2gc ongC3ybMdzKqD7sLBTSilzcgpzWquX5U8ZKadJaE7nPUlwwTVd4NyPJCZ2kpgNUjde 464VZy2KdGq7lw+WGHhUoOZF4Vtw0hsvL67W9PGOPAPNOuyjRZSskrgKMj25ESMi08 4tyCoWOzP6xIAUTF3qO4+eM/oDGzf6XnphaqKeSDMIGsZGE3tFkb6tGH07E/NzjWWn 3SpX7UW0rva3w== In-Reply-To: Received-SPF: pass client-ip=185.70.40.135; envelope-from=goncholden@protonmail.com; helo=mail-40135.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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" Xref: news.gmane.io gmane.emacs.help:136407 Archived-At: ------- Original Message ------- On Tuesday, March 8th, 2022 at 8:09 PM, Corwin Brust wrote: > On Tue, Mar 8, 2022 at 1:36 PM goncholden goncholden@protonmail.com wrote= : > > > How does one do it with an optional argument? Where can I read about th= is? > > A function with an optional argument ARG might look like this: > > (defun my:own-fun (&optional arg) > "Do something. When ARG is non-nil do it a lot." > (if arg > ;; when ARG is true we run this > (do-stuff) > ;; else we run this > (do-more-or-different-stuff))) Would like to use arg as a switch so I can enable or disable some emacs mod= es (customarily using value of 1 to enable, and -1 to disable). If no arg is supplied, I would l= ike to enable the modes. How would I define the parameter outside the function, and then pass it thr= ough. I might require a buffer local variable.