emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/realgud 1cc5ddc 59/72: add ability to show all locals i


From: Stefan Monnier
Subject: [elpa] externals/realgud 1cc5ddc 59/72: add ability to show all locals in one command
Date: Fri, 26 Mar 2021 22:49:13 -0400 (EDT)

branch: externals/realgud
commit 1cc5ddc34cfc52ee3fb54642451ae445b5da2683
Author: 813 <813gan@protonmail.com>
Commit: 813 <813gan@protonmail.com>

    add ability to show all locals in one command
    
    This commits introduces
    var realgud-immediately-show-all-locals,
    realgud-locals-show-all-values and
    realgud-locals-hide-all-values
---
 realgud/common/buffer/locals.el | 35 +++++++++++++++++++++++++++++++----
 realgud/common/custom.el        |  5 +++++
 realgud/common/locals-mode.el   |  6 ++++--
 3 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/realgud/common/buffer/locals.el b/realgud/common/buffer/locals.el
index 33ca741..3e918cd 100644
--- a/realgud/common/buffer/locals.el
+++ b/realgud/common/buffer/locals.el
@@ -98,16 +98,24 @@ LOCAL-VAR-NAME - variable to inspect"
    (car (realgud-run-command-get-output 'realgud:cmd-info-type local-var-name))
    (mapconcat 'identity (realgud-run-command-get-output 
'realgud:cmd-info-value local-var-name) "\n") ))
 
-(defun realgud-locals-register-reload ()
-  "Get list of local variables and load values selected by user."
+(defun realgud-locals-register-reload (&optional action)
+  "Get list of local variables and load values selected by user.
+
+If ACTION is set to 'showall unconditionally show all values.
+If ACTION is set to 'hideall hide all values."
   (let* ((locals-names-list (realgud-run-command-get-output 
'realgud:cmd-info-locals-name-list))
         (frame-id 'frame_id_placeholder)
         (locals-data-hash (realgud-get-info 'locals-data))
         (frame-data-hash (gethash frame-id locals-data-hash))
         (new-frame-data-hash (make-hash-table :test 'equal)))
+    ;; Iterate over list of variables and get values if user expanded values 
in past
+    ;;  or we are in this frame for first time, but 
"realgud-immediately-show-all-locals" is t
+    ;;  or function is called with ACTION argument
     (dolist (local-var-name locals-names-list)
-      (if (and frame-data-hash
-              (gethash local-var-name frame-data-hash))
+      (if (and (not (eq action 'hideall))
+          (or (and frame-data-hash (gethash local-var-name frame-data-hash))
+              (and (not frame-data-hash) realgud-immediately-show-all-locals)
+              (eq action 'showall) ))
          (puthash local-var-name
                   (realgud-locals-get-variable-data local-var-name)
                   new-frame-data-hash)
@@ -128,6 +136,25 @@ LOCAL-VAR-NAME - variable to toggle"
     (puthash local-var-name value frame-data-hash) )
   (realgud-locals-insert) )
 
+(defun realgud:locals-show-all-values ()
+  "Expand values of all variables."
+  ;; TODO in future this function should use separated debugger command that 
would get all values
+  ;;  in single call. Current implementation may be painful to use during 
remote debugging
+  ;;  in high latency networks.
+  (interactive)
+  (with-current-buffer-safe (realgud-get-cmdbuf)
+    (realgud-locals-register-reload 'showall)
+    (realgud-locals-insert) )
+  )
+
+(defun realgud:locals-hide-all-values ()
+  "Collapse values of all variables."
+  (interactive)
+  (with-current-buffer-safe (realgud-get-cmdbuf)
+    (realgud-locals-register-reload 'hideall)
+    (realgud-locals-insert) )
+  )
+
 (defun realgud-locals-insert ()
   "Serialize and format locales data."
   (let ((frame-data-hash
diff --git a/realgud/common/custom.el b/realgud/common/custom.el
index 771bc31..ea69c3d 100644
--- a/realgud/common/custom.el
+++ b/realgud/common/custom.el
@@ -25,6 +25,11 @@ A setting of `nil` allows editing, but Short-Key-mode use 
may inhibit this."
   :type 'boolean
   :group 'realgud)
 
+(defcustom realgud-immediately-show-all-locals t
+  "Immediately expand all values in locals window."
+  :type 'boolean
+  :group 'realgud)
+
 (defcustom realgud-update-hook nil
   "List of hooks to be run when debugger hits breakpoint"
   :type 'hook
diff --git a/realgud/common/locals-mode.el b/realgud/common/locals-mode.el
index 4b3ec81..badc3b6 100644
--- a/realgud/common/locals-mode.el
+++ b/realgud/common/locals-mode.el
@@ -24,8 +24,10 @@
   (let ((map  (realgud-populate-debugger-menu (make-sparse-keymap))))
     (suppress-keymap map)
     (realgud-populate-common-keys map)
-    (define-key map "q"       'realgud:cmd-quit)
-    (define-key map "L"       'realgud:window-locals)
+    (define-key map "q" 'realgud:cmd-quit)
+    (define-key map "L" 'realgud:window-locals)
+    (define-key map "s" 'realgud:locals-show-all-values)
+    (define-key map "h" 'realgud:locals-hide-all-values)
     map)
   )
 



reply via email to

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