From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Edebug, with Elisp source in different frame - Edebug doesn't select the source window. [PATCH] Date: Thu, 18 Oct 2018 11:08:24 +0000 Message-ID: <20181018110824.GA3929@ACM> References: <20181017142226.GC4753@ACM> <20181017162253.GD4753@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1539861276 13879 195.159.176.226 (18 Oct 2018 11:14:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 18 Oct 2018 11:14:36 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 18 13:14:32 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gD6G8-0003Va-7n for ged-emacs-devel@m.gmane.org; Thu, 18 Oct 2018 13:14:32 +0200 Original-Received: from localhost ([::1]:41708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD6IE-0007kr-Rj for ged-emacs-devel@m.gmane.org; Thu, 18 Oct 2018 07:16:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD6I8-0007kk-Ms for emacs-devel@gnu.org; Thu, 18 Oct 2018 07:16:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD6I5-0007LS-B4 for emacs-devel@gnu.org; Thu, 18 Oct 2018 07:16:36 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:30952 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1gD6I4-0007DS-UW for emacs-devel@gnu.org; Thu, 18 Oct 2018 07:16:33 -0400 Original-Received: (qmail 33860 invoked by uid 3782); 18 Oct 2018 11:16:27 -0000 Original-Received: from acm.muc.de (p5B1473D9.dip0.t-ipconnect.de [91.20.115.217]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 18 Oct 2018 13:16:26 +0200 Original-Received: (qmail 7675 invoked by uid 1000); 18 Oct 2018 11:08:24 -0000 Content-Disposition: inline In-Reply-To: <20181017162253.GD4753@ACM> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:230472 Archived-At: Hello, Emacs. On Wed, Oct 17, 2018 at 16:22:53 +0000, Alan Mackenzie wrote: > On Wed, Oct 17, 2018 at 14:22:26 +0000, Alan Mackenzie wrote: > > In a GUI Emacs (26.1 or master), instrument a function for edebug with > > C-u C-M-x in frame F1. From a different frame, F2, cause this function > > to be called, thus entering edebug. F2 is still selected. Surely edebug > > should have selected F1? > I've found the answer, I think. Edebug is using select-window to select > the frame. What select-window doesn't do is to shift the X-Window focus. > For that, one needs to call select-frame-set-input-focus, something which > the current incarnation of edebug fails to do. More precisely, the function to call is x-focus-frame. > My first experimentation with s-f-set-i-focus indicates this is the > problem. I will come up with a patch. Here is the first version of that patch. Now, in X, when edebug is entered, the focus is moved to edebug buffer's frame. When edebug is terminated, it is moved back to the original frame. edebug-bounce-point has not been working either, but is more difficult to fix. :-( Comments? diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index fb567c9cce..4d9850c7f6 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -2328,6 +2328,7 @@ edebug-default-enter (debugger edebug-debugger) ; only while edebug is active. (edebug-outside-debug-on-error debug-on-error) (edebug-outside-debug-on-quit debug-on-quit) + (outside-frame (selected-frame)) ;; Binding these may not be the right thing to do. ;; We want to allow the global values to be changed. (debug-on-error (or debug-on-error edebug-on-error)) @@ -2338,7 +2339,9 @@ edebug-default-enter edebug-initial-mode edebug-execution-mode) edebug-next-execution-mode nil) - (edebug-default-enter function args body)))) + (edebug-default-enter function args body)) + (if (frame-live-p outside-frame) + (x-focus-frame outside-frame)))) (let* ((edebug-data (get function 'edebug)) (edebug-def-mark (car edebug-data)) ; mark at def start @@ -2647,6 +2650,7 @@ edebug--display-1 (edebug-eval-display eval-result-list) ;; The evaluation list better not have deleted edebug-window-data. (select-window (car edebug-window-data)) + (x-focus-frame (window-frame (selected-window))) (set-buffer edebug-buffer) (setq edebug-buffer-outside-point (point)) -- Alan Mackenzie (Nuremberg, Germany).