aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustaf Waldemarson2022-11-29 23:40:23 +0100
committerEli Zaretskii2022-12-10 15:26:50 +0200
commit5d506a7eab693bbd3ef4c9a6f2ff6e61ee5b84b7 (patch)
tree0ef203a55000ec06484a957bf9320d257d9ad00b
parentcb202d30edbdaf710327f71feaa5985e35c75d86 (diff)
downloademacs-5d506a7eab693bbd3ef4c9a6f2ff6e61ee5b84b7.tar.gz
emacs-5d506a7eab693bbd3ef4c9a6f2ff6e61ee5b84b7.zip
gdb-mi.el: Configure variable order and length in local-vars window
This changes allows users to configure the order of various properties as well as truncating their length. The full description of each property is available as a help-text (tooltip). * lisp/progmodes/gdb-mi.el (gdb-locals-table-row-config): New user option. (gdb-locals-value-filter): Don't limit the values here. (gdb-locals-table-columns-list): New function. (gdb-locals-handler-custom): Call it. (Bug#59730) * etc/NEWS: Announce the change.
-rw-r--r--etc/NEWS14
-rw-r--r--lisp/progmodes/gdb-mi.el53
2 files changed, 57 insertions, 10 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 61f813568f0..e92e3b84682 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -40,6 +40,20 @@ connection.
40 40
41 41
42* Changes in Specialized Modes and Packages in Emacs 30.1 42* Changes in Specialized Modes and Packages in Emacs 30.1
43---
44** Variable order and truncation can now be configured in gdb-many-window mode.
45The new variable `gdb-locals-table-row-config' allows users to
46configure the order and max length of various properties in the local
47variables buffer when using `gdb-many-windows'.
48
49By default, this variable is set to write the properties in the order:
50name, type and value. Where the name and type are truncated to 20
51characters, and the value is truncated to the value of
52`gdb-locals-value-limit'.
53
54In order to restore the old display behavior, set
55`gdb-locals-table-row-config' to `((type . 0)(name . 0)(value
56. ,gdb-locals-value-limit)).
43 57
44** VC 58** VC
45 59
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index e8d8f9104e4..9cbee50ce31 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -4355,6 +4355,24 @@ member."
4355 :group 'gud 4355 :group 'gud
4356 :version "29.1") 4356 :version "29.1")
4357 4357
4358(defcustom gdb-locals-table-row-config `((name . 20)
4359 (type . 20)
4360 (value . ,gdb-locals-value-limit))
4361 "Configuration for table rows in the local variable display.
4362
4363An alist that controls the display of the name, type and value of
4364local variables inside the currently active stack-frame. The key
4365controls which column to change whereas the value determines the
4366maximum number of characters to display in each column. A value
4367of 0 means there is no limit.
4368
4369Additionally, the order the element in the alist determines the
4370left-to-right display order of the properties."
4371 :type '(alist :key-type 'symbol :value-type 'integer)
4372 :group 'gud
4373 :version "30.1")
4374
4375
4358(defvar gdb-locals-values-table (make-hash-table :test #'equal) 4376(defvar gdb-locals-values-table (make-hash-table :test #'equal)
4359 "Mapping of local variable names to a string with their value.") 4377 "Mapping of local variable names to a string with their value.")
4360 4378
@@ -4384,12 +4402,9 @@ member."
4384 4402
4385(defun gdb-locals-value-filter (value) 4403(defun gdb-locals-value-filter (value)
4386 "Filter function for the local variable VALUE." 4404 "Filter function for the local variable VALUE."
4387 (let* ((no-nl (replace-regexp-in-string "\n" " " value)) 4405 (let* ((no-nl (replace-regexp-in-string "\n" " " (or value "<Unknown>")))
4388 (str (replace-regexp-in-string "[[:space:]]+" " " no-nl)) 4406 (str (replace-regexp-in-string "[[:space:]]+" " " no-nl)))
4389 (limit gdb-locals-value-limit)) 4407 str))
4390 (if (>= (length str) limit)
4391 (concat (substring str 0 limit) "...")
4392 str)))
4393 4408
4394(defun gdb-edit-locals-value (&optional event) 4409(defun gdb-edit-locals-value (&optional event)
4395 "Assign a value to a variable displayed in the locals buffer." 4410 "Assign a value to a variable displayed in the locals buffer."
@@ -4403,6 +4418,22 @@ member."
4403 (gud-basic-call 4418 (gud-basic-call
4404 (concat "-gdb-set variable " var " = " value))))) 4419 (concat "-gdb-set variable " var " = " value)))))
4405 4420
4421
4422(defun gdb-locals-table-columns-list (alist)
4423 "Format and arrange the columns in locals display based on ALIST."
4424 (let (columns)
4425 (dolist (config gdb-locals-table-row-config columns)
4426 (let* ((key (car config))
4427 (max (cdr config))
4428 (prop (alist-get key alist)))
4429 (when prop
4430 (if (and (> max 0) (length> prop max))
4431 (push (propertize (string-truncate-left prop max) 'help-echo prop)
4432 columns)
4433 (push prop columns)))))
4434 (nreverse columns)))
4435
4436
4406;; Complex data types are looked up in `gdb-locals-values-table'. 4437;; Complex data types are looked up in `gdb-locals-values-table'.
4407(defun gdb-locals-handler-custom () 4438(defun gdb-locals-handler-custom ()
4408 "Handler to rebuild the local variables table buffer." 4439 "Handler to rebuild the local variables table buffer."
@@ -4431,12 +4462,14 @@ member."
4431 help-echo "mouse-2: edit value" 4462 help-echo "mouse-2: edit value"
4432 local-map ,gdb-edit-locals-map-1) 4463 local-map ,gdb-edit-locals-map-1)
4433 value)) 4464 value))
4465 (setf (gdb-table-right-align table) t)
4466 (setq name (propertize name 'font-lock-face font-lock-variable-name-face))
4467 (setq type (propertize type 'font-lock-face font-lock-type-face))
4434 (gdb-table-add-row 4468 (gdb-table-add-row
4435 table 4469 table
4436 (list 4470 (gdb-locals-table-columns-list `((name . ,name)
4437 (propertize type 'font-lock-face font-lock-type-face) 4471 (type . ,type)
4438 (propertize name 'font-lock-face font-lock-variable-name-face) 4472 (value . ,value)))
4439 value)
4440 `(gdb-local-variable ,local)))) 4473 `(gdb-local-variable ,local))))
4441 (insert (gdb-table-string table " ")) 4474 (insert (gdb-table-string table " "))
4442 (setq mode-name 4475 (setq mode-name