From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Newsgroups: gmane.emacs.bugs Subject: bug#39181: 27.0.50; [PATCH] Allow users to store & restore gdb-mi layout Date: Mon, 09 Mar 2020 20:18:44 +0100 Message-ID: <87ftehjq0b.fsf@gmail.com> References: <75FC69BA-CCD4-46D0-B9F5-109200C796F3@gmail.com> <55235252-FD03-4801-804A-864EFC1DCA0A@gmail.com> <90254CFF-2FFD-4D54-8467-717FF10166A2@gmail.com> <5c8d9f6a-0bc5-b2ff-1513-4b8631fee1a3@gmx.at> <2A945E3B-5506-4077-9C2E-AD049BCEFA23@gmail.com> <87zhcsyoee.fsf@gmail.com> <7DBBA6F5-4F53-48DC-A895-A0B06FF2A333@gmail.com> <2bc5d577-eded-c79c-5b05-c815ed8ac212@gmx.at> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="98031"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Notmuch/0.29.3 (https://notmuchmail.org) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 39181@debbugs.gnu.org To: Yuan Fu , martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 09 20:21:04 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jBNxY-000PMg-75 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 09 Mar 2020 20:21:04 +0100 Original-Received: from localhost ([::1]:48392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNxX-0008KB-7j for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 09 Mar 2020 15:21:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49256) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNvc-0005H1-1B for bug-gnu-emacs@gnu.org; Mon, 09 Mar 2020 15:19:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBNva-000771-IA for bug-gnu-emacs@gnu.org; Mon, 09 Mar 2020 15:19:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45495) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jBNva-00076m-Bh for bug-gnu-emacs@gnu.org; Mon, 09 Mar 2020 15:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jBNva-0005qe-7U for bug-gnu-emacs@gnu.org; Mon, 09 Mar 2020 15:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Mar 2020 19:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39181 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 39181-submit@debbugs.gnu.org id=B39181.158378151422450 (code B ref 39181); Mon, 09 Mar 2020 19:19:02 +0000 Original-Received: (at 39181) by debbugs.gnu.org; 9 Mar 2020 19:18:34 +0000 Original-Received: from localhost ([127.0.0.1]:51468 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jBNv8-0005q1-CI for submit@debbugs.gnu.org; Mon, 09 Mar 2020 15:18:34 -0400 Original-Received: from mail-lf1-f66.google.com ([209.85.167.66]:34615) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jBNv7-0005po-44 for 39181@debbugs.gnu.org; Mon, 09 Mar 2020 15:18:33 -0400 Original-Received: by mail-lf1-f66.google.com with SMTP id i19so2750027lfl.1 for <39181@debbugs.gnu.org>; Mon, 09 Mar 2020 12:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-transfer-encoding; bh=yrsk6TdpyXn5obr6SvGF4FKaHimnktTbYVq4jSITjvo=; b=gpoF6GYKZ2D82rYnnHQ7u0sUk7/RipH1/7ccHV+2Cdc+1bYl4oYoP+pv88Th2EtRha AA3bzZ3GUDCkmjxkV5A/dIRrKI1QXM6xJDxJsaFx3uB8Tz0YA+qztAkVNznmpHRDWUvr bIoU4osiO2AXWxIZo9NrUyh2UZJzBkf8hXbCFb7w+LyIbJX/oklyJo7QvwKfdhVAuoNe VrGgeGfdAlvfg7HhSLKeq7BCLRAPtirsJ9z4h0nuY0Nlyqmx7L7thkRyGDNBG49cRaDc PWo2JMyQ3sCiFQluHE2LBvtA4XvewOJ1SOEHSH8bMtOvOsl979pIGa+eGh2TGMCw8rcv cahg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-transfer-encoding; bh=yrsk6TdpyXn5obr6SvGF4FKaHimnktTbYVq4jSITjvo=; b=cZJ7aOSxi56ZjPILkuC8fshmJgpMM3jNLBaWqnL7n9VKldeRa70sSHGOr56YhkhwmK zrG2xWGB76PPUUphy5xZV9mvQ5rVmgPX4jXVN53CZFAhvZdwrNS23YBgF1rT6qS/tlLn l+s5iJJ/JIRCnr9tRubvnaMk99SQmrqy5hGU0CeodiRlTrOJcEVY2Ck3TxwS5lcGhaPv 3ROagmkJIoKgovmuZnzFRUE6wsvL7KXVui5gu3k101R7kcASanzNPClpAWyVwA1gN1+H /RTBhjo2PmpBC4k9IYMljRTQTT9hNgDDymMCEYqhx9CfAQAt1/pFO56lptY/VhIWlv2d HW7Q== X-Gm-Message-State: ANhLgQ1CHatxw8hTigRaAQnbbhnqZoW3yyI75lxDPFS3kozoNRMfPNPG UipbcYzMf/KmcFJe5vzIr8g= X-Google-Smtp-Source: ADFU+vtYzZ+TYGmxkwKhT7GRh0nfRNnZF9SvUTx4NZGJVj1xkZ/81L6kH3e1bhPyUOHwap2UpjcOZg== X-Received: by 2002:ac2:5508:: with SMTP id j8mr5824584lfk.31.1583781507047; Mon, 09 Mar 2020 12:18:27 -0700 (PDT) Original-Received: from localhost ([185.112.167.59]) by smtp.gmail.com with ESMTPSA id r15sm22024345ljh.11.2020.03.09.12.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2020 12:18:26 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:177104 Archived-At: Again, having little experience with gdb(-mi) I have mostly checked the doc strings; I hope Martin will provide better feedback. Other than the nit picks below, I have one question: is there any difference between "window layout" and "window configuration" in this context? You seem to be using both interchangeably, both in documentation and the function/variable names. There seems to be some prior usage of "layout" in gdb-mi, but the general Emacs term AFAIK is "configuration". Wouldn't it make sense to unify the usage somewhat, at least in the new code? Just an observation (I found it confusing.) On Mon, 09 Mar 2020 13:59:31 -0400 Yuan Fu wrote: > From c27f39a3e321a7a1111f71dd95573104f025c89c Mon Sep 17 00:00:00 2001 > From: Yuan Fu > Date: Tue, 3 Mar 2020 18:30:03 -0500 > Subject: [PATCH] Add window streo/restore feature for gdb-mi > MIME-Version: 1.0 > Content-Type: text/plain; charset=3DUTF-8 > Content-Transfer-Encoding: 8bit > > Add a feature that allows a user to save a gdb window layout to a file > with 'gdb-save-window-layout' and load it back it with ^^ Typo? [...] > +(defcustom gdb-restore-window-layout-after-quit nil > + "Specify whether to restore the window layout the user had before gdb = starts. > + > +Possible values are: > + t -- Always restore. > + nil -- Don't restore. > + 'if-show-main -- Restore only if `gdb-show-main' is non-nil > + 'if-many-windows -- Restore only if variable `gdb-many-windows' is n= on-nil." ^^^^^^^^^^^^^^^^ The documented symbols don't match the actual ones below. Also, if you want to quote them in the doc string, the convention (which you do follow elsewhere) is `like-this', 'this is confusing. > + :type '(choice > + (const :tag "Always restore" t) > + (const :tag "Don't restore" nil) > + (const :tag "Depends on `gdb-show-main'" 'if-gdb-show-main) > + (const :tag "Depends on `gdb-many-windows'" 'if-gdb-many-windo= ws)) ^^^^^^^^^^^^^^^^^= ^^ [...] > +(defun gdb-toggle-restore-window-layout () > + "Toggle whether to restore window layout when GDB quit." ^^^^ quits > + (interactive) > + (setq gdb-restore-window-layout-after-quit > + (not gdb-restore-window-layout-after-quit))) > + > +(defun gdb-get-source-buffer () > + "Return a buffer displaying source file or nil if we can't find one. > + > +The source file is the file that contains the code at where GDB ^^^^^^^^ Just "where", or perhaps "source location where"? > +stops. There could be multiple source files during a debugging > +session, we get the most recently showed one. If program hasn't > +start running yet, the source file is the \"main file\" at where ^^^^^^^^ Same as above. > +the GDB session starts (see `gdb-main-file')." [...] > +(defun gdb-function-buffer-p (buffer) > + "Return t if BUFFER is a GDB function buffer. > + > +Function buffers are locals buffer, registers buffer, etc, but > +not including main command buffer (the one in where you type GDB ^^^^^^^^ Again, just "where". > +commands) or source buffers (that displays program source code)." ^ "display" [...] > +(defun gdb-load-window-layout (file) > + "Restore window layout (window configuration) from FILE. > + > +FILE should be a window layout file saved by > +`gdb-save-window-layout'." > + (interactive (list (read-file-name > + "Restore window configuration from file: " > + (or gdb-window-layout-directory default-directory)= ))) > + ;; Basically, we restore window configuration and go through each > + ;; window and restore the function buffers. > + (let* ((placeholder (get-buffer-create " *gdb-placeholder*"))) > + (unwind-protect ; Don't leak buffer. > + (let ((window-config (with-temp-buffer > + (insert-file-contents file) > + ;; We need to go to point-min even we > + ;; are reading the whole buffer. I can't understand this comment. Maybe "even" should have been "so that"? > + (goto-char (point-min)) > + (read (current-buffer)))) [...] > @@ -4659,6 +4847,9 @@ gdb-many-windows > (defun gdb-restore-windows () > "Restore the basic arrangement of windows used by gdb. > This arrangement depends on the value of option `gdb-many-windows'." > + ;; This function is used when the user messed up window > + ;; configuration and want to "reset to default". The function that ^^^^ "wants" [...] > +(defmacro with-window-undedicated (window &rest body) > + "Select WINDOW, set it to be undedicated and execute BODY. > + > +WINDOW is only set to be undedicated temporarily while executing > +BODY. That is, the original value of WINDOW's dedication is > +restored after executing BODY. If WINDOW is nil, use the > +selected window. The value returned is the value of the last > +form in BODY. The "temporarily" thing is actually expected/understood with with- macros, so I think it could be simplified to something like the following (BTW, while there are occurences or "non-dedicated" in Emacs sources, there are no occurences of "undedicated". Another thing to maybe consider for the sake of consistency/least surprise.): "Evaluate BODY with WINDOW selected and temporarily made non-dedicated. If WINDOW is nil, use the selected window. Return the value of the last form in BODY." Thank you, =C5=A0t=C4=9Bp=C3=A1n