bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#10805: 24.0.93; edebug-trace t may cause stuff being inserted into c


From: martin rudalics
Subject: bug#10805: 24.0.93; edebug-trace t may cause stuff being inserted into current buffer
Date: Tue, 14 Feb 2012 11:53:48 +0100

> 1. emacs -Q
> 2. I write this into the scratch buffer:
>      (defun f (x) (if (> x 0) (* x (f (1- x))) 0))
>    and do M-1 C-M-x
> 3. M-: (setq edebug-trace t) RET
> 4. M-: (f 5) RET
>
> Then, "{ f args: (5)" is inserted into *scratch*.
>
> The bug is related to this commented code at the end of
> `edebug-pop-to-buffer':
>
>   ;; Selecting the window does not set the buffer until command loop.
>   ;;(set-buffer buffer)
>
> If I uncomment this call to `set-buffer', the problem disappears.
>
> Seems the one who commented this line of code wanted to test if it is
> (still) needed - seems it is.

More or less so, yes.  This is yet another incarnation of the "unless
WINDOW already is the selected window, its buffer becomes the current
buffer" problem of `select-window'.

We have three possibilites to fix this:

(1) Fix this in `select-window' and friends.  This should be done sooner
    or later but I'm not sure whether "now" is the right moment.

(2) Fix this by uncommenting the line above.  I suppose, however, that
    line was commented out on purpose, hence we might experience more
    surprises in edebug.

(3) Do something like the patch below.  This is the most conservative
    approach and will consequently fail to fix similar problems.  Note
    also that my experience with `edebug-trace' is zero.

martin


*** lisp/emacs-lisp/edebug.el   2012-01-19 07:21:25 +0000
--- lisp/emacs-lisp/edebug.el   2012-02-14 10:43:52 +0000
***************
*** 4129,4146 ****
  ;;      (point) (window-start))
    (let* ((oldbuf (current-buffer))
         (selected-window (selected-window))
!        (buffer (get-buffer-create buf-name))
!        buf-window)
  ;;    (message "before pop-to-buffer") (sit-for 1)
      (edebug-pop-to-buffer buffer)
!     (setq truncate-lines t)
!     (setq buf-window (selected-window))
!     (goto-char (point-max))
!     (insert (apply 'edebug-format fmt args) "\n")
!     ;; Make it visible.
!     (vertical-motion (- 1 (window-height)))
!     (set-window-start buf-window (point))
!     (goto-char (point-max))
  ;;    (set-window-point buf-window (point))
  ;;    (edebug-sit-for 0)
      (bury-buffer buffer)
--- 4129,4145 ----
  ;;      (point) (window-start))
    (let* ((oldbuf (current-buffer))
         (selected-window (selected-window))
!        (buffer (get-buffer-create buf-name)))
  ;;    (message "before pop-to-buffer") (sit-for 1)
      (edebug-pop-to-buffer buffer)
!     (with-current-buffer buffer
!       (setq truncate-lines t)
!       (goto-char (point-max))
!       (insert (apply 'edebug-format fmt args) "\n")
!       ;; Make it visible.
!       (vertical-motion (- 1 (window-height)))
!       (set-window-start nil (point))
!       (goto-char (point-max)))
  ;;    (set-window-point buf-window (point))
  ;;    (edebug-sit-for 0)
      (bury-buffer buffer)







reply via email to

[Prev in Thread] Current Thread [Next in Thread]