unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* defvaralias
@ 2005-05-06  1:42 Luc Teirlinck
  2005-05-06  2:01 ` defvaralias Luc Teirlinck
                   ` (3 more replies)
  0 siblings, 4 replies; 26+ messages in thread
From: Luc Teirlinck @ 2005-05-06  1:42 UTC (permalink / raw)


The old docstrings of define-obsolete-{function,variable}-alias
contained statements that if no docstring was provided, that is,
`(define-obsolete-{function,variable}-alias 'old 'new)', then OLD
would get the docstring of NEW, _unless_ it already had one.  This has
been replaced with references to the `defalias' and `defvaralias '
docs, which have no such "unless" statements.  The "unless" appears to
be definitely false in the `function' case.  But it is true in the
variable case.  That is because it is false for defalias, but true for
defvaralias.

There are two solutions for the variable case.  Document the fact in
the docstring and Elisp documentation of defvaralias, or make
defvaralias behave exactly like defalias and get rid of the "unless"
behavior.  I prefer the latter.  The patch below would implement
it.  I can install if desired.

To be more concrete:

After:

(defvar var1 "DOC1")
(defvar var2 "DOC2")
(defvaralias 'var1 'var2)

C-h v var1 RET

now shows "DOC1", whereas after the patch below it shows "DOC2", which
is behavior consistent with defalias.

===File ~/eval.c-diff=======================================
*** eval.c	03 May 2005 20:44:24 -0500	1.237
--- eval.c	05 May 2005 19:42:50 -0500	
***************
*** 747,752 ****
--- 747,754 ----
    LOADHIST_ATTACH (symbol);
    if (!NILP (docstring))
      Fput (symbol, Qvariable_documentation, docstring);
+   else
+     Fput (symbol, Qvariable_documentation, Qnil);
  
    return aliased;
  }
============================================================

^ permalink raw reply	[flat|nested] 26+ messages in thread
* defvaralias
@ 2003-10-28  1:25 Luc Teirlinck
  2003-10-28  2:08 ` defvaralias Miles Bader
  2003-10-29 19:02 ` defvaralias Richard Stallman
  0 siblings, 2 replies; 26+ messages in thread
From: Luc Teirlinck @ 2003-10-28  1:25 UTC (permalink / raw)


Output of C-h f defvaralias:

defvaralias is a built-in function.
(defvaralias SYMBOL ALIASED &optional DOCSTRING)

Make SYMBOL a variable alias for symbol ALIASED.  

Setting the value of SYMBOL will subsequently set the value of ALIASED, 
and getting the value of SYMBOL will return the value ALIASED has.
ALIASED nil means remove the alias; SYMBOL is unbound after that.
Third arg DOCSTRING, if non-nil, is documentation for SYMBOL.

My remarks:

This suggests that (defvaralias 'var nil) will make `var' cease to be
an alias if it was one and unbind var, if var was bound.  Instead, var
becomes, pretty logically, an alias for `nil'.  I looked at the code
in eval.c and the code makes not the slightest attempt to implement
any special behavior when ALIASED is `nil'.  I propose to just remove
the next to last line in the doc string and could commit this change
if desired.  I just want to make sure that the described behavior is
not _really_ intended (and hence the bug would be in the code rather
than in the doc string).

Sincerely,

Luc.

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

end of thread, other threads:[~2005-05-08 16:41 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-06  1:42 defvaralias Luc Teirlinck
2005-05-06  2:01 ` defvaralias Luc Teirlinck
2005-05-06  4:30 ` defvaralias Nick Roberts
2005-05-06 14:56   ` defvaralias Luc Teirlinck
2005-05-07  1:19     ` defvaralias Nick Roberts
2005-05-07  1:32       ` defvaralias Luc Teirlinck
2005-05-07 15:11         ` defvaralias Stefan Monnier
2005-05-07 15:33           ` defvaralias Luc Teirlinck
2005-05-07 15:39           ` defvaralias Luc Teirlinck
2005-05-07 18:35       ` defvaralias Richard Stallman
2005-05-06 15:43   ` defvaralias Luc Teirlinck
2005-05-06 18:51 ` defvaralias Richard Stallman
2005-05-06 22:39   ` defvaralias Luc Teirlinck
2005-05-07 18:35     ` defvaralias Richard Stallman
2005-05-07 18:44       ` defvaralias Luc Teirlinck
2005-05-07 19:31         ` defvaralias Luc Teirlinck
2005-05-07 20:09         ` defvaralias Juanma Barranquero
2005-05-07 20:54           ` defvaralias Luc Teirlinck
2005-05-07 20:04       ` defvaralias Juanma Barranquero
2005-05-08 16:11         ` defvaralias Richard Stallman
2005-05-08 16:41           ` defvaralias Luc Teirlinck
2005-05-07  9:26 ` defvaralias Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2003-10-28  1:25 defvaralias Luc Teirlinck
2003-10-28  2:08 ` defvaralias Miles Bader
2003-10-28  2:29   ` defvaralias Luc Teirlinck
2003-10-29 19:02 ` defvaralias Richard Stallman

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