all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Štěpán Němec" <stepnem@gmail.com>
To: Yuan Fu <casouri@gmail.com>, martin rudalics <rudalics@gmx.at>
Cc: 39181@debbugs.gnu.org
Subject: bug#39181: 27.0.50; [PATCH] Allow users to store & restore gdb-mi layout
Date: Mon, 09 Mar 2020 20:18:44 +0100	[thread overview]
Message-ID: <87ftehjq0b.fsf@gmail.com> (raw)
In-Reply-To: <B2CA1F86-3579-4752-808B-2162D1E25DEB@gmail.com>


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 <casouri@gmail.com>
> 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=UTF-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 non-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-windows))
                                                          ^^^^^^^^^^^^^^^^^^^
[...]

> +(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,

  Štěpán





  reply	other threads:[~2020-03-09 19:18 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5e950f28.1c69fb81.61726.5731.GMR@mx.google.com>
2020-01-18 20:57 ` bug#39181: 27.0.50; [PATCH] Allow users to store & restore gdb-mi layout Yuan Fu
2020-01-31 10:13   ` Eli Zaretskii
2020-02-02 14:22     ` Yuan Fu
2020-02-07 22:28       ` Yuan Fu
2020-02-10  4:56         ` Yuan Fu
2020-02-15  8:08           ` Eli Zaretskii
2020-02-15  9:55             ` martin rudalics
2020-02-15 10:19               ` Eli Zaretskii
2020-02-15 20:37                 ` Yuan Fu
2020-02-16 10:00                   ` martin rudalics
2020-03-03 23:41                     ` Yuan Fu
2020-03-04 13:28                       ` Fu Yuan
2020-03-05  6:12                         ` Yuan Fu
2020-03-05  9:14                           ` martin rudalics
2020-03-07 18:09                             ` Yuan Fu
2020-03-07 19:07                               ` Štěpán Němec
2020-03-07 19:17                                 ` Yuan Fu
2020-03-09  9:01                                   ` martin rudalics
2020-03-09 17:59                                     ` Yuan Fu
2020-03-09 19:18                                       ` Štěpán Němec [this message]
2020-03-09 20:17                                         ` Yuan Fu
2020-03-09 20:54                                           ` Štěpán Němec
2020-03-10  8:49                                           ` martin rudalics
2020-03-10 18:05                                             ` Fu Yuan
2020-03-11  8:52                                               ` martin rudalics
2020-03-11  9:26                                                 ` Štěpán Němec
2020-03-12  8:22                                                   ` martin rudalics
2020-03-12  8:49                                                     ` Štěpán Němec
2020-03-12 19:21                                                       ` Yuan Fu
2020-03-13 20:09                                                         ` Yuan Fu
     [not found]                                                           ` <87lfo4netg.fsf@gmail.com>
2020-03-13 21:13                                                             ` Štěpán Němec
2020-03-13 21:40                                                               ` Yuan Fu
2020-03-13 22:12                                                                 ` Štěpán Němec
2020-03-15 15:55                                                                 ` martin rudalics
2020-03-16  0:13                                                                   ` Yuan Fu
2020-03-16  9:24                                                                     ` martin rudalics
2020-03-20 20:03                                                                       ` Yuan Fu
2020-03-20 20:58                                                                         ` Štěpán Němec
2020-03-21 18:00                                                                           ` Yuan Fu
2020-03-21 18:39                                                                             ` Štěpán Němec
2020-03-21 21:03                                                                               ` Yuan Fu
2020-03-21 21:49                                                                                 ` Štěpán Němec
2020-03-24 16:14                                                                                   ` Yuan Fu
2020-03-27  9:01                                                                                     ` martin rudalics
2020-03-27 16:28                                                                                       ` Yuan Fu
2020-04-14  8:05                                                                                         ` martin rudalics
2020-03-10  8:48                                       ` martin rudalics
2020-04-14  1:17   ` bug#39181: Fwd: Delivery Status Notification (Failure) Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ftehjq0b.fsf@gmail.com \
    --to=stepnem@gmail.com \
    --cc=39181@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.