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

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

Re: About the `:variable' keyword in `define-minor-mode'


From: Michael Heerdegen
Subject: Re: About the `:variable' keyword in `define-minor-mode'
Date: Thu, 14 Feb 2013 16:53:13 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Stefan Monnier <address@hidden> 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.



reply via email to

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