unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* define-obsolete-variable-alias problem
@ 2008-04-09 19:16 Glenn Morris
  2008-04-10  4:54 ` Nick Roberts
  0 siblings, 1 reply; 9+ messages in thread
From: Glenn Morris @ 2008-04-09 19:16 UTC (permalink / raw)
  To: emacs-devel


Given this sequence:

(progn
  (setq foo 1)
  (define-obsolete-variable-alias 'foo 'bar)
  (defvar bar 2))

I'd have expected the end result to be bar = foo = 1.
However, the actual result is bar = foo = 2.

This is a problem for the case where I have:

  (setq old-variable-name 1)

in my ~/.emacs, and a package uses:

  (define-obsolete-variable-name 'old-variable-name 'new-variable-name)
  (defcustom new-variable-name 2)

because it means that my customization is ignored. The only solution
seems to be to ;;;###autoload the define-obsolete-variable-name
statement, and AFAICS by extension every such statement in Emacs,
where the variable is user option that might be set in ~.emacs. Is
this really how it is supposed to work?




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

* Re: define-obsolete-variable-alias problem
  2008-04-09 19:16 define-obsolete-variable-alias problem Glenn Morris
@ 2008-04-10  4:54 ` Nick Roberts
  2008-04-11  1:36   ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Nick Roberts @ 2008-04-10  4:54 UTC (permalink / raw)
  To: Glenn Morris; +Cc: emacs-devel

 > Given this sequence:
 > 
 > (progn
 >   (setq foo 1)
 >   (define-obsolete-variable-alias 'foo 'bar)
 >   (defvar bar 2))
 > 
 > I'd have expected the end result to be bar = foo = 1.
 > However, the actual result is bar = foo = 2.

Isn't this really a problem with defvaralias?  Perhaps we could test there if
new-alias is bound and if so assign the value to base-variable.

-- 
Nick                                           http://www.inet.net.nz/~nickrob




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

* Re: define-obsolete-variable-alias problem
  2008-04-10  4:54 ` Nick Roberts
@ 2008-04-11  1:36   ` Stefan Monnier
  2008-04-11  3:53     ` Glenn Morris
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2008-04-11  1:36 UTC (permalink / raw)
  To: Nick Roberts; +Cc: Glenn Morris, emacs-devel

>> Given this sequence:
>> 
>> (progn
>> (setq foo 1)
>> (define-obsolete-variable-alias 'foo 'bar)
>> (defvar bar 2))
>> 
>> I'd have expected the end result to be bar = foo = 1.
>> However, the actual result is bar = foo = 2.

> Isn't this really a problem with defvaralias?

Yes.

> Perhaps we could test there if new-alias is bound and if so assign the
> value to base-variable.

Indeed except if base-variable already exist, we can't do that.


        Stefan




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

* Re: define-obsolete-variable-alias problem
  2008-04-11  1:36   ` Stefan Monnier
@ 2008-04-11  3:53     ` Glenn Morris
  2008-04-11  4:12       ` Glenn Morris
  0 siblings, 1 reply; 9+ messages in thread
From: Glenn Morris @ 2008-04-11  3:53 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Nick Roberts, emacs-devel

Stefan Monnier wrote:

>> Isn't this really a problem with defvaralias?
>
> Yes.
>
>> Perhaps we could test there if new-alias is bound and if so assign the
>> value to base-variable.
>
> Indeed except if base-variable already exist, we can't do that.

OK, I think I've installed that.

However if it is to work for the case I posted,
define-obsolete-variable-alias must be placed _before_ an associated
defcustom. A quick glance in some random .el files shows that often it
is not. I know I usually write them the other way round. Time to move
a bunch of them?




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

* Re: define-obsolete-variable-alias problem
  2008-04-11  3:53     ` Glenn Morris
@ 2008-04-11  4:12       ` Glenn Morris
  2008-04-11 17:29         ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Glenn Morris @ 2008-04-11  4:12 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Nick Roberts, emacs-devel

Glenn Morris wrote:

>> Indeed except if base-variable already exist, we can't do that.
[...]
> define-obsolete-variable-alias must be placed _before_ an associated
> defcustom.

Actually, thinking about it more, I don't see why it can't be done if
base-variable already exists?




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

* Re: define-obsolete-variable-alias problem
  2008-04-11  4:12       ` Glenn Morris
@ 2008-04-11 17:29         ` Stefan Monnier
  2008-04-11 18:03           ` Glenn Morris
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2008-04-11 17:29 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Nick Roberts, emacs-devel

>>> Indeed except if base-variable already exist, we can't do that.
> [...]
>> define-obsolete-variable-alias must be placed _before_ an associated
>> defcustom.

> Actually, thinking about it more, I don't see why it can't be done if
> base-variable already exists?

You can call defvaralias after the base_var has been set.
That's perfectly fine.  But if both base_var and new_alias are set when
you call defvaralias, then defvaralias can't know which of the two
values to use.


        Stefan




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

* Re: define-obsolete-variable-alias problem
  2008-04-11 17:29         ` Stefan Monnier
@ 2008-04-11 18:03           ` Glenn Morris
  2008-04-11 19:16             ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Glenn Morris @ 2008-04-11 18:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Nick Roberts, emacs-devel

Stefan Monnier wrote:

> But if both base_var and new_alias are set when you call
> defvaralias, then defvaralias can't know which of the two values to
> use.

I'm probably fixated on define-obsolete-variable-alias.
Always using the value of new_alias would be the right thing there
AFAICS, and I can't see a downside to always doing so.




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

* Re: define-obsolete-variable-alias problem
  2008-04-11 18:03           ` Glenn Morris
@ 2008-04-11 19:16             ` Stefan Monnier
  2008-04-11 20:14               ` Glenn Morris
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2008-04-11 19:16 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Nick Roberts, emacs-devel

>> But if both base_var and new_alias are set when you call
>> defvaralias, then defvaralias can't know which of the two values to use.

> I'm probably fixated on define-obsolete-variable-alias.
> Always using the value of new_alias would be the right thing there
> AFAICS,

No.


        Stefan


PS: BTW "new_alias" = "obsolete_name".




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

* Re: define-obsolete-variable-alias problem
  2008-04-11 19:16             ` Stefan Monnier
@ 2008-04-11 20:14               ` Glenn Morris
  0 siblings, 0 replies; 9+ messages in thread
From: Glenn Morris @ 2008-04-11 20:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Nick Roberts, emacs-devel

Stefan Monnier wrote:

> No.

OK, I'll give up on understanding this, and go away and move a bunch
of define-obsolete-variable-alias statements. (There are < 100; I'm
surprised).




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

end of thread, other threads:[~2008-04-11 20:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-09 19:16 define-obsolete-variable-alias problem Glenn Morris
2008-04-10  4:54 ` Nick Roberts
2008-04-11  1:36   ` Stefan Monnier
2008-04-11  3:53     ` Glenn Morris
2008-04-11  4:12       ` Glenn Morris
2008-04-11 17:29         ` Stefan Monnier
2008-04-11 18:03           ` Glenn Morris
2008-04-11 19:16             ` Stefan Monnier
2008-04-11 20:14               ` Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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