From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Corwin Brust Newsgroups: gmane.emacs.help Subject: Re: Function passing flag Date: Tue, 8 Mar 2022 14:09:51 -0600 Message-ID: References: <87pmmwpbni.fsf@zoho.eu> <877d94p87y.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16388"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs mailing list , Emanuel Berg To: goncholden Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 08 21:11:24 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 1nRgAu-0003uX-HC for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Mar 2022 21:11:16 +0100 Original-Received: from localhost ([::1]:60686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRgAs-0000hj-VR for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Mar 2022 15:11:14 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRg9m-0000hO-Ez for help-gnu-emacs@gnu.org; Tue, 08 Mar 2022 15:10:06 -0500 Original-Received: from mail-ej1-f52.google.com ([209.85.218.52]:46890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRg9k-0003mE-Mi for help-gnu-emacs@gnu.org; Tue, 08 Mar 2022 15:10:06 -0500 Original-Received: by mail-ej1-f52.google.com with SMTP id qx21so256428ejb.13 for ; Tue, 08 Mar 2022 12:10:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=x2P00ksyuSOc2+siTlirarhK0EwryMawKj+pGzkU+1U=; b=XMMJqsyCVOS7yFR+k47KMXxB0rAg52taa35oLxHhvocCRC2kRMGCGGPoZ7tOxC7BMf 4JIEx+xLUZcddSw+88Fe/s3pdi4ZCDdle/yFhKbkNGxFo4nET37Nb5o8y+yBCv9/n69v PpYMOw/PB6M9Iz3YUBi7NGq1XL40TcgXdZOcHPue5yo5pXUet7MwR4xSvR2Oleqwl9xo OnExfwWzn2XOPauI08ieH1DVLYE0tQSV2VtR7pPAdvTmzlCAMwEqnBgnoIcOgM7pUILn 7TAgJQhM6BbtRfPZouQzDCBEqtbPC+K0X6dVHVAWwW32jBJ0kTs/jQ0h7OYW6fH4uW20 hCDw== X-Gm-Message-State: AOAM533ZJln2AhSbwc4kbZzQUpzGuk0a0mi5w8f57G1PI+CvwIADdCVU FTm8mAicSNd76zJDFk8TNgt6TDke5UagKN/Wg9U= X-Google-Smtp-Source: ABdhPJzMLQh5Gzy8uRSBo40PAWoKfwjsU1OHZqkNpkaCEJgv3h9hecJqWQk3SfIy9OeJaUMW1XnElAOqUhMsxDJoLg0= X-Received: by 2002:a17:907:1b0e:b0:6da:81ae:a798 with SMTP id mp14-20020a1709071b0e00b006da81aea798mr14142071ejc.699.1646770202597; Tue, 08 Mar 2022 12:10:02 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=209.85.218.52; envelope-from=mplscorwin@gmail.com; helo=mail-ej1-f52.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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:136405 Archived-At: On Tue, Mar 8, 2022 at 1:36 PM goncholden wrote: > > How does one do it with an optional argument? Where can I read about this? > 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))) Note, if you are defining a command (a function you will bind to a key or otherwise use interactively), you will want to to use (interactive), usually placed at the start of the function definition, so just after the docstring.