all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* eval-buffer with debug-on-error t
@ 2005-07-07 13:42 Lennart Borgman
  2005-07-09  4:21 ` Richard M. Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2005-07-07 13:42 UTC (permalink / raw)


I have debug-on-error set to t. When I do an eval-buffer and there is an 
undefined function:

   (this-is-no-fun)

I get the error "Wrong type argument: stringp, nul

If I instead let the region be the whole buffer and to eval-region I get 
a traceback with "Symbol's function definition is void: this-is-no-fun".

Is not the later much more useful? Can't eval-buffer return something 
similar?

When debug-on-error is nil eval-buffer returns the same as eval-region.

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

* Re: eval-buffer with debug-on-error t
  2005-07-07 13:42 eval-buffer with debug-on-error t Lennart Borgman
@ 2005-07-09  4:21 ` Richard M. Stallman
  2005-07-09 10:23   ` Johan Bockgård
  2005-07-09 10:41   ` Lennart Borgman
  0 siblings, 2 replies; 5+ messages in thread
From: Richard M. Stallman @ 2005-07-09  4:21 UTC (permalink / raw)
  Cc: emacs-devel

    I have debug-on-error set to t. When I do an eval-buffer and there is an 
    undefined function:

       (this-is-no-fun)

    I get the error "Wrong type argument: stringp, nul

Does this fix it?  (I installed a more elaborate patch.)

*** debug.el	05 Jul 2005 00:45:47 -0400	1.90
--- debug.el	09 Jul 2005 00:05:50 -0400	
***************
*** 315,322 ****
      (while (re-search-forward "^  eval-buffer(" nil t)
        (end-of-line)
        (insert (format "\n  ;;; Reading at buffer position %d"
! 		      (with-current-buffer (nth 2 (backtrace-frame (debugger-frame-number)))
! 			(point))))))
    (debugger-make-xrefs))
  
  (defun debugger-make-xrefs (&optional buffer)
--- 315,325 ----
      (while (re-search-forward "^  eval-buffer(" nil t)
        (end-of-line)
        (insert (format "\n  ;;; Reading at buffer position %d"
! 		      (with-current-buffer
! 			  (or (nth 2 (backtrace-frame (debugger-frame-number)))
! 			      debugger-old-buffer)
! 			(point))))
!       ))
    (debugger-make-xrefs))
  
  (defun debugger-make-xrefs (&optional buffer)

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

* Re: eval-buffer with debug-on-error t
  2005-07-09  4:21 ` Richard M. Stallman
@ 2005-07-09 10:23   ` Johan Bockgård
  2005-07-10  5:19     ` Richard M. Stallman
  2005-07-09 10:41   ` Lennart Borgman
  1 sibling, 1 reply; 5+ messages in thread
From: Johan Bockgård @ 2005-07-09 10:23 UTC (permalink / raw)


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

> Does this fix it?  (I installed a more elaborate patch.)

Well, it does make the error go away.

A problem is that `debugger-old-buffer' is not necessarily the same
buffer that was current when `eval-buffer' was called.


Example (with the patch):

Run emacs -Q

M-x toggle-debug-on-error RET

Insert this into *scratch*:

     (get-buffer-create "foo")
     (with-current-buffer "foo"
       (error "foo"))

M-x eval-buffer RET

=>

Debugger entered--Lisp error: (error "foo")
  signal(error ("foo"))
  error("foo")
  (save-current-buffer (set-buffer "foo") (error "foo"))
  (with-current-buffer "foo" (error "foo"))
  eval-buffer()  ; Reading at buffer position 1
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the position in the "foo" buffer.




`eval-region' has the same problem. In fact, regardless of that
problem the feature does not seem very useful at present when it comes
to eval-region.

E.g. if you do C-x h M-x eval-region RET and there is an error you
will get a note like this in the backtrace no matter where the error
occurred:

  eval-region(1 500)  ; Reading at buffer position 1

Since point doesn't move (eval-region apparently works differently
than eval-buffer in this respect) the value of point will always be at
the start or the end of the region (and these values are already
present in the backtrace).

-- 
Johan Bockgård

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

* Re: eval-buffer with debug-on-error t
  2005-07-09  4:21 ` Richard M. Stallman
  2005-07-09 10:23   ` Johan Bockgård
@ 2005-07-09 10:41   ` Lennart Borgman
  1 sibling, 0 replies; 5+ messages in thread
From: Lennart Borgman @ 2005-07-09 10:41 UTC (permalink / raw)
  Cc: emacs-devel

Richard M. Stallman wrote:

>    I have debug-on-error set to t. When I do an eval-buffer and there is an 
>    undefined function:
>
>       (this-is-no-fun)
>
>    I get the error "Wrong type argument: stringp, nul
>
>Does this fix it?  (I installed a more elaborate patch.)
>  
>
Yes, thanks, I think so. I tested with the latest CVS and emacs -Q.

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

* Re: eval-buffer with debug-on-error t
  2005-07-09 10:23   ` Johan Bockgård
@ 2005-07-10  5:19     ` Richard M. Stallman
  0 siblings, 0 replies; 5+ messages in thread
From: Richard M. Stallman @ 2005-07-10  5:19 UTC (permalink / raw)
  Cc: emacs-devel

    A problem is that `debugger-old-buffer' is not necessarily the same
    buffer that was current when `eval-buffer' was called.

Strange, somehow I thought about that issue and concluded that it
would be the current buffer.  Now it's clear I was not thinking
straight at the time.

I fixed it another way.

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

end of thread, other threads:[~2005-07-10  5:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-07 13:42 eval-buffer with debug-on-error t Lennart Borgman
2005-07-09  4:21 ` Richard M. Stallman
2005-07-09 10:23   ` Johan Bockgård
2005-07-10  5:19     ` Richard M. Stallman
2005-07-09 10:41   ` Lennart Borgman

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.