Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
custom: how do I augment an option?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sam Steingold  
View profile  
 More options Sep 5 2012, 1:56 pm
Newsgroups: gnu.emacs.help
From: Sam Steingold <s...@gnu.org>
Date: Wed, 05 Sep 2012 13:56:20 -0400
Local: Wed, Sep 5 2012 1:56 pm
Subject: custom: how do I augment an option?
If I want to set a custom variable, I can do
--8<---------------cut here---------------start------------->8---
(custom-set-variables
 '(foo 42))
--8<---------------cut here---------------end--------------->8---
in my .emacs.
However, if I want to modify the custom variable, I have to resort to
something like
--8<---------------cut here---------------start------------->8---
(add-hook 'message-load-hook
  (lambda ()
    (add-to-list 'message-syntax-checks
                 '(long-lines . disabled))))
--8<---------------cut here---------------end--------------->8---
because
--8<---------------cut here---------------start------------->8---
(custom-set-variables
 '(message-syntax-checks (adjoin '(long-lines . disabled)
                                 message-syntax-checks
                                 :key 'equal)))
--8<---------------cut here---------------end--------------->8---
will evaluate `message-syntax-checks' too early:
--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (void-variable message-syntax-checks)
  (adjoin (quote (long-lines . disabled)) message-syntax-checks :key (quote equal))
  eval((adjoin (quote (long-lines . disabled)) message-syntax-checks :key (quote equal)))
  custom-initialize-reset(message-syntax-checks (if message-insert-canlock (quote ((sender . disabled))) nil))
  custom-declare-variable(message-syntax-checks...
  byte-code...
  require(message)
  byte-code...
  gnus-msg-mail(nil nil nil nil nil nil nil nil)
  compose-mail(nil nil nil nil)
  call-interactively(compose-mail nil nil)
--8<---------------cut here---------------end--------------->8---
(it also uses a CL function which emacs purists frown upon).

So, how do I use the custom facility to add something to a custom variable?
Thanks!

--
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://americancensorship.org http://jihadwatch.org
http://iris.org.il http://think-israel.org http://ffii.org
Don't use force -- get a bigger hammer.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jambunathan K  
View profile  
 More options Sep 5 2012, 2:27 pm
Newsgroups: gnu.emacs.help
From: Jambunathan K <kjambunat...@gmail.com>
Date: Wed, 05 Sep 2012 23:57:48 +0530
Local: Wed, Sep 5 2012 2:27 pm
Subject: Re: custom: how do I augment an option?

Sam Steingold <s...@gnu.org> writes:
> (custom-set-variables
>  '(message-syntax-checks (adjoin '(long-lines . disabled)
>                                  message-syntax-checks
>                                  :key 'equal)))

> will evaluate `message-syntax-checks' too early:

I think the solution will involve using

    (get 'message-syntax-checks 'saved-value)

See (info "(elisp) Applying Customizations").
--


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Steingold  
View profile  
 More options Sep 5 2012, 3:18 pm
Newsgroups: gnu.emacs.help
From: Sam Steingold <s...@gnu.org>
Date: Wed, 05 Sep 2012 15:18:03 -0400
Local: Wed, Sep 5 2012 3:18 pm
Subject: Re: custom: how do I augment an option?

> * Sam Steingold <f...@tah.bet> [2012-09-05 13:56:20 -0400]:

> (custom-set-variables
>  '(message-syntax-checks (adjoin '(long-lines . disabled)
>                                  message-syntax-checks
>                                  :key 'equal)))
> will evaluate `message-syntax-checks' too early:

The "solution" is
--8<---------------cut here---------------start------------->8---
(custom-set-variables
 '(message-syntax-checks
   (adjoin '(long-lines . disabled)
    (eval (car (get 'message-syntax-checks 'standard-value)))
    :test 'equal)))
--8<---------------cut here---------------end--------------->8---
which uses `eval' on top of `adjoin'.

So, what is the official method?

--
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://dhimmi.com http://jihadwatch.org
http://honestreporting.com http://iris.org.il http://thereligionofpeace.com
Save your burned out bulbs for me, I'm building my own dark room.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Drew Adams  
View profile  
 More options Sep 5 2012, 4:04 pm
Newsgroups: gnu.emacs.help
From: "Drew Adams" <drew.ad...@oracle.com>
Date: Wed, 5 Sep 2012 13:04:36 -0700
Local: Wed, Sep 5 2012 4:04 pm
Subject: RE: custom: how do I augment an option?

>> If I want to set a custom variable, I can do

>> (custom-set-variables '(foo 42))

>> in my .emacs.  However, if I want to modify the custom variable,
>> I have to resort to something like

>> (add-hook 'message-load-hook
>>   (lambda ()
>>     (add-to-list 'message-syntax-checks '(long-lines . disabled))))

No, you do not have to resort to doing that.

> The "solution" is

> (custom-set-variables
>  '(message-syntax-checks
>    (adjoin '(long-lines . disabled)
>     (eval (car (get 'message-syntax-checks 'standard-value)))
>     :test 'equal)))

> which uses `eval' on top of `adjoin'.
> So, what is the official method?

Sorry, but I don't see what the problem is.  Why not just use Customize?

At the very least you could use Customize to see what it writes out.  If you
start with Emacs -Q and add (long-lines . disabled) to the default value then it
writes this:

'(message-syntax-checks
   (quote ((sender . disabled) (long-lines . disabled))))

`M-x customize-option' lets you not worry about the Lisp form to use.

But if for some reason you prefer to worry about it, the "solution" is to ask
Emacs what Lisp code it uses, i.e., use Customize to see what it does.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Steingold  
View profile  
 More options Sep 5 2012, 4:48 pm
Newsgroups: gnu.emacs.help
From: Sam Steingold <s...@gnu.org>
Date: Wed, 05 Sep 2012 16:45:08 -0400
Local: Wed, Sep 5 2012 4:45 pm
Subject: Re: custom: how do I augment an option?

I don't like the gui; also see below (sneak preview: customize is broken :-).

> At the very least you could use Customize to see what it writes out.  If you
> start with Emacs -Q and add (long-lines . disabled) to the default value then it
> writes this:

> '(message-syntax-checks
>    (quote ((sender . disabled) (long-lines . disabled))))

Hah, but this is wrong!
The correct value of message-syntax-checks depends on message-insert-canlock:

(get 'message-syntax-checks 'standard-value)
==> ((if message-insert-canlock (quote ((sender . disabled))) nil))

While if I go your way, then message-syntax-checks will not depend on
message-insert-canlock!

--
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://openvotingconsortium.org
http://ffii.org http://thereligionofpeace.com http://honestreporting.com
Beliefs divide, doubts unite.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Drew Adams  
View profile  
 More options Sep 5 2012, 5:15 pm
Newsgroups: gnu.emacs.help
From: "Drew Adams" <drew.ad...@oracle.com>
Date: Wed, 5 Sep 2012 14:15:41 -0700
Local: Wed, Sep 5 2012 5:15 pm
Subject: RE: custom: how do I augment an option?

> > Why not just use Customize?

> I don't like the gui;

I don't like the GUI either.  Which is why I've made improvement suggestions,
filed bug reports, and come up some extensions of my own.

But I recognize that the GUI at least _works_, and it can often give you answers
to questions like the one you raised.

And I've seen a fair amount of hand-coded customize-workaround stuff in .emacs
files that does _not_ work or does not provide the type-checking and proper
initialization/setting code that Customize provides.

It is not uncommon for people to underestimate Customize, IMO.  Customize is in
fact surprisingly solid, and it does quite a lot that you or I might never think
to do by hand.

IOW, if you don't want to use the GUI then there is a fair amount that you
become responsible for getting right, if you want the same solid result.  This
is even more true if you write code that others will use, since they will do
things differently from what you might expect.

> also see below (sneak preview: customize is broken :-).

Please, don't just tell us here.  `M-x report-emacs-bug', if you think Emacs
code is broken.  That's the only real hope (however slim it might be in some
cases) of getting something fixed.

In all likelihood (my guess), if "customize" does not seem to do the right thing
in this particular case it is not because Customize is broken but because the
programmer who coded this particular user option did not do the right thing.
Those are not the same thing.  And the devil is in the details.  So provide the
details to Emacs Dev by reporting a bug.

You would not say "Lisp is broken" just because some programmer wrote some Lisp
code that didn't work, would you?

> While if I go your way, then message-syntax-checks will not depend on
> message-insert-canlock!

It is not my way.  I don't even use `message-syntax-checks' or Gnus, at all.
And I have _no_ plans to ever do so.

I do use `defcustom' heavily (more and more so), and I do use the Customize GUI.

FWIW, I didn't used to use Customize.  Like you, I was convinced that my reason
for that was that I didn't like the GUI.  I changed my mind about using it years
ago, though I am still of the opinion that the GUI sucks.  And the underlying
Lisp code is virtually impenetrable, if not a mine field.

What does not suck, however, is what Customize _does_, as opposed to how
ugly/inconvenient it might be to use or how hard its code might be to fathom.

I use a separate `custom-file' (Touches pas a mon .emacs!), and I find that
letting Customize handle my option & face customizations is a lot less
problematic than fiddling with the equivalent Lisp code myself.  YMMV.

I'm not trying to convince you - just telling my own story.  IMHO, Customize is
your friend - ugly and hard to understand, but your friend nonetheless.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Drew Adams  
View profile  
 More options Sep 5 2012, 5:28 pm
Newsgroups: gnu.emacs.help
From: "Drew Adams" <drew.ad...@oracle.com>
Date: Wed, 5 Sep 2012 14:27:55 -0700
Local: Wed, Sep 5 2012 5:27 pm
Subject: RE: custom: how do I augment an option?

> > also see below (sneak preview: customize is broken :-).

> Please, don't just tell us here.  `M-x report-emacs-bug', if
> you think Emacs code is broken.  That's the only real hope
> (however slim it might be in some cases) of getting something fixed.

> In all likelihood (my guess), if "customize" does not seem to
> do the right thing in this particular case it is not because
> Customize is broken but because the programmer who coded this
> particular user option did not do the right thing.
> Those are not the same thing.  And the devil is in the details.
> So provide the details to Emacs Dev by reporting a bug.

BTW, the doc string and source code comments seem to be an admission that there
are some remaining problems.  They suggest that this option is complex and is
not necessarily for most end users to fiddle with.  IOW, this is not your
typical option.

In the doc string:

 Don't touch this variable unless you really know what you're doing.

In the code comments:

 ;; Guess this one shouldn't be easy to customize...
...
 ; Fixme: improve this


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stefan Monnier  
View profile  
 More options Sep 6 2012, 9:14 am
Newsgroups: gnu.emacs.help
From: Stefan Monnier <monn...@iro.umontreal.ca>
Date: Thu, 06 Sep 2012 09:14:55 -0400
Local: Thurs, Sep 6 2012 9:14 am
Subject: Re: custom: how do I augment an option?

> So, what is the official method?

There are 3 official methods:
1- forget about flexibility and just set the var to a constant value
   that does not depend on the default value.  That can be done from the GUI.
2- if you want to use actual code (instead of a mere constant), then
   don't use Customize, and use something like the add-hook code you showed.
3- submit a patch for Customize which lets the user specify not just
   a new value but a change (like a "diff") to the default value.
   For lists representing sets, a way for the user to specify elements
   to add and elements to remove would be great.  For lists where order
   matters, the user should additionally have some control over where to
   add elements.
Point 3 would be *really* welcome.

        Stefan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Drew Adams  
View profile  
 More options Sep 6 2012, 9:37 am
Newsgroups: gnu.emacs.help
From: "Drew Adams" <drew.ad...@oracle.com>
Date: Thu, 6 Sep 2012 06:37:05 -0700
Local: Thurs, Sep 6 2012 9:37 am
Subject: RE: custom: how do I augment an option?

> 3- submit a patch for Customize which lets the user specify
>    not just a new value but a change (like a "diff") to the
>    default value. For lists representing sets, a way for the
>    user to specify elements to add and elements to remove
>    would be great.  For lists where order matters, the user
>    should additionally have some control over where to add
>    elements.
> Point 3 would be *really* welcome.

+1

One reason this would be helpful would be simplicity of expression.  But
another, quite important reason IMO, would be some ability to better handle
updates of the default value, e.g. in a new version of the given defcustom.

For example, an option value that is a list of mappings of some kind might have
additional mappings by default in a newer version of the library.  If you have
already customized the option then you might not learn of the added
possibilities.  I see this fairly often.  You've customized based on the old
default value, not the new one.  Given some awareness of the change, you might
now want to customize the option differently.

But this problem of a changed default value is presented even for non-collection
options.  It would be good to have a simple (optional) way for users of a
library to be alerted that the default value of a given option or face that they
have customized has changed.

E.g., if the default value of `foo' was 3, you have customized it to 42, and the
default value is now nil, be able to be alerted to that default change.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »