help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function passing flag


From: goncholden
Subject: Re: Function passing flag
Date: Tue, 08 Mar 2022 20:28:22 +0000

------- Original Message -------

On Tuesday, March 8th, 2022 at 8:09 PM, Corwin Brust <corwin@bru.st> 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 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)))

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.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]