unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* debug-on-entry question
@ 2005-06-18 10:03 Yoni Rabkin Katzenell
  2005-06-18 11:23 ` David Kastrup
  2005-06-19 14:03 ` Juri Linkov
  0 siblings, 2 replies; 18+ messages in thread
From: Yoni Rabkin Katzenell @ 2005-06-18 10:03 UTC (permalink / raw)



Is there an existing function which performs the following?

(defun debug-on-entry-at-point ()
  "Perform \\[debug-on-entry] on the function at point."
  (let ((fn (function-called-at-point)))
    (if fn
	(debug-on-entry fn)
      (message "No function at point"))))

-- 
"Cut your own wood and it will warm you twice"
	Regards, Yoni Rabkin Katzenell

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

* Re: debug-on-entry question
  2005-06-18 10:03 debug-on-entry question Yoni Rabkin Katzenell
@ 2005-06-18 11:23 ` David Kastrup
  2005-06-18 11:47   ` Yoni Rabkin Katzenell
  2005-06-19 14:03 ` Juri Linkov
  1 sibling, 1 reply; 18+ messages in thread
From: David Kastrup @ 2005-06-18 11:23 UTC (permalink / raw)
  Cc: emacs-devel

Yoni Rabkin Katzenell <yoni-r@actcom.com> writes:

> Is there an existing function which performs the following?
>
> (defun debug-on-entry-at-point ()
>   "Perform \\[debug-on-entry] on the function at point."
>   (let ((fn (function-called-at-point)))
>     (if fn
> 	(debug-on-entry fn)
>       (message "No function at point"))))

Usually
M-x edebug-defun RET

is much more useful.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: debug-on-entry question
  2005-06-18 11:23 ` David Kastrup
@ 2005-06-18 11:47   ` Yoni Rabkin Katzenell
  0 siblings, 0 replies; 18+ messages in thread
From: Yoni Rabkin Katzenell @ 2005-06-18 11:47 UTC (permalink / raw)



Excellent, thank you.

-- 
"Cut your own wood and it will warm you twice"
	Regards, Yoni Rabkin Katzenell

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

* Re: debug-on-entry question
  2005-06-18 10:03 debug-on-entry question Yoni Rabkin Katzenell
  2005-06-18 11:23 ` David Kastrup
@ 2005-06-19 14:03 ` Juri Linkov
  2005-06-19 17:24   ` Drew Adams
                     ` (2 more replies)
  1 sibling, 3 replies; 18+ messages in thread
From: Juri Linkov @ 2005-06-19 14:03 UTC (permalink / raw)


> Is there an existing function which performs the following?
>
> (defun debug-on-entry-at-point ()
>   "Perform \\[debug-on-entry] on the function at point."
>   (let ((fn (function-called-at-point)))
>     (if fn
> 	(debug-on-entry fn)
>       (message "No function at point"))))

A better way to do this is to change the interactive specification of
`debug-on-entry' to call `function-called-at-point'.

For post-release: it would be good to rewrite the function
`call-interactively' in Lisp which will allow easy modification of
reading arguments according to code letters (e.g. in this particular
case adding a call to `function-called-at-point' for the code letter `a').

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* RE: debug-on-entry question
  2005-06-19 14:03 ` Juri Linkov
@ 2005-06-19 17:24   ` Drew Adams
  2005-06-19 17:48     ` David Kastrup
  2005-06-20  4:59     ` Juri Linkov
  2005-06-20  3:50   ` Richard Stallman
  2005-06-20 17:41   ` Lute Kamstra
  2 siblings, 2 replies; 18+ messages in thread
From: Drew Adams @ 2005-06-19 17:24 UTC (permalink / raw)


    change the interactive specification of
    `debug-on-entry' to call `function-called-at-point'.

