all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: About the `:variable' keyword in `define-minor-mode'
Date: Thu, 14 Feb 2013 16:53:13 +0100	[thread overview]
Message-ID: <87a9r6df0w.fsf@web.de> (raw)
In-Reply-To: <mailman.19937.1360854183.855.help-gnu-emacs@gnu.org> (Stefan Monnier's message of "Thu, 14 Feb 2013 10:02:32 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> > In the docstring of `define-minor-mode':
> >   [...]
> >   :variable PLACE [...]
> >                 PLACE can also be of the form (GET . SET), where GET is
> >                 an expression that returns the current state, and SET
> >                 is a function that takes one argument, the new state,
> >                 and sets it.
>
> > I don't understand the meaning of GET.  The docstring says it returns
> > the current state, but where will it return?
>
> It will return it to the context?

I think he wanted to know where and how it is referenced/used (in the code).

Xue, please have a look at the definition of the macro
`define-minor-mode'.  The GET part is used in the defun of the modefun,
after these lines:

       ;; The actual function.
       (defun ,modefun (&optional arg ,@extra-args)

There, the variable `mode' is bound to the GET expression.  It is mainly
used to check if the mode is on or off, but it is also `setf'ed if SET
is nil.

So, if e.g. GET is `(car foo)', the car of the value of the variable
`foo' will be looked at to decide whether the mode is turned on or off.

Does this help?


Regards,

Michael.



  parent reply	other threads:[~2013-02-14 15:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14 14:37 About the `:variable' keyword in `define-minor-mode' Xue Fuqiao
2013-02-14 15:02 ` Stefan Monnier
     [not found] ` <mailman.19937.1360854183.855.help-gnu-emacs@gnu.org>
2013-02-14 15:53   ` Michael Heerdegen [this message]
2013-02-14 15:53   ` Michael Heerdegen
  -- strict thread matches above, loose matches on Subject: below --
2013-02-14 23:50 Xue Fuqiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a9r6df0w.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.