]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/edebug.el
upstream
[gnu-emacs] / lisp / emacs-lisp / edebug.el
index f147fba167d64883df6c2a7f704e5cbbf7c349a3..315fbbcf1f34418d9ab28a7a6301c8a8a17956ab 100644 (file)
@@ -375,7 +375,7 @@ Return the result of the last expression in BODY."
         ((edebug-get-buffer-window buffer))
         ((one-window-p 'nomini)
          ;; When there's one window only, split it.
-         (split-window))
+         (split-window (minibuffer-selected-window)))
         ((let ((trace-window (get-buffer-window edebug-trace-buffer)))
            (catch 'found
              (dolist (elt (window-list nil 'nomini))
@@ -386,13 +386,10 @@ Return the result of the last expression in BODY."
                  (throw 'found elt))))))
         ;; All windows are dedicated or show `edebug-trace-buffer', split
         ;; selected one.
-        (t (split-window))))
-  (select-window window)
+        (t (split-window (minibuffer-selected-window)))))
   (set-window-buffer window buffer)
-  (set-window-hscroll window 0);; should this be??
-  ;; Selecting the window does not set the buffer until command loop.
-  ;;(set-buffer buffer)
-  )
+  (select-window window)
+  (set-window-hscroll window 0)) ;; should this be??
 
 (defun edebug-get-displayed-buffer-points ()
   ;; Return a list of buffer point pairs, for all displayed buffers.
@@ -4415,6 +4412,21 @@ With prefix argument, make it a temporary breakpoint."
 \f
 ;;; Finalize Loading
 
+;; When edebugging a function, some of the sub-expressions are
+;; wrapped in (edebug-enter (lambda () ..)), so we need to teach
+;; called-interactively-p that calls within the inner lambda should refer to
+;; the outside function.
+(add-hook 'called-interactively-p-functions
+          #'edebug--called-interactively-skip)
+(defun edebug--called-interactively-skip (i frame1 frame2)
+  (when (and (eq (car-safe (nth 1 frame1)) 'lambda)
+             (eq (nth 1 (nth 1 frame1)) '())
+             (eq (nth 1 frame2) 'edebug-enter))
+    ;; `edebug-enter' calls itself on its first invocation.
+    (if (eq (nth 1 (internal--called-interactively-p--get-frame i))
+            'edebug-enter)
+        2 1)))
+
 ;; Finally, hook edebug into the rest of Emacs.
 ;; There are probably some other things that could go here.