Yes. I've suggested this previously. When debugging, you are often in an
Emacs-Lisp buffer, and this is useful.

    For post-release: it would be good to rewrite the function
    `call-interactively' in Lisp which will allow easy modification of
    reading arguments according to code letters (e.g. in this particular
    case adding a call to `function-called-at-point' for the code
    letter `a').

Not a bad idea.

---

However, that would only help with uses of `call-interactively', not uses of
`interactive' itself.

It's probably not feasible (and I foresee immediate dismissal of the idea,
regardless of feasibility), but what about also having a mechanism to let
users extend (redefine) the predefined `interactive' code letters?

For example, a user could define his own version of `b' in `(interactive
"b...")'. Instead of having to find all occurrences of `(interactive
"b...")' and replacing each of them with his own `(interactive (list
(my-read-buffer...)...)...)', he could just redefine what `(interactive
"b...")' means, in a single place. IOW, why not make the "bindings" between
the `interactive' code letters (e.g. `b') and their input-reading functions
available to users?

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

* Re: debug-on-entry question
  2005-06-19 17:24   ` Drew Adams
@ 2005-06-19 17:48     ` David Kastrup
  2005-06-19 18:07       ` Drew Adams
  2005-06-20  4:59     ` Juri Linkov
  1 sibling, 1 reply; 18+ messages in thread
From: David Kastrup @ 2005-06-19 17:48 UTC (permalink / raw)
  Cc: emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:

>     change the interactive specification of
>     `debug-on-entry' to call `function-called-at-point'.
>
> Yes. I've suggested this previously. When debugging, you are often
> in an Emacs-Lisp buffer, and this is useful.

_If_ you are in an Emacs-Lisp buffer and consequently have the source
code of the function to be debugged available, edebug-defun is orders
of magnitude more useful for debugging a particular function.

debug-on-entry is much less convenient, but can be used without having
the source at hand.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* RE: debug-on-entry question
  2005-06-19 17:48     ` David Kastrup
@ 2005-06-19 18:07       ` Drew Adams
  0 siblings, 0 replies; 18+ messages in thread
From: Drew Adams @ 2005-06-19 18:07 UTC (permalink / raw)


    >     change the interactive specification of
    >     `debug-on-entry' to call `function-called-at-point'.
    >
    > Yes. I've suggested this previously. When debugging, you are often
    > in an Emacs-Lisp buffer, and this is useful.

    _If_ you are in an Emacs-Lisp buffer and consequently have the source
    code of the function to be debugged available, edebug-defun is orders
    of magnitude more useful for debugging a particular function.

    debug-on-entry is much less convenient, but can be used without having
    the source at hand.

OK. I take that as an FYI about the usefulness and appropriateness of edebug
in a source-code buffer, but not as an argument not to let `debug-on-entry'
grab the function-at-point in its interactive spec.

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

* Re: debug-on-entry question
  2005-06-19 14:03 ` Juri Linkov
  2005-06-19 17:24   ` Drew Adams
@ 2005-06-20  3:50   ` Richard Stallman
  2005-06-20 17:41   ` Lute Kamstra
  2 siblings, 0 replies; 18+ messages in thread
From: Richard Stallman @ 2005-06-20  3:50 UTC (permalink / raw)
  Cc: emacs-devel

    For post-release: it would be good to rewrite the function
    `call-interactively' in Lisp which will allow easy modification of
    reading arguments according to code letters (e.g. in this particular
    case adding a call to `function-called-at-point' for the code letter `a').

I think that would be messy and unnecessary.  I would rather keep the
present scheme: code letters for doing something standard, and pure
Lisp code for everything else.

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

* Re: debug-on-entry question
  2005-06-19 17:24   ` Drew Adams
  2005-06-19 17:48     ` David Kastrup
@ 2005-06-20  4:59     ` Juri Linkov
  2005-06-20 15:42       ` Drew Adams
  2005-06-21  2:00       ` Richard Stallman
  1 sibling, 2 replies; 18+ messages in thread
From: Juri Linkov @ 2005-06-20  4:59 UTC (permalink / raw)
  Cc: emacs-devel

> However, that would only help with uses of `call-interactively', not
> uses of `interactive' itself.

I don't understand what you mean.  `interactive' is just a specification.
`call-interactively' interprets it.

> It's probably not feasible (and I foresee immediate dismissal of the idea,
> regardless of feasibility), but what about also having a mechanism to let
> users extend (redefine) the predefined `interactive' code letters?
>
> For example, a user could define his own version of `b' in `(interactive
> "b...")'. Instead of having to find all occurrences of `(interactive
> "b...")' and replacing each of them with his own `(interactive (list
> (my-read-buffer...)...)...)', he could just redefine what `(interactive
> "b...")' means, in a single place. IOW, why not make the "bindings" between
> the `interactive' code letters (e.g. `b') and their input-reading functions
> available to users?

