unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Whats wrong with this defcustom?
@ 2014-07-26 10:55 Thorsten Jolitz
  2014-07-28  8:58 ` Tassilo Horn
  2014-07-28 13:17 ` Whats wrong with this defcustom? Sebastian Wiesner
  0 siblings, 2 replies; 13+ messages in thread
From: Thorsten Jolitz @ 2014-07-26 10:55 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

I'm probably overlooking the obvious, but what is wrong with this
defcustom:

,----
| (defcustom org-x-style 'notes
|   "Possible styles for diagrams."
|   :group 'org-x
|   :type '(choice (const :tag "Sync-bars" 'sync-bars)
| 		 (const :tag "Partitions" 'partitions)
| 		 (const :tag "Notes" 'notes)))
`----

why do I get the (mismatch) note but no choices?

,----
| Hide org-x-style: 'notes
|    [ State ]: STANDARD. (mismatch)
|    Possible styles for diagrams.
| Groups: [Org X]
`----

Thanks in advance for any hint.

-- 
cheers,
Thorsten





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

* Re: Whats wrong with this defcustom?
  2014-07-26 10:55 Whats wrong with this defcustom? Thorsten Jolitz
@ 2014-07-28  8:58 ` Tassilo Horn
  2014-07-28 10:06   ` Thorsten Jolitz
                     ` (3 more replies)
  2014-07-28 13:17 ` Whats wrong with this defcustom? Sebastian Wiesner
  1 sibling, 4 replies; 13+ messages in thread
From: Tassilo Horn @ 2014-07-28  8:58 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: help-gnu-emacs

Thorsten Jolitz <tjolitz@gmail.com> writes:

Hi Thorsten,

> I'm probably overlooking the obvious, but what is wrong with this
> defcustom:
>
> ,----
> | (defcustom org-x-style 'notes
> |   "Possible styles for diagrams."
> |   :group 'org-x
> |   :type '(choice (const :tag "Sync-bars" 'sync-bars)
> | 		 (const :tag "Partitions" 'partitions)
> | 		 (const :tag "Notes" 'notes)))
> `----

,----[ C-h f defcustom RET ]
| defcustom is a Lisp macro in `custom.el'.
| 
| (defcustom SYMBOL STANDARD DOC &rest ARGS)
| 
| Declare SYMBOL as a customizable variable.
| SYMBOL is the variable name; it should not be quoted.
| STANDARD is an expression specifying the variable's standard
| value.  It should not be quoted.
|         ^^^^^^^^^^^^^^^^^^^^^^^
`----

Bye,
Tassilo



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

* Re: Whats wrong with this defcustom?
  2014-07-28  8:58 ` Tassilo Horn
@ 2014-07-28 10:06   ` Thorsten Jolitz
  2014-07-28 22:11   ` [BUG] in defcustom docstring (was Re: Whats wrong with this defcustom?) Thorsten Jolitz
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Thorsten Jolitz @ 2014-07-28 10:06 UTC (permalink / raw)
  To: help-gnu-emacs

Tassilo Horn <tsdh@gnu.org> writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:

Hi Tassilo,

>> I'm probably overlooking the obvious, but what is wrong with this
>> defcustom:
>>
>> ,----
>> | (defcustom org-x-style 'notes
>> |   "Possible styles for diagrams."
>> |   :group 'org-x
>> |   :type '(choice (const :tag "Sync-bars" 'sync-bars)
>> | 		 (const :tag "Partitions" 'partitions)
>> | 		 (const :tag "Notes" 'notes)))
>> `----
>
> ,----[ C-h f defcustom RET ]
> | defcustom is a Lisp macro in `custom.el'.
> | 
> | (defcustom SYMBOL STANDARD DOC &rest ARGS)
> | 
> | Declare SYMBOL as a customizable variable.
> | SYMBOL is the variable name; it should not be quoted.
> | STANDARD is an expression specifying the variable's standard
> | value.  It should not be quoted.
> |         ^^^^^^^^^^^^^^^^^^^^^^^
> `----

Right, I fixed this too ... thx.
Quoting symbols is done so often that unquoted symbols somehow look
wrong (when unaware of dealing with a macro ...)

-- 
cheers,
Thorsten




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

* Re: Whats wrong with this defcustom?
  2014-07-26 10:55 Whats wrong with this defcustom? Thorsten Jolitz
  2014-07-28  8:58 ` Tassilo Horn
@ 2014-07-28 13:17 ` Sebastian Wiesner
  2014-07-28 13:54   ` Thorsten Jolitz
  1 sibling, 1 reply; 13+ messages in thread
From: Sebastian Wiesner @ 2014-07-28 13:17 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: help-gnu-emacs


Am 26.07.2014 um 12:55 schrieb Thorsten Jolitz <tjolitz@gmail.com>:

> 
> Hi List, 
> 
> I'm probably overlooking the obvious, but what is wrong with this
> defcustom:
> 
> ,----
> | (defcustom org-x-style 'notes
> |   "Possible styles for diagrams."
> |   :group 'org-x
> |   :type '(choice (const :tag "Sync-bars" 'sync-bars)
> | 		 (const :tag "Partitions" 'partitions)
> | 		 (const :tag "Notes" 'notes)))
> `——

Remove the quotes from the symbols inside the `(const …)` expressions.  The outer `choice` is already quoted, so you are “double-quoting” the choices.  Hence the mismatch: The symbol "notes" is different from the expression "(quote notes)".


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

* Re: Whats wrong with this defcustom?
  2014-07-28 13:17 ` Whats wrong with this defcustom? Sebastian Wiesner
@ 2014-07-28 13:54   ` Thorsten Jolitz
  0 siblings, 0 replies; 13+ messages in thread
From: Thorsten Jolitz @ 2014-07-28 13:54 UTC (permalink / raw)
  To: help-gnu-emacs

Sebastian Wiesner <swiesner@lunaryorn.com> writes:

> Am 26.07.2014 um 12:55 schrieb Thorsten Jolitz <tjolitz@gmail.com>:
>
>> 
>> Hi List, 
>> 
>> I'm probably overlooking the obvious, but what is wrong with this
>> defcustom:
>> 
>> ,----
>> | (defcustom org-x-style 'notes
>> |   "Possible styles for diagrams."
>> |   :group 'org-x
>> |   :type '(choice (const :tag "Sync-bars" 'sync-bars)
>> | 		 (const :tag "Partitions" 'partitions)
>> | 		 (const :tag "Notes" 'notes)))
>> `——
>
> Remove the quotes from the symbols inside the `(const …)` expressions.
> The outer `choice` is already quoted, so you are “double-quoting” the
> choices.  Hence the mismatch: The symbol "notes" is different from the
> expression "(quote notes)".

Yes, thanks, I see it now but somehow did not see it before, there were
4 redundant quotes in that def, STANDARD and those inside the '(const
...)' expressions, I fixed that now.

,----[ C-h f defcustom RET ]
| defcustom is a Lisp macro in `custom.el'.
| 
| (defcustom SYMBOL STANDARD DOC &rest ARGS)
| 
| Declare SYMBOL as a customizable variable.
| SYMBOL is the variable name; it should not be quoted.
| STANDARD is an expression specifying the variable's standard
| value.  It should not be quoted.
`----

-- 
cheers,
Thorsten




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

* [BUG] in defcustom docstring (was Re: Whats wrong with this defcustom?)
  2014-07-28  8:58 ` Tassilo Horn
  2014-07-28 10:06   ` Thorsten Jolitz
@ 2014-07-28 22:11   ` Thorsten Jolitz
  2014-07-28 22:33   ` Whats wrong with this defcustom? Stefan Monnier
       [not found]   ` <mailman.6168.1406585492.1147.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 13+ messages in thread
From: Thorsten Jolitz @ 2014-07-28 22:11 UTC (permalink / raw)
  To: help-gnu-emacs

Tassilo Horn <tsdh@gnu.org> writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
> Hi Thorsten,
>
>> I'm probably overlooking the obvious, but what is wrong with this
>> defcustom:
>>
>> ,----
>> | (defcustom org-x-style 'notes
>> |   "Possible styles for diagrams."
>> |   :group 'org-x
>> |   :type '(choice (const :tag "Sync-bars" 'sync-bars)
>> | 		 (const :tag "Partitions" 'partitions)
>> | 		 (const :tag "Notes" 'notes)))
>> `----
>
> ,----[ C-h f defcustom RET ]
> | defcustom is a Lisp macro in `custom.el'.
> | 
> | (defcustom SYMBOL STANDARD DOC &rest ARGS)
> | 
> | Declare SYMBOL as a customizable variable.
> | SYMBOL is the variable name; it should not be quoted.
> | STANDARD is an expression specifying the variable's standard
> | value.  It should not be quoted.
> |         ^^^^^^^^^^^^^^^^^^^^^^^
> `----

If I don't quote STANDARD I get a load-error, so either the docstring is
lying or I'm already confused about this whole issue ...

Recipe:

1. emacs -Q
2. C-x C-f ~/junk/test.el ; new empty test file
3. insert '(defcustom foo bar "loo")'
4. C-x C-s
5. M-x eval-buffer

-> 
,----
| custom-initialize-reset:
|   Symbol's value as variable is void: bar
`----

-- 
cheers,
Thorsten




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

* Re: Whats wrong with this defcustom?
  2014-07-28  8:58 ` Tassilo Horn
  2014-07-28 10:06   ` Thorsten Jolitz
  2014-07-28 22:11   ` [BUG] in defcustom docstring (was Re: Whats wrong with this defcustom?) Thorsten Jolitz
@ 2014-07-28 22:33   ` Stefan Monnier
  2014-07-28 23:09     ` Thorsten Jolitz
       [not found]   ` <mailman.6168.1406585492.1147.help-gnu-emacs@gnu.org>
  3 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2014-07-28 22:33 UTC (permalink / raw)
  To: help-gnu-emacs

> | STANDARD is an expression specifying the variable's standard
> | value.  It should not be quoted.
> |         ^^^^^^^^^^^^^^^^^^^^^^^

The underscored text means that you shouldn't write

   '(concat foo bar)
but
   (concat foo bar)

I.e. his 'notes is perfectly correct: it's an unquoted *expression*
which will return the symbol `notes' when evaluated.


        Stefan




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

* Re: Whats wrong with this defcustom?
  2014-07-28 22:33   ` Whats wrong with this defcustom? Stefan Monnier
@ 2014-07-28 23:09     ` Thorsten Jolitz
  2014-07-29  0:46       ` Robert Thorpe
  0 siblings, 1 reply; 13+ messages in thread
From: Thorsten Jolitz @ 2014-07-28 23:09 UTC (permalink / raw)
  To: help-gnu-emacs

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

>> | STANDARD is an expression specifying the variable's standard
>> | value.  It should not be quoted.
>> |         ^^^^^^^^^^^^^^^^^^^^^^^
>
> The underscored text means that you shouldn't write
>
>    '(concat foo bar)
> but
>    (concat foo bar)
>
> I.e. his 'notes is perfectly correct: it's an unquoted *expression*
> which will return the symbol `notes' when evaluated.

Ok, precision matters, so a quoted symbol is at the same time an
unquoted *expression* that returns the symbol itself ... while an unquoted symbol
in an unquoted *expression* that tries to return the symbols value (as a
variable) ... (?)

-- 
cheers,
Thorsten




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

* Re: Whats wrong with this defcustom?
  2014-07-28 23:09     ` Thorsten Jolitz
@ 2014-07-29  0:46       ` Robert Thorpe
  2014-07-29  2:06         ` Thien-Thi Nguyen
  2014-07-29  8:19         ` Thorsten Jolitz
  0 siblings, 2 replies; 13+ messages in thread
From: Robert Thorpe @ 2014-07-29  0:46 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: help-gnu-emacs

Thorsten Jolitz <tjolitz@gmail.com> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
...
>
> Ok, precision matters, so a quoted symbol is at the same time an
> unquoted *expression* that returns the symbol itself ... while an unquoted symbol
> in an unquoted *expression* that tries to return the symbols value (as a
> variable) ... (?)


Apologies if I explain things you already know.  See below:
*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (setq bar 4)
4
ELISP> (setq foo bar)
4
ELISP> foo
4
ELISP> bar
4
ELISP> (setq foo 'bar)
bar
ELISP> foo
bar
ELISP> bar
4

Think about setq....  If you want to set foo to the symbol bar then you
have to quote it.  Similarly, in defcustom if you want the STANDARD to
be a symbol then you have to quote it, so quoting "notes" is right.  On
the other hand the whole "'choice ..." expression is quoted.  It's a
data structure, a little list/tree made up of strings and symbols.  The
bit in the docstring is telling you not to quote anything except
symbols.

This may help...  Last week I replied to a question about symbols and
explained what they are.  Sometimes the lisp interpreter evaluates and
sometimes it doesn't, that confuses things.  I wrote: "If we have a
function call: (foo bar 'baz) then lisp treats each of these symbols
differently.  It finds the function slot for foo because that's the
first symbol, it finds the variable slot for bar because it's not first.
Finally, 'baz returns the symbol itself.  To be more careful: (quote
baz) returns a list containing the symbol, which evaluates to the
symbol".  That applies to functions, other things can be different.

Imagine we have a lisp interpreter that works on lisp lists.  It takes a
tree (a lisp list) and evaluates it (the "eval" function) by looking at
the first argument and figuring out what to do.  Some "special forms"
are dealt with directly.  For other things the interpreter finds the
corresponding function.  If you think about this it needs to decide how
to deal with arguments.  They can be "unevalled", the relevant fragment
of the list can be used as-is.  Or it can be "evalled" in which case a
recursive call to the eval function is needed.  In that case a list
would be interpreted as a function call and a sole symbol as a variable
reference.  Does the lisp programmer need to deal with both unevalled
and evalled type arguments?  Not really, a special-form can be provided
to switch between the two.  The special-form "Quote" takes its arguments
unevalled and simply returns them; '(something) is just an abbreviation
for (quote something).

As well as quote, there are a few built-in special forms that work that
way.  There are also macros which operate directly on lists.  They get
lists from the reader before evaluation begins, then they transform
them.

For example, "eval-when-compile" is a macro.  It takes an argument BODY
which is unquoted.  On the other hand, "eval-after-load" is a function
it takes two arguments FILE and FORM.  Since it's a function FORM must
be quoted.  Because eval-after-load is a function it must call eval
explicitly to deal with FORM.  The line in defcustom's documentation
about not quoting is there to say that defcustom behaves like
"eval-when-compile" not like "eval-after-load".

BR,
Robert Thorpe



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

* Re: Whats wrong with this defcustom?
  2014-07-29  0:46       ` Robert Thorpe
@ 2014-07-29  2:06         ` Thien-Thi Nguyen
  2014-07-29 23:55           ` Robert Thorpe
  2014-07-29  8:19         ` Thorsten Jolitz
  1 sibling, 1 reply; 13+ messages in thread
From: Thien-Thi Nguyen @ 2014-07-29  2:06 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 842 bytes --]

() Robert Thorpe <rt@robertthorpeconsulting.com>
() Tue, 29 Jul 2014 01:46:10 +0100

   '(something) is just an abbreviation for
   (quote something).

This is not correct.

 '(something) ≡ (quote (something))
 which evals to a list of one element, the symbol ‘something’
 i.e., => (something)

but

 (quote something) ≡ 'something
 which evals to the symbol ‘something’
 i.e., => something

Also, i think it's better to say "evals to" rather than "returns".
The latter strikes me as indicative of a function-call context.
OTOH, ‘eval’ is a function, so i suppose YMMV...  :-D

-- 
Thien-Thi Nguyen
   GPG key: 4C807502
   (if you're human and you know it)
      read my lisp: (responsep (questions 'technical)
                               (not (via 'mailing-list)))
                     => nil

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: Whats wrong with this defcustom?
  2014-07-29  0:46       ` Robert Thorpe
  2014-07-29  2:06         ` Thien-Thi Nguyen
@ 2014-07-29  8:19         ` Thorsten Jolitz
  1 sibling, 0 replies; 13+ messages in thread
From: Thorsten Jolitz @ 2014-07-29  8:19 UTC (permalink / raw)
  To: help-gnu-emacs

Robert Thorpe <rt@robertthorpeconsulting.com> writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
> ...
>>
>> Ok, precision matters, so a quoted symbol is at the same time an
>> unquoted *expression* that returns the symbol itself ... while an
>> unquoted symbol
>> in an unquoted *expression* that tries to return the symbols value (as a
>> variable) ... (?)
>
>
> Apologies if I explain things you already know.  See below:
> *** Welcome to IELM ***  Type (describe-mode) for help.

Well, I did quote the STANDARD argument in my defcustom correctly and
really actually know that in an already quoted list I should not quote
symbols again, but that did not prevent me from doing it wrong and then
being unable to see my mistake ;)

Since 'foo is (quote foo) which is an unquoted expression the docstring
of `defcustom` is correct, and I did not think it through before doing
my bug-report, shame on me. 

Thanks for your long and interesting explanations anyway!

-- 
cheers,
Thorsten




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

* Re: [BUG] in defcustom docstring (was Re: Whats wrong with this defcustom?)
       [not found]   ` <mailman.6168.1406585492.1147.help-gnu-emacs@gnu.org>
@ 2014-07-29 16:48     ` Christoph Wedler
  0 siblings, 0 replies; 13+ messages in thread
From: Christoph Wedler @ 2014-07-29 16:48 UTC (permalink / raw)
  To: help-gnu-emacs

Thorsten Jolitz <tjolitz@gmail.com> writes:

> Tassilo Horn <tsdh@gnu.org> writes:
>
>> Thorsten Jolitz <tjolitz@gmail.com> writes:
>>
>> Hi Thorsten,
>>
>>> I'm probably overlooking the obvious, but what is wrong with this
>>> defcustom:
>>>
>>> ,----
>>> | (defcustom org-x-style 'notes
>>> |   "Possible styles for diagrams."
>>> |   :group 'org-x
>>> |   :type '(choice (const :tag "Sync-bars" 'sync-bars)
>>> | 		 (const :tag "Partitions" 'partitions)
>>> | 		 (const :tag "Notes" 'notes)))
>>> `----
>>
>> ,----[ C-h f defcustom RET ]
>> | defcustom is a Lisp macro in `custom.el'.
>> | 
>> | (defcustom SYMBOL STANDARD DOC &rest ARGS)
>> | 
>> | Declare SYMBOL as a customizable variable.
>> | SYMBOL is the variable name; it should not be quoted.
>> | STANDARD is an expression specifying the variable's standard
                    ^^^^^^^^^^
>> | value.  It should not be quoted.
>> |         ^^^^^^^^^^^^^^^^^^^^^^^

That means: the EXPRESSION should not be quoted, but the expression
might contain (or consist only of) a quoted symbol, of course...

If you just have bar as an expression, it means the variable bar - if
that is undefined... =>

> ,----
> | custom-initialize-reset:
> |   Symbol's value as variable is void: bar
> `----


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

* Re: Whats wrong with this defcustom?
  2014-07-29  2:06         ` Thien-Thi Nguyen
@ 2014-07-29 23:55           ` Robert Thorpe
  0 siblings, 0 replies; 13+ messages in thread
From: Robert Thorpe @ 2014-07-29 23:55 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: help-gnu-emacs

Thien-Thi Nguyen <ttn@gnu.org> writes:

> () Robert Thorpe <rt@robertthorpeconsulting.com>
> () Tue, 29 Jul 2014 01:46:10 +0100
>
>    '(something) is just an abbreviation for
>    (quote something).
>
> This is not correct.
>
>  '(something) ≡ (quote (something))
>  which evals to a list of one element, the symbol ‘something’
>  i.e., => (something)

I agree, you're right.

BR,
Robert Thorpe



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

end of thread, other threads:[~2014-07-29 23:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-26 10:55 Whats wrong with this defcustom? Thorsten Jolitz
2014-07-28  8:58 ` Tassilo Horn
2014-07-28 10:06   ` Thorsten Jolitz
2014-07-28 22:11   ` [BUG] in defcustom docstring (was Re: Whats wrong with this defcustom?) Thorsten Jolitz
2014-07-28 22:33   ` Whats wrong with this defcustom? Stefan Monnier
2014-07-28 23:09     ` Thorsten Jolitz
2014-07-29  0:46       ` Robert Thorpe
2014-07-29  2:06         ` Thien-Thi Nguyen
2014-07-29 23:55           ` Robert Thorpe
2014-07-29  8:19         ` Thorsten Jolitz
     [not found]   ` <mailman.6168.1406585492.1147.help-gnu-emacs@gnu.org>
2014-07-29 16:48     ` [BUG] in defcustom docstring (was Re: Whats wrong with this defcustom?) Christoph Wedler
2014-07-28 13:17 ` Whats wrong with this defcustom? Sebastian Wiesner
2014-07-28 13:54   ` Thorsten Jolitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).