From 044e11641bc0bfaf0d735bd57f04333f9616cfc7 Mon Sep 17 00:00:00 2001 From: Santiago Calandrino Date: Wed, 24 Aug 2022 13:54:28 +0200 Subject: [PATCH] Fix string padding in gdb-mi * lisp/progmodes/gdb-mi.el (gdb-table): Fix string padding in gdb-mi (bug#57362). (gdb-pad-string): Unobsolete. (gdb-table-string): Re-fix string padding. Copyright-paperwork-exempt: yes --- lisp/progmodes/gdb-mi.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index c256198b3c1..bab80719dbd 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -2943,8 +2943,7 @@ Return position where LINE begins." start-posn))) (defun gdb-pad-string (string padding) - (declare (obsolete string-pad "29.1")) - (string-pad string padding nil t)) + (string-pad string (abs padding) nil (natnump padding))) ;; gdb-table struct is a way to programmatically construct simple ;; tables. It help to reliably align columns of data in GDB buffers @@ -2962,8 +2961,7 @@ When non-nil, PROPERTIES will be added to the whole row when calling `gdb-table-string'." (let ((rows (gdb-table-rows table)) (row-properties (gdb-table-row-properties table)) - (column-sizes (gdb-table-column-sizes table)) - (right-align (gdb-table-right-align table))) + (column-sizes (gdb-table-column-sizes table))) (when (not column-sizes) (setf (gdb-table-column-sizes table) (make-list (length row) 0))) @@ -2973,9 +2971,7 @@ calling `gdb-table-string'." (append row-properties (list properties))) (setf (gdb-table-column-sizes table) (cl-mapcar (lambda (x s) - (let ((new-x - (max (abs x) (string-width (or s ""))))) - (if right-align new-x (- new-x)))) + (max (abs x) (string-width (or s "")))) (gdb-table-column-sizes table) row)) ;; Avoid trailing whitespace at eol @@ -2991,7 +2987,10 @@ calling `gdb-table-string'." (lambda (row properties) (apply #'propertize (mapconcat #'identity - (cl-mapcar (lambda (s x) (string-pad s x nil t)) + (cl-mapcar (lambda (s x) + (string-pad + s x nil + (not (gdb-table-right-align table)))) row column-sizes) sep) properties)) -- 2.39.2