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

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

Re: What is the :eval form ?


From: Tassilo Horn
Subject: Re: What is the :eval form ?
Date: Fri, 08 Jun 2012 20:02:38 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.0.97 (gnu/linux)

Philippe M. Coatmeur <philippe.coatmeur@gmail.com> writes:

Hi Philippe,

> How can I find information about this special form ? When I ask emacs
> using C-h f with point over it, it acts like google and shows me the
> "plain eval" info page... :(

:eval is neither a function nor a special form, it is a keyword.

,----[ (info "(elisp)Symbol Type") ]
|    A symbol whose name starts with a colon (`:') is called a "keyword
| symbol".  These symbols automatically act as constants, and are
| normally used only by comparing an unknown symbol with a few specific
| alternatives.
`----

Some keywords have a special meaning for some variables such as
`global-mode-string', so let's check its docs instead of googling.

,----[ C-h v global-mode-string RET ]
| global-mode-string is a variable defined in `C source code'.
| Its value is ("" appt-mode-string)
| 
|   This variable is potentially risky when used as a file local variable.
| 
| Documentation:
| String (or mode line construct) included (normally) in `mode-line-format'.
`----

Ah, so I might want to check out `mode-line-format'.

,----[ C-h v mode-line-format RET ]
| mode-line-format is a variable defined in `C source code'.
| Its value is shown below.
| 
|   Automatically becomes buffer-local when set in any fashion.
|   This variable is potentially risky when used as a file local variable.
| 
| Documentation:
| [...]
| For a list of the form `(:eval FORM)', FORM is evaluated and the result
|  is used as a mode line element.  Be careful--FORM should not load any files,
|  because that can cause an infinite recursion.
| [...]
`----

So there's your :eval.  Another way to find out about the meaning of
eval was to use the emacs info docs.

  C-h i m elisp RET C-s :eval C-s [maybe repeatedly]

leads to:

,----[ (info "(elisp)Mode Line Data") ]
|    A mode line construct may be as simple as a fixed string of text,
| but it usually specifies how to combine fixed strings with variables'
| values to construct the text.  Many of these variables are themselves
| defined to have mode line constructs as their values.
| 
|    Here are the meanings of various data types as mode line constructs:
|
| [...]
|
| `(:eval FORM)'
|      A list whose first element is the symbol `:eval' says to evaluate
|      FORM, and use the result as a string to display.  Make sure this
|      evaluation cannot load any files, as doing so could cause infinite
|      recursion.
`----

Bye,
Tassilo




reply via email to

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