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:42:07 -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="12837"; 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:42:46 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 1nRgfN-00037K-FJ for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Mar 2022 21:42:45 +0100 Original-Received: from localhost ([::1]:41332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRgfM-0000bE-HA for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Mar 2022 15:42:44 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRgez-0000aw-RX for help-gnu-emacs@gnu.org; Tue, 08 Mar 2022 15:42:21 -0500 Original-Received: from mail-ed1-f48.google.com ([209.85.208.48]:41869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRgey-0000fI-6v for help-gnu-emacs@gnu.org; Tue, 08 Mar 2022 15:42:21 -0500 Original-Received: by mail-ed1-f48.google.com with SMTP id c20so261234edr.8 for ; Tue, 08 Mar 2022 12:42:19 -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=ta7ZMgJChZ68KJvznOl3fVyMrDfW82xddu+TIVHDQ3Y=; b=DamNQqnVr+E1KJRt/NM0JDMGxdsRdUmRFRY9P9xT5nlrYBIGyLzWCT8rKbLDebXurc RmcYrKVUb3aO42x34K/Km0UNPTfCvzgoJM0l8ttxHLTCK3w2eDU/o5a2ZJmeKLUIqDOI 77nt4KugWoFbEDAyJHXoPdiNbxzs+hqVuwS0WRDrraWV3sF7tNQ0O6FjFTJXnocL0SvI TMkQhV/M5CGU7EbMnUBfuwVeA3fETpZ2SvqsUFxIklIdvmWEO63R1Nc/nddEVKa3yPFp 5TDBdKHTKmA7suaPnpGZ5LJxz1ciql1guDeI9FdX1twmkF94WsMchq/i7mPjGiDYZbaQ SM0Q== X-Gm-Message-State: AOAM5324gnpPuQ5vjg2UNtLzSSt1AP5nFMrj3204aNW6YSmmwPW24f0q LYFIXnjV1wifajl4xs5dTSHRIQurJ65LCjO+YSc= X-Google-Smtp-Source: ABdhPJznHx6TtitkKZ40tTR/fGQlr3wJF3QkhOUTwtkAgb5l86vz2MJUIJFgrdKYoUMGoPmG4CBw8UT2mIzTL+/0dFI= X-Received: by 2002:a50:9505:0:b0:416:4496:5ec4 with SMTP id u5-20020a509505000000b0041644965ec4mr12442015eda.309.1646772138857; Tue, 08 Mar 2022 12:42:18 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=209.85.208.48; envelope-from=mplscorwin@gmail.com; helo=mail-ed1-f48.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_H2=-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:136408 Archived-At: On Tue, Mar 8, 2022 at 2:28 PM goncholden wrote: > > Would like to use arg as a switch so I can enable or disable some emacs modes (customarily using > value of 1 to enable, and -1 to disable). If no arg is supplied, I would like to enable the modes. > > How would I define the parameter outside the function, and then pass it through. I might require > a buffer local variable. > One typical way of doing this would be to use the "universal argument", also known as a "prefix argument": (info "(elisp)Prefix Command Arguments") Here's an example that would create an interactive command that enables tool-bars and scroll-bars or, with a prefix argument, disables them. (defun my:enable-bars (&optional arg) "Enable `tool-bar-mode' and `scroll-bar-mode'. When ARG is non-nill, disable them." (interactive "P") (if arg (progn (tool-bar-mode -1) (scroll-bar-mode -1)) (tool-bar-mode 1) (scroll-bar-mode 1))) Once you evaluate this you can ensure both tool-bar and scroll bar modes are active with: M-x my:enable-bar RET Or, to ensure both tool-bar and scroll-bar modes are disabled: C-u M-x my:enable-bar RET