unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Replacing custom-set-variables
@ 2008-09-13 17:19 Mauricio
  2008-09-13 22:20 ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Mauricio @ 2008-09-13 17:19 UTC (permalink / raw
  To: help-gnu-emacs

Hi,

In .emacs I have a few variables defined using:

(custom-set-variables
  '(var1 val1)
  '(var2 val2)
  '(var3 val3))

How can I define those same variables in .emacs
without using custom-set-variables?

Thanks,
Maurício





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

* Re: Replacing custom-set-variables
       [not found] <mailman.19185.1221326409.18990.help-gnu-emacs@gnu.org>
@ 2008-09-13 18:08 ` Joost Diepenmaat
  2008-09-13 19:05 ` Andy Stewart
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Joost Diepenmaat @ 2008-09-13 18:08 UTC (permalink / raw
  To: help-gnu-emacs

Mauricio <briqueabraque@yahoo.com> writes:

> Hi,
>
> In .emacs I have a few variables defined using:
>
> (custom-set-variables
>  '(var1 val1)
>  '(var2 val2)
>  '(var3 val3))
>
> How can I define those same variables in .emacs
> without using custom-set-variables?

just use

(setq var-name value)

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


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

* Re: Replacing custom-set-variables
       [not found] <mailman.19185.1221326409.18990.help-gnu-emacs@gnu.org>
  2008-09-13 18:08 ` Joost Diepenmaat
@ 2008-09-13 19:05 ` Andy Stewart
  2008-09-13 20:13 ` Giorgos Keramidas
  2008-09-14  4:25 ` Tim X
  3 siblings, 0 replies; 12+ messages in thread
From: Andy Stewart @ 2008-09-13 19:05 UTC (permalink / raw
  To: help-gnu-emacs

>>>>> "Mauricio" == Mauricio  <briqueabraque@yahoo.com> writes:

Hi, Mauricio!

Just 
(setq var1 val1)
(setq var2 val2)
(setq var3 val3)

Regards.

Andy.

    Mauricio> Hi,
    Mauricio> In .emacs I have a few variables defined using:

    Mauricio> (custom-set-variables
    Mauricio> '(var1 val1)
    Mauricio> '(var2 val2)
    Mauricio> '(var3 val3))

    Mauricio> How can I define those same variables in .emacs
    Mauricio> without using custom-set-variables?

    Mauricio> Thanks,
    Mauricio> Maurício





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

* Re: Replacing custom-set-variables
       [not found] <mailman.19185.1221326409.18990.help-gnu-emacs@gnu.org>
  2008-09-13 18:08 ` Joost Diepenmaat
  2008-09-13 19:05 ` Andy Stewart
@ 2008-09-13 20:13 ` Giorgos Keramidas
  2008-09-14  4:33   ` Tim X
  2008-09-14  4:25 ` Tim X
  3 siblings, 1 reply; 12+ messages in thread
From: Giorgos Keramidas @ 2008-09-13 20:13 UTC (permalink / raw
  To: help-gnu-emacs

On Sat, 13 Sep 2008 14:19:52 -0300, Mauricio <briqueabraque@yahoo.com> wrote:
> Hi,
>
> In .emacs I have a few variables defined using:
>
> (custom-set-variables
>  '(var1 val1)
>  '(var2 val2)
>  '(var3 val3))
>
> How can I define those same variables in .emacs
> without using custom-set-variables?

You can always use `setq-default', either in one call:

    (setq-default var1 val1
                  var2 val2
                  var3 val3)

or multiple calls:

    (setq-default var1 val1)
    (setq-default var2 val2)
    (setq-default var3 val3)



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

* RE: Replacing custom-set-variables
  2008-09-13 17:19 Replacing custom-set-variables Mauricio
@ 2008-09-13 22:20 ` Drew Adams
  2008-09-14  0:17   ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2008-09-13 22:20 UTC (permalink / raw
  To: 'Mauricio', help-gnu-emacs

> In .emacs I have a few variables defined using:
> (custom-set-variables
>   '(var1 val1)
>   '(var2 val2)
>   '(var3 val3))
> 
> How can I define those same variables in .emacs
> without using custom-set-variables?

Typically:

(setq var1 val1
      var2 val2
      var3 val3)

But see also `setq-default'; it might be more appropriate for some variables.

As an alternative to not using `custom-set-variables', consider having a
separate custom file, the value of variable `custom-file', and letting Customize
manage `custom-set-variables' there. That will keep Customize out of your init
file (~/.emacs). See the Emacs manual, node Saving Customizations.





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

* Re: Replacing custom-set-variables
  2008-09-13 22:20 ` Drew Adams
@ 2008-09-14  0:17   ` Lennart Borgman (gmail)
  2008-09-14  0:53     ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-14  0:17 UTC (permalink / raw
  To: Drew Adams; +Cc: help-gnu-emacs, 'Mauricio'

Drew Adams wrote:
>> In .emacs I have a few variables defined using:
>> (custom-set-variables
>>   '(var1 val1)
>>   '(var2 val2)
>>   '(var3 val3))
>>
>> How can I define those same variables in .emacs
>> without using custom-set-variables?
> 
> Typically:
> 
> (setq var1 val1
>       var2 val2
>       var3 val3)
> 
> But see also `setq-default'; it might be more appropriate for some variables.
> 
> As an alternative to not using `custom-set-variables', consider having a
> separate custom file, the value of variable `custom-file', and letting Customize
> manage `custom-set-variables' there. That will keep Customize out of your init
> file (~/.emacs). See the Emacs manual, node Saving Customizations.


I think that is much better since setq/setq-default actually does not
work for all custom variables. (See `defcustom' for details.)




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

* RE: Replacing custom-set-variables
  2008-09-14  0:17   ` Lennart Borgman (gmail)
@ 2008-09-14  0:53     ` Drew Adams
  0 siblings, 0 replies; 12+ messages in thread
From: Drew Adams @ 2008-09-14  0:53 UTC (permalink / raw
  To: 'Lennart Borgman (gmail)'; +Cc: help-gnu-emacs, 'Mauricio'

> >> In .emacs I have a few variables defined using:
> >> (custom-set-variables
> >>   '(var1 val1)
> >>   '(var2 val2)
> >>   '(var3 val3))
> >>
> >> How can I define those same variables in .emacs
> >> without using custom-set-variables?
> > 
> > Typically:
> > (setq var1 val1
> >       var2 val2
> >       var3 val3)
> > 
> > But see also `setq-default'; it might be more appropriate 
> > for some variables.
> > 
> > As an alternative to not using `custom-set-variables', 
> > consider having a separate custom file, the value of
> > variable `custom-file', and letting Customize
> > manage `custom-set-variables' there. That will keep 
> > Customize out of your init
> > file (~/.emacs). See the Emacs manual, node Saving Customizations.
> 
> I think that is much better since setq/setq-default actually does not
> work for all custom variables. (See `defcustom' for details.)

Yes. And before you replace `custom-set-variables' for any options, read at
least the doc strings for those options to see if they specify any special
considerations for customizing. And different libraries treat variables
differently, so it's also a good idea to read the library's doc or Commentary
section.

In sum, `custom-set-variables' is probably what you want, even if you might not
think so. If you use something else, inform yourself before making the change.





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

* Re: Replacing custom-set-variables
       [not found] <mailman.19185.1221326409.18990.help-gnu-emacs@gnu.org>
                   ` (2 preceding siblings ...)
  2008-09-13 20:13 ` Giorgos Keramidas
@ 2008-09-14  4:25 ` Tim X
  2008-09-15 14:06   ` Mauricio
  3 siblings, 1 reply; 12+ messages in thread
From: Tim X @ 2008-09-14  4:25 UTC (permalink / raw
  To: help-gnu-emacs

Mauricio <briqueabraque@yahoo.com> writes:

> Hi,
>
> In .emacs I have a few variables defined using:
>
> (custom-set-variables
>  '(var1 val1)
>  '(var2 val2)
>  '(var3 val3))
>
> How can I define those same variables in .emacs
> without using custom-set-variables?
>

Just use setq e.g.

(setq var1 value1)

but don't forget to also remove the corresponding bits in the custom
section. 

but can I ask why you want to do this? 

For a long time, I stuck to using the older (setq ....) method, but now
I've switched to using customize whenever possible. I've noticed that
some 'odd' behavior I used to get with the older traditional method have
gone away now that I'm using customize as much as possible. I do still
have some stuff to convert over and plan to do so one day when I get the
motivation.....

In particular, I noticed some inconsistent behavior between some
packages that supported customize when I also configured them 'manually'
(and without corresponding settings in the customize section). for some
reason, the default customize setting would override my setq setting. I
never investigated very closely, but suspect it was related to how the
initialization of the custom variables was handled. the quick and easy
solution was to just set the values via customize and remove my hand
crafted version. 

I've also found using customize is also useful in alerting you to
changes in packages after an upgrade - something you generally don't get
using the older manual approach. 

Tim

-- 
tcross (at) rapttech dot com dot au


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

* Re: Replacing custom-set-variables
  2008-09-13 20:13 ` Giorgos Keramidas
@ 2008-09-14  4:33   ` Tim X
  2008-09-14  8:39     ` rustom
  2008-09-14 21:30     ` Nikolaj Schumacher
  0 siblings, 2 replies; 12+ messages in thread
From: Tim X @ 2008-09-14  4:33 UTC (permalink / raw
  To: help-gnu-emacs

Giorgos Keramidas <keramida@ceid.upatras.gr> writes:

> On Sat, 13 Sep 2008 14:19:52 -0300, Mauricio <briqueabraque@yahoo.com> wrote:
>> Hi,
>>
>> In .emacs I have a few variables defined using:
>>
>> (custom-set-variables
>>  '(var1 val1)
>>  '(var2 val2)
>>  '(var3 val3))
>>
>> How can I define those same variables in .emacs
>> without using custom-set-variables?
>
> You can always use `setq-default', either in one call:
>
>     (setq-default var1 val1
>                   var2 val2
>                   var3 val3)
>
> or multiple calls:
>
>     (setq-default var1 val1)
>     (setq-default var2 val2)
>     (setq-default var3 val3)
>

Be careful using setq-default in .emacs. The difference between setq and
setq-default is that if the variable is already bound to a value,
setq-default does nothing. This can cause confusion/problems when you
are working/tweaking your .emacs and you want to re-evaluate things. If
you have your .emacs split into multiple files to make it easier to
manage, it can be even more confusioing as you may have the same value
being set somewhere else and you start ripping out your hair tyring to
work out why your changes are not taking effect. 

This is not to say that setq-default should not be used. To a large
extent its a matter of taste/style. I just wanted to emphasise the
differences between the two. 

Tim


-- 
tcross (at) rapttech dot com dot au


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

* Re: Replacing custom-set-variables
  2008-09-14  4:33   ` Tim X
@ 2008-09-14  8:39     ` rustom
  2008-09-14 21:30     ` Nikolaj Schumacher
  1 sibling, 0 replies; 12+ messages in thread
From: rustom @ 2008-09-14  8:39 UTC (permalink / raw
  To: help-gnu-emacs

I sympathize with the OP.

Using customize is like having all the linux customizations in /etc
collapsed into one humongous file.
Or equivalently like the windows registry without any namespaces.

Of course as others have pointed out setq does not (always) replace
customize variable.
But when it can (which is mostly) it is neater and more 'programmer-
like'.

I will also add that if you use setq you usually want to do the setq-
ing  as an attachment to the hook for the mode whose customization you
want to do. Setq just-like-that (ie standalone) will usually not work.

For example here is my recentf setup

(add-hook 'recentf-load-hook
  (function (lambda ()
	      (setq recentf-save-file "~/.emacs.d/recentfiles"))))
(recentf-mode 1)


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

* Re: Replacing custom-set-variables
  2008-09-14  4:33   ` Tim X
  2008-09-14  8:39     ` rustom
@ 2008-09-14 21:30     ` Nikolaj Schumacher
  1 sibling, 0 replies; 12+ messages in thread
From: Nikolaj Schumacher @ 2008-09-14 21:30 UTC (permalink / raw
  To: Tim X; +Cc: help-gnu-emacs

Tim X <timx@nospam.dev.null> wrote:

> Giorgos Keramidas <keramida@ceid.upatras.gr> writes:
>
> Be careful using setq-default in .emacs. The difference between setq and
> setq-default is that if the variable is already bound to a value,
> setq-default does nothing.

I think that is not quite correct.  `setq-default' never does
"nothing".  It only leaves values untouched for buffers that have a
local value for the variable.

> This is not to say that setq-default should not be used. To a large
> extent its a matter of taste/style. I just wanted to emphasise the
> differences between the two.

The difference is important mostly for variables that become
buffer-local automatically, like `tab-width'.  There's only two ways to
set them in your .emacs:  Either with hooks or with `setq-default'.

For all other variables, `setq' and `setq-default' are identical.


regards,
Nikolaj Schumacher




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

* Re: Replacing custom-set-variables
  2008-09-14  4:25 ` Tim X
@ 2008-09-15 14:06   ` Mauricio
  0 siblings, 0 replies; 12+ messages in thread
From: Mauricio @ 2008-09-15 14:06 UTC (permalink / raw
  To: help-gnu-emacs; +Cc: help-gnu-emacs

>>
>> In .emacs I have a few variables defined using:
>>
>> (custom-set-variables
>>  '(var1 val1)
>>  '(var2 val2)
>>  '(var3 val3))
>>
>> How can I define those same variables in .emacs
>> without using custom-set-variables?
>>
> 
> Just use setq e.g.
> 
> (setq var1 value1)
> 
> but don't forget to also remove the corresponding bits in the custom
> section. 
> 
> but can I ask why you want to do this? 
> 
> For a long time, I stuck to using the older (setq ....) method, but now
> I've switched to using customize whenever possible. I've noticed that
> some 'odd' behavior I used to get with the older traditional method have
> gone away now that I'm using customize as much as possible. I do still
> have some stuff to convert over and plan to do so one day when I get the
> motivation.....
> 
> In particular, I noticed some inconsistent behavior between some
> packages that supported customize when I also configured them 'manually'
> (and without corresponding settings in the customize section). for some
> reason, the default customize setting would override my setq setting. I
> never investigated very closely, but suspect it was related to how the
> initialization of the custom variables was handled. the quick and easy
> solution was to just set the values via customize and remove my hand
> crafted version. 
> 
> I've also found using customize is also useful in alerting you to
> changes in packages after an upgrade - something you generally don't get
> using the older manual approach. 
> 
> Tim
> 

Based on all comments, maybe a begginer like
me would prefer custom-set-... until I learn
more about a few emacs details, specially
regarding to how modes deal with variables.

Best,
Maurício





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

end of thread, other threads:[~2008-09-15 14:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-13 17:19 Replacing custom-set-variables Mauricio
2008-09-13 22:20 ` Drew Adams
2008-09-14  0:17   ` Lennart Borgman (gmail)
2008-09-14  0:53     ` Drew Adams
     [not found] <mailman.19185.1221326409.18990.help-gnu-emacs@gnu.org>
2008-09-13 18:08 ` Joost Diepenmaat
2008-09-13 19:05 ` Andy Stewart
2008-09-13 20:13 ` Giorgos Keramidas
2008-09-14  4:33   ` Tim X
2008-09-14  8:39     ` rustom
2008-09-14 21:30     ` Nikolaj Schumacher
2008-09-14  4:25 ` Tim X
2008-09-15 14:06   ` Mauricio

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).