all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using variables to set defaults to parameters
@ 2022-02-03 14:55 goncholden via Users list for the GNU Emacs text editor
  2022-02-03 16:24 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 4+ messages in thread
From: goncholden via Users list for the GNU Emacs text editor @ 2022-02-03 14:55 UTC (permalink / raw)
  To: goncholden via Users list for the GNU Emacs text editor

I am currently defining a minor-mode with default parameters, but want to pass defaulted variables
instead. What is the way to do this, using setq ?

(define-minor-mode rich-minor-mode
"Brief description" nil "" nil

then changed to

(setq initval nil)
(setq mdline-indic "")
(setq other nil)

(define-minor-mode rich-minor-mode
"Brief description" initval mdline-indic other

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using variables to set defaults to parameters
  2022-02-03 14:55 Using variables to set defaults to parameters goncholden via Users list for the GNU Emacs text editor
@ 2022-02-03 16:24 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2022-02-03 18:20   ` goncholden
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-02-03 16:24 UTC (permalink / raw)
  To: help-gnu-emacs

> I am currently defining a minor-mode with default parameters, but want
> to pass defaulted variables instead.  What is the way to do this,
> using setq ?
>
> (define-minor-mode rich-minor-mode
> "Brief description" nil "" nil

Don't use this long obsolete form.  Use the keyword arguments, instead:

    (define-minor-mode rich-minor-mode
      "Brief description"
      :lighter "")

> then changed to
>
> (setq initval nil)
> (setq mdline-indic "")
> (setq other nil)

I don't know what you mean with "then changed" nor where the above code
is intended to be placed (inside the `define-minor-mode`?  In some
other function?).


        Stefan




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Using variables to set defaults to parameters
  2022-02-03 16:24 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2022-02-03 18:20   ` goncholden
  2022-02-03 18:43     ` goncholden
  0 siblings, 1 reply; 4+ messages in thread
From: goncholden @ 2022-02-03 18:20 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs


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

On Thursday, February 3rd, 2022 at 4:24 PM, Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> I am currently defining a minor-mode with default parameters, but want
>
> to pass defaulted variables instead. What is the way to do this,
>
> using setq ?
>
> (define-minor-mode rich-minor-mode
>
> "Brief description" nil "" nil

Don't use this long obsolete form. Use the keyword arguments, instead:

(define-minor-mode rich-minor-mode

"Brief description"

:lighter "")

> then changed to
>
> (setq initval nil)
>
> (setq mdline-indic "")
>
> (setq other nil)

I don't know what you mean with "then changed" nor where the above code
is intended to be placed (inside the `define-minor-mode`? In some
other function?).

Stefan

Have been trying to pass the parameters with names that mean something, rather than
using

(define-minor-mode rich-minor-mode "Brief description" nil "" nil

so I would have

(define-minor-mode rich-minor-mode "Brief description" initval mdline-indic other

Where can I find some information on using the keyword arguments? I only know about the
long obsolete form.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using variables to set defaults to parameters
  2022-02-03 18:20   ` goncholden
@ 2022-02-03 18:43     ` goncholden
  0 siblings, 0 replies; 4+ messages in thread
From: goncholden @ 2022-02-03 18:43 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

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

On Thursday, February 3rd, 2022 at 6:20 PM, goncholden <goncholden@protonmail.com> wrote:

> ------- Original Message -------
>
> On Thursday, February 3rd, 2022 at 4:24 PM, Stefan Monnier via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org wrote:
>
> > I am currently defining a minor-mode with default parameters, but want
> >
> > to pass defaulted variables instead. What is the way to do this,
> >
> > using setq ?
> >
> > (define-minor-mode rich-minor-mode
> >
> > "Brief description" nil "" nil
>
> Don't use this long obsolete form. Use the keyword arguments, instead:
>
> (define-minor-mode rich-minor-mode
>
> "Brief description"
>
> :lighter "")
>
> > then changed to
> >
> > (setq initval nil)
> >
> > (setq mdline-indic "")
> >
> > (setq other nil)
>
> I don't know what you mean with "then changed" nor where the above code
>
> is intended to be placed (inside the `define-minor-mode`? In some
>
> other function?).
>
> Stefan
>
> Have been trying to pass the parameters with names that mean something, rather than
>
> using
>
> (define-minor-mode rich-minor-mode "Brief description" nil "" nil
>
> so I would have

> (define-minor-mode rich-minor-mode "Brief description" initval mdline-indic other

> Where can I find some information on using the keyword arguments? I only know about the
> long obsolete form.

What's the best thing to make code more readable?  Keywords as you say?  I do not want modeline
indicator for this.  I do not particularly understand initial values, how do they work?




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-03 18:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-03 14:55 Using variables to set defaults to parameters goncholden via Users list for the GNU Emacs text editor
2022-02-03 16:24 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-02-03 18:20   ` goncholden
2022-02-03 18:43     ` goncholden

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.