Rewriting it in Lisp implies that you will be able to redefine default
code letters easily if you want.

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* RE: debug-on-entry question
  2005-06-20  4:59     ` Juri Linkov
@ 2005-06-20 15:42       ` Drew Adams
  2005-06-21  2:00       ` Richard Stallman
  1 sibling, 0 replies; 18+ messages in thread
From: Drew Adams @ 2005-06-20 15:42 UTC (permalink / raw)


    > However, that would only help with uses of `call-interactively', not
    > uses of `interactive' itself.
    
    I don't understand what you mean.  `interactive' is just a 
    specification.
    `call-interactively' interprets it.

Sorry; I see that now. I didn't realize it when I wrote that.    

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

* Re: debug-on-entry question
  2005-06-19 14:03 ` Juri Linkov
  2005-06-19 17:24   ` Drew Adams
  2005-06-20  3:50   ` Richard Stallman
@ 2005-06-20 17:41   ` Lute Kamstra
  2005-06-21 16:32     ` Juri Linkov
  2 siblings, 1 reply; 18+ messages in thread
From: Lute Kamstra @ 2005-06-20 17:41 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> A better way to do this is to change the interactive specification of
> `debug-on-entry' to call `function-called-at-point'.

How about this?

Lute.


Index: lisp/emacs-lisp/debug.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/debug.el,v
retrieving revision 1.87
diff -c -r1.87 debug.el
*** lisp/emacs-lisp/debug.el	14 Jun 2005 12:00:50 -0000	1.87
--- lisp/emacs-lisp/debug.el	20 Jun 2005 17:40:29 -0000
***************
*** 653,658 ****
--- 653,664 ----
        nil
      (funcall debugger 'debug)))
  
+ (defun debugger-special-form-p (symbol)
+   "Return whether SYMBOL is a special form."
+   (and (fboundp symbol)
+        (subrp (symbol-function symbol))
+        (eq (cdr (subr-arity (symbol-function symbol))) 'unevalled)))
+ 
  ;;;###autoload
  (defun debug-on-entry (function)
    "Request FUNCTION to invoke debugger each time it is called.
***************
*** 668,676 ****
  
  Use \\[cancel-debug-on-entry] to cancel the effect of this command.
  Redefining FUNCTION also cancels it."
!   (interactive "aDebug on entry (to function): ")
!   (when (and (subrp (symbol-function function))
! 	     (eq (cdr (subr-arity (symbol-function function))) 'unevalled))
      (error "Function %s is a special form" function))
    (if (or (symbolp (symbol-function function))
  	  (subrp (symbol-function function)))
--- 674,694 ----
  
  Use \\[cancel-debug-on-entry] to cancel the effect of this command.
  Redefining FUNCTION also cancels it."
!   (interactive
!    (let ((fn (function-called-at-point)) val)
!      (when (debugger-special-form-p fn)
!        (setq fn nil))
!      (setq val (completing-read 
! 		(if fn
! 		    (format "Debug on entry to function (default %s): " fn)
! 		  "Debug on entry to function: ")
! 		obarray
! 		#'(lambda (symbol)
! 		    (and (fboundp symbol)
! 			 (not (debugger-special-form-p symbol))))
! 		t nil nil (symbol-name fn)))
!      (list (if (equal val "") fn (intern val)))))
!   (when (debugger-special-form-p function)
      (error "Function %s is a special form" function))
    (if (or (symbolp (symbol-function function))
  	  (subrp (symbol-function function)))

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

* Re: debug-on-entry question
  2005-06-20  4:59     ` Juri Linkov
  2005-06-20 15:42       ` Drew Adams
@ 2005-06-21  2:00       ` Richard Stallman
  1 sibling, 0 replies; 18+ messages in thread
From: Richard Stallman @ 2005-06-21  2:00 UTC (permalink / raw)
  Cc: drew.adams, emacs-devel

    > For example, a user could define his own version of `b' in `(interactive
    > "b...")'. Instead of having to find all occurrences of `(interactive
    > "b...")' and replacing each of them with his own `(interactive (list
    > (my-read-buffer...)...)...)', he could just redefine what `(interactive
    > "b...")' means, in a single place. IOW, why not make the "bindings" between
    > the `interactive' code letters (e.g. `b') and their input-reading functions
    > available to users?

    Rewriting it in Lisp implies that you will be able to redefine default
    code letters easily if you want.

I think that allowing customization at that level is asking for
trouble.  Customizating details of how a specific letter `b' works is
not a problem, but letting programs simply redefine these codes is
asking for trouble.  What if two different packages both define Q but
define it in different ways?

It is much better if people keep on handling such cases by writing
Lisp code as they already have.  So aI will not entertain the idea
of adding a new feature of this kind.

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

* Re: debug-on-entry question
  2005-06-20 17:41   ` Lute Kamstra
@ 2005-06-21 16:32     ` Juri Linkov
  2005-06-22  3:40       ` Richard M. Stallman
  0 siblings, 1 reply; 18+ messages in thread
From: Juri Linkov @ 2005-06-21 16:32 UTC (permalink / raw)
  Cc: emacs-devel

>> A better way to do this is to change the interactive specification of
>> `debug-on-entry' to call `function-called-at-point'.
>
> How about this?

There are other commands using `a' letter to read function names (like
`elp-instrument-function', etc.) where getting the default function name
from the current buffer would be useful too.  So maybe it's better to
implement this in `call-interactively' for all commands using `a'?

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* Re: debug-on-entry question
  2005-06-21 16:32     ` Juri Linkov
@ 2005-06-22  3:40       ` Richard M. Stallman
  2005-06-22  8:32         ` Lute Kamstra
  2005-06-22 13:12         ` Juri Linkov
  0 siblings, 2 replies; 18+ messages in thread
From: Richard M. Stallman @ 2005-06-22  3:40 UTC (permalink / raw)
  Cc: Lute.Kamstra.lists, emacs-devel

    There are other commands using `a' letter to read function names (like
    `elp-instrument-function', etc.) where getting the default function name
    from the current buffer would be useful too.  So maybe it's better to
    implement this in `call-interactively' for all commands using `a'?

That seems like a good idea.

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

* Re: debug-on-entry question
  2005-06-22  3:40       ` Richard M. Stallman
@ 2005-06-22  8:32         ` Lute Kamstra
  2005-06-23  0:54           ` Richard M. Stallman
  2005-06-22 13:12         ` Juri Linkov
  1 sibling, 1 reply; 18+ messages in thread
From: Lute Kamstra @ 2005-06-22  8:32 UTC (permalink / raw)
  Cc: Juri Linkov, emacs-devel

"Richard M. Stallman" <rms@gnu.org> writes:

>     There are other commands using `a' letter to read function names (like
>     `elp-instrument-function', etc.) where getting the default function name
>     from the current buffer would be useful too.  So maybe it's better to
>     implement this in `call-interactively' for all commands using `a'?
>
> That seems like a good idea.

Ok, I'll work on that.

But I still like to apply the patch for debug-on-entry as is.  Besides
using function-called-at-point, it also filters out special forms
(which can't be set to break on entry).  Is that Ok?

Lute.

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

* Re: debug-on-entry question
  2005-06-22  3:40       ` Richard M. Stallman
  2005-06-22  8:32         ` Lute Kamstra
@ 2005-06-22 13:12         ` Juri Linkov
  2005-06-23 14:38           ` Drew Adams
  1 sibling, 1 reply; 18+ messages in thread
From: Juri Linkov @ 2005-06-22 13:12 UTC (permalink / raw)
  Cc: lute.kamstra.lists, emacs-devel

>     There are other commands using `a' letter to read function names (like
>     `elp-instrument-function', etc.) where getting the default function name
>     from the current buffer would be useful too.  So maybe it's better to
>     implement this in `call-interactively' for all commands using `a'?
>
> That seems like a good idea.

I have ideas for improving other code letters (for example, using ffap
for `f', `F', `D'), but they are much easier implementable in Lisp.

> I think that allowing customization at that level is asking for
> trouble.  Customizating details of how a specific letter `b' works is
> not a problem, but letting programs simply redefine these codes is
> asking for trouble.  What if two different packages both define Q but
> define it in different ways?
>
> It is much better if people keep on handling such cases by writing
> Lisp code as they already have.

The problem is in changing existing code letters.  Emacs allows
customization of almost everything down to redefining built-in core
functions, but disallows customization of default methods for reading
input arguments.  This is an artificial restriction contradicting the
principles of Emacs customization.

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* Re: debug-on-entry question
  2005-06-22  8:32         ` Lute Kamstra
@ 2005-06-23  0:54           ` Richard M. Stallman
  0 siblings, 0 replies; 18+ messages in thread
From: Richard M. Stallman @ 2005-06-23  0:54 UTC (permalink / raw)
  Cc: juri, emacs-devel

    But I still like to apply the patch for debug-on-entry as is.  Besides
    using function-called-at-point, it also filters out special forms
    (which can't be set to break on entry).  Is that Ok?

Yes.

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

* RE: debug-on-entry question
  2005-06-22 13:12         ` Juri Linkov
@ 2005-06-23 14:38           ` Drew Adams
  0 siblings, 0 replies; 18+ messages in thread
From: Drew Adams @ 2005-06-23 14:38 UTC (permalink / raw)


    The problem is in changing  [the behavior of]  existing
    code letters. Emacs allows customization of almost
    everything down to redefining built-in core functions,
    but disallows customization of default methods for reading
    input arguments.  This is an artificial restriction
    contradicting the principles of Emacs customization.

I agree.

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

end of thread, other threads:[~2005-06-23 14:38 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-18 10:03 debug-on-entry question Yoni Rabkin Katzenell
2005-06-18 11:23 ` David Kastrup
2005-06-18 11:47   ` Yoni Rabkin Katzenell
2005-06-19 14:03 ` Juri Linkov
2005-06-19 17:24   ` Drew Adams
2005-06-19 17:48     ` David Kastrup
2005-06-19 18:07       ` Drew Adams
2005-06-20  4:59     ` Juri Linkov
2005-06-20 15:42       ` Drew Adams
2005-06-21  2:00       ` Richard Stallman
2005-06-20  3:50   ` Richard Stallman
2005-06-20 17:41   ` Lute Kamstra
2005-06-21 16:32     ` Juri Linkov
2005-06-22  3:40       ` Richard M. Stallman
2005-06-22  8:32         ` Lute Kamstra
2005-06-23  0:54           ` Richard M. Stallman
2005-06-22 13:12         ` Juri Linkov
2005-06-23 14:38           ` Drew Adams

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