unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#669: 23.0.60; defalias is not taken into account by C-h k
@ 2008-08-07 18:23 Drew Adams
  2008-08-07 20:54 ` Drew Adams
  0 siblings, 1 reply; 10+ messages in thread
From: Drew Adams @ 2008-08-07 18:23 UTC (permalink / raw)
  To: emacs-pretest-bug

emacs -Q
 
(defun foo (&optional predicate)
  "" (interactive) (message "FOO"))
 
(defalias 'lisp-complete-symbol (symbol-function 'foo))
 
C-h k then shows this, which is 100% wrong:
 
M-TAB (translated from <escape> <tab>) runs the command
lisp-complete-symbol, which is an interactive Lisp function in
`lisp.el'.
 
It is bound to M-TAB.
 
(lisp-complete-symbol &optional predicate)
 
 
 
In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
 of 2008-08-01 on LENNART-69DE564
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/g/include
-fno-crossjumping'
 
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t
 
Major mode: Emacs-Lisp
 
Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
 
Recent input:
<help-echo> C-x C-f t h r o w - r r r r . e l <return> 
<down-mouse-1> <mouse-1> ( d e f u n SPC f o o SPC 
( <backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <help-echo> C-h f l i s p - 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<help-echo> <help-echo> l i s p - c o m p l e t e - 
s y m b o l <return> <help-echo> <help-echo> <help-echo> 








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

* bug#669: 23.0.60; defalias is not taken into account by C-h k
  2008-08-07 18:23 bug#669: 23.0.60; defalias is not taken into account by C-h k Drew Adams
@ 2008-08-07 20:54 ` Drew Adams
  2008-08-13 17:05   ` martin rudalics
  0 siblings, 1 reply; 10+ messages in thread
From: Drew Adams @ 2008-08-07 20:54 UTC (permalink / raw)
  To: 669, emacs-pretest-bug

If you use (defalias 'lisp-complete-symbol 'foo) instead, then this is output:

M-TAB (translated from <escape> <tab>) runs the command
lisp-complete-symbol, which is an alias for `foo' in `lisp.el'.

It is bound to M-TAB.

(lisp-complete-symbol &optional predicate)

This is still wrong, because `foo' is not in `lisp.el' (and the defalias is not
in `lisp.el').

This bug appears as far back as Emacs 20.7.


> From: Drew Adams Sent: Thursday, August 07, 2008 11:23 AM
> emacs -Q
>  
> (defun foo (&optional predicate)
>   "" (interactive) (message "FOO"))
>  
> (defalias 'lisp-complete-symbol (symbol-function 'foo))
>  
> C-h k then shows this, which is 100% wrong:
>  
> M-TAB (translated from <escape> <tab>) runs the command
> lisp-complete-symbol, which is an interactive Lisp function in
> `lisp.el'.
>  
> It is bound to M-TAB.
>  
> (lisp-complete-symbol &optional predicate)
>  
>  
>  
> In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
>  of 2008-08-01 on LENNART-69DE564
> Windowing system distributor `Microsoft Corp.', version 5.1.2600
> configured using `configure --with-gcc (3.4) --no-opt 
> --cflags -Ic:/g/include
> -fno-crossjumping'
>  
> Important settings:
>   value of $LC_ALL: nil
>   value of $LC_COLLATE: nil
>   value of $LC_CTYPE: nil
>   value of $LC_MESSAGES: nil
>   value of $LC_MONETARY: nil
>   value of $LC_NUMERIC: nil
>   value of $LC_TIME: nil
>   value of $LANG: ENU
>   value of $XMODIFIERS: nil
>   locale-coding-system: cp1252
>   default-enable-multibyte-characters: t
>  
> Major mode: Emacs-Lisp
>  
> Minor modes in effect:
>   tooltip-mode: t
>   tool-bar-mode: t
>   mouse-wheel-mode: t
>   menu-bar-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   blink-cursor-mode: t
>   global-auto-composition-mode: t
>   auto-composition-mode: t
>   auto-encryption-mode: t
>   auto-compression-mode: t
>   line-number-mode: t
>   transient-mark-mode: t
>  
> Recent input:
> <help-echo> C-x C-f t h r o w - r r r r . e l <return> 
> <down-mouse-1> <mouse-1> ( d e f u n SPC f o o SPC 
> ( <backspace> <backspace> <backspace> <backspace> <backspace> 
> <backspace> <backspace> <backspace> <backspace> <backspace> 
> <backspace> <backspace> <help-echo> C-h f l i s p - 
> <backspace> <backspace> <backspace> <backspace> <backspace> 
> <help-echo> <help-echo> l i s p - c o m p l e t e - 
> s y m b o l <return> <help-echo> <help-echo> <help-echo> 
> 
> 
> 
> 
> 
> 
> 







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

* bug#669: 23.0.60; defalias is not taken into account by C-h k
  2008-08-07 20:54 ` Drew Adams
@ 2008-08-13 17:05   ` martin rudalics
  2008-08-13 17:27     ` Drew Adams
  0 siblings, 1 reply; 10+ messages in thread
From: martin rudalics @ 2008-08-13 17:05 UTC (permalink / raw)
  To: Drew Adams; +Cc: 669

 > If you use (defalias 'lisp-complete-symbol 'foo) instead, then this is output:
 >
 > M-TAB (translated from <escape> <tab>) runs the command
 > lisp-complete-symbol, which is an alias for `foo' in `lisp.el'.
 >
 > It is bound to M-TAB.
 >
 > (lisp-complete-symbol &optional predicate)
 >
 > This is still wrong, because `foo' is not in `lisp.el' (and the defalias is not
 > in `lisp.el').
 >
 > This bug appears as far back as Emacs 20.7.
 >
 >
 >> From: Drew Adams Sent: Thursday, August 07, 2008 11:23 AM
 >> emacs -Q
 >>
 >> (defun foo (&optional predicate)
 >>   "" (interactive) (message "FOO"))
 >>
 >> (defalias 'lisp-complete-symbol (symbol-function 'foo))
 >>
 >> C-h k then shows this, which is 100% wrong:
 >>
 >> M-TAB (translated from <escape> <tab>) runs the command
 >> lisp-complete-symbol, which is an interactive Lisp function in
 >> `lisp.el'.
 >>
 >> It is bound to M-TAB.
 >>
 >> (lisp-complete-symbol &optional predicate)

I'm currently rewriting help-fns.el and can produce


M-TAB (translated from <escape> <tab>) runs the command
lisp-complete-symbol, which is an interactive Lisp function.

It is bound to M-TAB, <menu-bar> <lisp-interaction>
<lisp-complete-symbol>, H-SPC.

(lisp-complete-symbol &optional predicate)


and


M-TAB (translated from <escape> <tab>) runs the command
lisp-complete-symbol, which is an alias for `foo'.

It is bound to M-TAB, <menu-bar> <lisp-interaction>
<lisp-complete-symbol>, H-SPC.

(lisp-complete-symbol &optional predicate)


Are these acceptable?

martin







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

* bug#669: 23.0.60; defalias is not taken into account by C-h k
  2008-08-13 17:05   ` martin rudalics
@ 2008-08-13 17:27     ` Drew Adams
  2008-08-13 21:17       ` martin rudalics
  0 siblings, 1 reply; 10+ messages in thread
From: Drew Adams @ 2008-08-13 17:27 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 669

>  > If you use (defalias 'lisp-complete-symbol 'foo) instead, 
>  > then this is output:
>  >
>  > M-TAB (translated from <escape> <tab>) runs the command
>  > lisp-complete-symbol, which is an alias for `foo' in `lisp.el'.
>  >
>  > It is bound to M-TAB.
>  >
>  > (lisp-complete-symbol &optional predicate)
>  >
>  > This is still wrong, because `foo' is not in `lisp.el' 
>  > (and the defalias is not in `lisp.el').
>  >
>  > This bug appears as far back as Emacs 20.7.
>  >
>  >
>  >> From: Drew Adams Sent: Thursday, August 07, 2008 11:23 AM
>  >> emacs -Q
>  >>
>  >> (defun foo (&optional predicate)
>  >>   "" (interactive) (message "FOO"))
>  >>
>  >> (defalias 'lisp-complete-symbol (symbol-function 'foo))
>  >>
>  >> C-h k then shows this, which is 100% wrong:
>  >>
>  >> M-TAB (translated from <escape> <tab>) runs the command
>  >> lisp-complete-symbol, which is an interactive Lisp function in
>  >> `lisp.el'.
>  >>
>  >> It is bound to M-TAB.
>  >>
>  >> (lisp-complete-symbol &optional predicate)
> 
> I'm currently rewriting help-fns.el and can produce
> 
> M-TAB (translated from <escape> <tab>) runs the command
> lisp-complete-symbol, which is an interactive Lisp function.
> 
> It is bound to M-TAB, <menu-bar> <lisp-interaction>
> <lisp-complete-symbol>, H-SPC.
> 
> (lisp-complete-symbol &optional predicate)
> 
> and
> 
> M-TAB (translated from <escape> <tab>) runs the command
> lisp-complete-symbol, which is an alias for `foo'.
> 
> It is bound to M-TAB, <menu-bar> <lisp-interaction>
> <lisp-complete-symbol>, H-SPC.
> 
> (lisp-complete-symbol &optional predicate)
> 
> Are these acceptable?

Hi Martin, 

Thanks for working on this.

Not completely fixed yet, because it doesn't say anything about where `foo' is
defined (assuming it is defined in a file somewhere). If you could add that,
that would be great. The point is that we do want to send the user to the source
code, but not to the original `lisp-complete-symbol' source code.

We also need to be sure that the `foo' doc string is used. In my test example I
omitted that.

And both of these cases need to be treated:

(defalias 'lisp-complete-symbol 'foo)
(defalias 'lisp-complete-symbol (symbol-function 'foo))

Thx - Drew







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

* bug#669: 23.0.60; defalias is not taken into account by C-h k
  2008-08-13 17:27     ` Drew Adams
@ 2008-08-13 21:17       ` martin rudalics
  2008-08-13 21:41         ` Drew Adams
  2008-08-14 20:00         ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: martin rudalics @ 2008-08-13 21:17 UTC (permalink / raw)
  To: Drew Adams; +Cc: 669

 > Not completely fixed yet, because it doesn't say anything about where `foo' is
 > defined (assuming it is defined in a file somewhere).

If it is "defined in a file somewhere" you can jump to `foo' and see
where it is defined.  IIUC your assumption was that it's been defined
and evaluated in a buffer only.

 > If you could add that,
 > that would be great. The point is that we do want to send the user to the source
 > code, but not to the original `lisp-complete-symbol' source code.

If it's defined in a file we can send the user to the source code in the

   (defalias 'lisp-complete-symbol 'foo)

case via the `foo' indirection but certainly _not_ in the

   (defalias 'lisp-complete-symbol (symbol-function 'foo))

because, well, look at the return value of (symbol-function 'foo).

 > We also need to be sure that the `foo' doc string is used. In my test example I
 > omitted that.

In the indirection case follow the link to `foo' and get its doc-string
from there.  In the `symbol-function' case you simply have to provide
your own doc-string via the third arg of `defalias'.

 > And both of these cases need to be treated:
 >
 > (defalias 'lisp-complete-symbol 'foo)
 > (defalias 'lisp-complete-symbol (symbol-function 'foo))

I suppose I posted the *Help* output for both cases.

martin







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

* bug#669: 23.0.60; defalias is not taken into account by C-h k
  2008-08-13 21:17       ` martin rudalics
@ 2008-08-13 21:41         ` Drew Adams
  2008-08-14  6:18           ` martin rudalics
  2008-08-14 20:00         ` Stefan Monnier
  1 sibling, 1 reply; 10+ messages in thread
From: Drew Adams @ 2008-08-13 21:41 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 669

>  > Not completely fixed yet, because it doesn't say anything 
>  > about where `foo' is
>  > defined (assuming it is defined in a file somewhere).
> 
> If it is "defined in a file somewhere" you can jump to `foo' and see
> where it is defined.  IIUC your assumption was that it's been defined
> and evaluated in a buffer only.

I didn't mean to make any such assumption. The example I sent was ambiguous in
this regard, but it did probably suggest a definition outside of a file.

If the new definition is in a file that is loaded, then it would be good to
treat it the same way we treat such a definition when it has nothing aliased to
it: give the function name and the file it is defined in.

That is, for (defun foo () "..." 5) we don't just print `foo' and let you click
that link to find out where it is defined. We also print "is an interactive
compiled Lisp function in `titi.el'". That same format would be preferable for
the defalias case also: "`toto' is an alias for `foo' which is an interactive
compiled Lisp function in `titi.el'".

IOW, the only thing to be added is the fact that `toto' is an alias for `foo'.
We still need to know what `foo' is and where it was defined.

>  > If you could add that, that would be great. The point is that
>  > we do want to send the user to the source
>  > code, but not to the original `lisp-complete-symbol' source code.
> 
> If it's defined in a file we can send the user to the source 
> code in the
> 
>    (defalias 'lisp-complete-symbol 'foo)
> 
> case via the `foo' indirection

It's the `lisp-complete-symbol' that is the indirection: it is a pointer to
`foo'.

> but certainly _not_ in the
> 
>    (defalias 'lisp-complete-symbol (symbol-function 'foo))
> 
> because, well, look at the return value of (symbol-function 'foo).

I guess this is because `defalias' is a function, not a macro, so we don't have
access to the sexp (symbol-function 'foo) and hence to `foo'. OK.

>  > We also need to be sure that the `foo' doc string is used. 
>  > In my test example I omitted that.
> 
> In the indirection case follow the link to `foo' and get its 
> doc-string from there.  In the `symbol-function' case you
> simply have to provide your own doc-string via the third arg of `defalias'.

This is presumably the same problem as above. OK.

So it sounds like we can build the source file link "in `titi.el'" in the case
of 'foo but not in the case of (symbol-function 'foo). That's still pretty good
- much more helpful than what we have now (which is wrong and misleading).

>  > And both of these cases need to be treated:
>  >
>  > (defalias 'lisp-complete-symbol 'foo)
>  > (defalias 'lisp-complete-symbol (symbol-function 'foo))
> 
> I suppose I posted the *Help* output for both cases.

Thx - Drew







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

* bug#669: 23.0.60; defalias is not taken into account by C-h k
  2008-08-13 21:41         ` Drew Adams
@ 2008-08-14  6:18           ` martin rudalics
  2008-08-14 15:33             ` Drew Adams
  2008-08-14 20:03             ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: martin rudalics @ 2008-08-14  6:18 UTC (permalink / raw)
  To: Drew Adams; +Cc: 669

 > That is, for (defun foo () "..." 5) we don't just print `foo' and let you click
 > that link to find out where it is defined. We also print "is an interactive
 > compiled Lisp function in `titi.el'". That same format would be preferable for
 > the defalias case also: "`toto' is an alias for `foo' which is an interactive
 > compiled Lisp function in `titi.el'".

Doing C-h f RET rplaca RET gets me a Help buffer with the line

   rplaca is an alias for `setcar' in `.../subr.el'.

Clicking on

- the "setcar" link gets me to the Help buffer for `setcar',

- the ".../subr.el" link gets me to the location of the defalias.

I suppose we shouldn't change that behavior.

martin







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

* bug#669: 23.0.60; defalias is not taken into account by C-h k
  2008-08-14  6:18           ` martin rudalics
@ 2008-08-14 15:33             ` Drew Adams
  2008-08-14 20:03             ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Drew Adams @ 2008-08-14 15:33 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 669

>  > That is, for (defun foo () "..." 5) we don't just print 
> `foo' and let you click
>  > that link to find out where it is defined. We also print 
> "is an interactive
>  > compiled Lisp function in `titi.el'". That same format 
> would be preferable for
>  > the defalias case also: "`toto' is an alias for `foo' 
> which is an interactive
>  > compiled Lisp function in `titi.el'".
> 
> Doing C-h f RET rplaca RET gets me a Help buffer with the line
> 
>    rplaca is an alias for `setcar' in `.../subr.el'.
> 
> Clicking on
> 
> - the "setcar" link gets me to the Help buffer for `setcar',
> 
> - the ".../subr.el" link gets me to the location of the defalias.
> 
> I suppose we shouldn't change that behavior.

I'll leave it up to you - whatever you think is appropriate. Thanks for working
on this.

The general idea, from my point of view, is to immediately give the user the
most info s?he might need, provided that doesn't obscure the most important info
s?he is after (the doc string, in this case).

The main thing I wanted to point out was that `C-h f' was describing the wrong
things and attributing those faulty descriptions to the right things. It should
say that the alias is an alias and then describe the function for which it is an
alias. If it can also let you know where the alias is defined and where the
function it points to is defined, so much the better.







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

* bug#669: 23.0.60; defalias is not taken into account by C-h k
  2008-08-13 21:17       ` martin rudalics
  2008-08-13 21:41         ` Drew Adams
@ 2008-08-14 20:00         ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2008-08-14 20:00 UTC (permalink / raw)
  To: martin rudalics; +Cc: 669

> case via the `foo' indirection but certainly _not_ in the
>   (defalias 'lisp-complete-symbol (symbol-function 'foo))
> because, well, look at the return value of (symbol-function 'foo).

We certainly could, if we labelled every lambda we build with the
location where it was found (rather than labelling the symbol to which
the lambda is bound).  In some cases we already do that (if the code is
byte-compiled and the lambda has a docstring, we include a pointer to
the docstring which includes the file name).


        Stefan






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

* bug#669: 23.0.60; defalias is not taken into account by C-h k
  2008-08-14  6:18           ` martin rudalics
  2008-08-14 15:33             ` Drew Adams
@ 2008-08-14 20:03             ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2008-08-14 20:03 UTC (permalink / raw)
  To: martin rudalics; +Cc: 669

> Clicking on
> - the "setcar" link gets me to the Help buffer for `setcar',
> - the ".../subr.el" link gets me to the location of the defalias.
> I suppose we shouldn't change that behavior.

Indeed we don't want to change that: having access to the defalias
itself is more important than saving a click in the case the user wants
to access the actual function body.


        Stefan






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

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

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-07 18:23 bug#669: 23.0.60; defalias is not taken into account by C-h k Drew Adams
2008-08-07 20:54 ` Drew Adams
2008-08-13 17:05   ` martin rudalics
2008-08-13 17:27     ` Drew Adams
2008-08-13 21:17       ` martin rudalics
2008-08-13 21:41         ` Drew Adams
2008-08-14  6:18           ` martin rudalics
2008-08-14 15:33             ` Drew Adams
2008-08-14 20:03             ` Stefan Monnier
2008-08-14 20:00         ` Stefan Monnier

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